Posts

Showing posts from February, 2010

In the excel/vba IDE, How can I quickly see the code for a function in my code and then come back? -

it such chore hit ctrl + r everytime , try remember in module keep function !! worse excel sheet focused , end overwriting data ctrl + r ! the answer shift + f2 , shift + ctrl + f2 go ! i found on forum. you double click on function or subroutine (which somewhere in code) , hit shift + f2 , blammo ! teleported it, no need project explorer !! then hit shift + ctrl + f2 , takes before! such time saver !

excel vba - vlookup splitted through items does not work -

Image
one time, asked on function vlookup split value. using long time. now, code no longer seems work. can reason code working no longer does? sub test() dim cl range, key variant dim dic object: set dic = createobject("scripting.dictionary") dic.comparemode = vbtextcompare sheets("sheet1") each cl in .range("a1:a" & .cells.specialcells(xlcelltypelastcell).row) if cl.value <> "" dic.add cl.row & "|" & replace(lcase(cl.value), ";", "||") & "|", cl.offset(, 1).text end if next cl end with sheets("sheet2") each cl in .range("a1:a" & .cells.specialcells(xlcelltypelastcell).row) each key in dic if key "*|" & lcase(cl.value) & "|*" , cl.value <> "" cl.offset(, 1).value = dic(key) exit end if next key next cl e

How do I get a unicode symbol/emoji to appear in a listbox in C#? -

the user can "lock" item on listbox prevent being altered. i'm trying symbol '🔒' (unicode 1f512) appear next item, keep getting square '◻'. appears in microsoft visual studio in editor, font consolas. changed font consolas in listbox, , tried number of other fonts, none of them worked. it should work out of box default font microsoft sans serif . the following code works me. it's not production quality, proving point. private void form1_load(object sender, eventargs e) { listbox1.items.add("🔒"); } private void buttonunlock_click(object sender, eventargs e) { listbox1.items[0] = listbox1.items[0].tostring().replace("🔒", ""); } private void buttonappend_click(object sender, eventargs e) { listbox1.items[0] += "🔒"; } at first thought problem language/font settings if visual studio editor able show unicode characters correctly, doesn't seem case.

swift - UICollectionView Section headers & footers show wrong way - iOS -

Image
the problem is: supplementaryview has textlabel on it, text appears @ wrong location while header , footer , textlabel show right. as can see in picture, first section header has title, other header or footers text out of sight(they on screen have scroll down see it). don't know how solve it... i setup collectionview following in viewdidload function: func setupcollectionsview(){ let width:cgfloat = self.view.frame.size.width/4 let flowlayout = uicollectionviewflowlayout() flowlayout.minimuminteritemspacing = 5 flowlayout.minimumlinespacing = 5 flowlayout.estimateditemsize = cgsizemake(width, width) flowlayout.headerreferencesize = cgsizemake(self.view.frame.size.width, 30) flowlayout.footerreferencesize = cgsizemake(self.view.frame.size.width, 30) flowlayout.scrolldirection = uicollectionviewscrolldirection.vertical collectionview = uicollectionview(frame: self.view.frame, collectionviewlayout: flowlayout) collectionview.dataso

date - Where to put this code in laravel? -

i have table in database has 3 columns of type date, stored in y-m-d format. need dates displayed in views d/m/y. model table jobcard.php, every time retrieve instance of jobcard this: $jobcard -> datereqlatest = carbon::createfromformat('y-m-d', $jobcard -> datereqlatest)->format('d/m/y'); $jobcard -> dateissued = carbon::createfromformat('y-m-d', $jobcard -> dateissued)->format('d/m/y'); $jobcard -> datedespatch = carbon::createfromformat('y-m-d', $jobcard -> datedespatch)->format('d/m/y'); i pass $jobcard view. works there several views making use of model , these views use different controllers rather copying code every controller function, want date format automatically converted when pass instance of jobcard view. the user submit dates in form in d/m/y format need covert y-m-d stored in database. where best write code this? you can create acessor called every time access property: pu

javascript - react webapp manage which user can view which features -

i'm pretty new web dev. web app i'm developing uses react , plain js (i' not using flux or redux yet). need add functionality manage user type can view screen/ functionality. can point me / give suggestions on start , possibly best practices on doing it? thanks

node.js - Creating Node Package with Angular2 and Webpackage -

i building large application multiple projects want put angular2 components in module, gets shared between of modules. since using webpack in projects nice use adavantages in node module, generated output not useable. the reason why trying use webpack take advantage of loaders webpack provides. want seperate template , styles in different files. is there way use webpack render angular2 components in way can use them node_module in different project? by default webpack outputs bundle browser. if want code usable in project, can use output.library , output.librarytarget in webpack configuration. example: output: { library: 'mycomponentname', // component / library name librarytarget: 'umd', // or 'commonjs2', 'var', ... } this result in bundle can import in browser or module system supports amd or commonjs2 (like webpack, browserify, requirejs, ...). more information available in webpack documentation these 2 options.

oracle - Synonym not working: USER.SYNONYM_NAME works but SYNONYM_NAME does not -

i have following issue: i have created synonym user in order call procedure schema, output all_synonyms table log sqlplus user_1: owner synonym_name table_owner table_name db_link origin_con_id ~~~~~ ~~~~~~~~~~~~ ~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~ ~~~~~~~~~~~~~ user_1 syn_name admin procedure_name null 0 but i'm unable run using synonym name. if oora-06550. example: exec syn_name; oora-06550: line 1, column 7: pls-00201: identifier 'syn_name' must declared exec user_1.syn_name; //works expected i've ran `grant execute on syn_name user_1; is there else need set? i'm not sure i'm missing. in advance. you can see effect if change current_schema . if matches user works ok: select user, sys_context( 'userenv', 'current_schema') schema dual; user schema ------------------------------ ------------------------------ user_1

excel - Run-time error '1004' Pivot table error -

Image
i looking assistance following error. i have vba code opens workbook , copies in sheet containing pivot table. the code selects pivot table, filters date, , copies fields out. this functionality works on first time use. however, when report used more once in day, hits following error: the issue assignment of pivot table name, vba uses system defaults. code follows: sheets("sheet1").select activeworkbook.showpivottablefieldlist = false activesheet.pivottables("pivottable1").pivotfields("date ").autosort _ xldescending, "date " is there alternative way dynamically select pivot table regardless of name? alternatively, there code clear history @ end of execution every time report run pivot 1? any appreciated. thanks in advance if know there 1 pivot table (as seems have intended in post convey, though may have misinterpretted this), better use index name, name different if new pivot table created while had exi

Getting Specific Array Element - Meteor Mongodb -

i have structure { "_id" : "ebtlm2nmb79wwryer", "notificationbyusers" : { "all" : [ { "account_id" : "x5pjy66jawgoxdb4l", "date" : isodate("2016-07-27t13:48:17.154z"), "value" : null }, { "account_id" : "2c2fkxaktmermnt3e", "date" : isodate("2016-07-27t13:53:10.296z"), "value" : "instant" }, { "account_id" : "6np35oj63cavf4rhs", "date" : isodate("2016-07-28t07:18:22.696z"), "value" : "instant" } ] } } and querying db.collection.findone({_id: ebtlm2nmb79wwryer, 'notificationbyusers.all':{$elemmatch:{account_id: "2c2fkxaktmermnt3e"}}}, {_id:0, 'notificationbyusers.all.$': 1}) it

c - Android mouse cursor event /dev/uinput not moving on Y axis -

i'm trying move cursor mouse on android using /dev/uinput , ioctl. here code : int fd = -1; struct input_event ev; int uinput_open_device() { fd = open("/dev/uinput", o_wronly | o_nonblock); if (fd < 0) { __android_log_print(android_log_debug, "code c", "failed open event"); return -1; } return fd; } int dev_uinput_init_mouse(char *name) { struct uinput_user_dev dev; fd = uinput_open_device(); if (fd > 0) { ioctl(fd, ui_set_evbit, ev_key); ioctl(fd, ui_set_keybit, btn_left); ioctl(fd, ui_set_evbit, ev_rel); ioctl(fd, ui_set_relbit, rel_x); ioctl(fd, ui_set_relbit, rel_y); memset(&dev, 0, sizeof(dev)); strncpy(dev.name, name, uinput_max_name_size); dev.id.bustype = bus_usb; dev.id.vendor = 0x1; dev.id.product = 0x1; dev.id.version = 1; if (write(fd, &dev, sizeof(dev)) < 0) { __android_log_print(android_log_debug, "code c", "failed write")

java - Modification of value in switch case -

public class sample { public static void main(string[] args) { int = 9; switch (i) { default: system.out.println("default"); case 0: system.out.println("zero"); break; case 1: system.out.println("one"); case 2: system.out.println("two"); } } } output: default 0 although i initialized 9, how possible case 0 picked? reason? you miss break statement after first default case excution falls through second case.also put default case last excuted after other cases checked. public static void main(string[] args) { int = 9; switch (i) { case 0: system.out.println("zero"); break; case 1: system.out.println("one"); break; case 2: system.out.println("two"); break; default: system.out.println("default&quo

ruby - Rails spring testunit Bad file descriptor -

i'm trying use spring 1.4.0 rails 3.2.22/ruby 2.2.5, , doing : bundle exec spring testunit <test_file.rb> outputs : /users/igor/.rbenv/versions/2.2.5/gemsets/<app>/gems/spring-1.4.0/lib/spring/application/boot.rb:7:in 'for_fd': bad file descriptor - not socket file descriptor (errno::ebadf) /users/igor/.rbenv/versions/2.2.5/gemsets/<app>/gems/spring-1.4.0/lib/spring/application/boot.rb:7:in '<top (required)>' -e:1:in 'require' -e:1:in '<main>' from gathered in spring source code, faulty instruction unixsocket.for_fd(3) , should first available file handle, why caught bad file descriptor ? any appreciated, !

Python numba: how to find position of the largest element in array -

i'm writing code real-time processing of image camera. using python 3.5 anaconda accelerate/numba packages perform of calculations on gpu. have problems implementing function find position of largest element in float32 2d array. array in gpu memory. problem is: terribly slow. bottleneck of whole code. code: @n_cuda.jit('void(float32[:,:], float32, float32, float32)') def d_findcarpeak(temp_mat, height, width, peak_flat): row, col = cuda.grid(2) if row < height , col < width: peak_flat = temp_mat.argmax() here call it: d_findcarpeak[number_of_blocks, threads_per_block]( d_temp_mat, height, width, d_peak_flat) how can rewrite code?

javascript - jquery function not working inside second document ready -

this question has answer here: what scope of variables in javascript? 23 answers this strange issue confusing me completely. paste whole code make sure nothing missed. echo " <script> $(function() { $('#biddingload').fadeout(500); function notice() { $('#auction_notice').show(); $('#auction_notice').css('background', 'rgba(0, 100, 0, 0.8)'); $('#auction_notice').html('<p>bid accepted!</p>'); settimeout(function() { $('#auction_notice').fadeout(); }, 1000); // <-- time in millisec

jquery - Javascript improving ajax call for populating select -

i using code data , populate select dropdown. $.ajax({ url: 'myurl here', method: 'get', success: function(result) { $.each(result.main, function(result, value) { $('#myselect').append($('<option>').text(value.id).attr('value', value.id)); }); } }); what need after populating select value of 1st line populated in select. how can this? to can set val() of select first item in array. try this: success: function(result) { var html = ''; $.each(result.main, function(result, value) { html += '<option value="' + value.id + '">' + value.id + '</option>' }); $('#myselect').append(html).val(result.main[0].id); } working example alternatively if want force selection first option within select can set selectedindex property 0 : $('#myselect').append(html).prop('selectedindex', 0

objective c - MFSideMenu is not working in iOS? -

Image
hi have followed github page add mfsidemenu , showing following error. undefined symbols architecture x86_64: "_objc_class_$_mfsidemenucontainerviewcontroller", referenced from: objc-class-ref in appdelegate.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) this appdelegate - (viewcontroller *)democontroller { uistoryboard *mainstoryboard = [uistoryboard storyboardwithname:@"main" bundle: nil]; viewcontroller *main = (viewcontroller *)[mainstoryboard instantiateviewcontrollerwithidentifier:@"home"]; return main; } - (uinavigationcontroller *)navigationcontroller { return [[uinavigationcontroller alloc] initwithrootviewcontroller:[self democontroller]]; } - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point customization after application launch. leftmenuc

spring - Can I declare <%@page~ contentType~ pageEncoding~%> or taglib like JSTL only once by using <jsp:include/>? -

i had declare <%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ page session="true" %> these 3 lines each page of jsp file in spring mvc project. made header.jsp 3 lines and, , used other jsp pages. but won't work. other jsp pages still needed declare 3 lines. any way not declare 3 lines every page, , declared once?

cryptography - RNGCryptoServiceProvider in .Net Core -

i cannot find system.security.cryptography.rngcryptoserviceprovider class in .netcore. it essential application trying port .net framework, being used generate initialisation vector encryption. does exist under different name, or there way of achieving functionality? system.security.cryptography.randomnumbergenerator base class cryptographically-secure pseudo-random number generator (csprng) implementations. in .net framework randomnumbergenerator.create() returns rngcryptoserviceprovider instance (unless configured differently cryptoconfig ). in .net core randomnumbergenerator.create() returns opaque type based on bcryptgenrandom (windows) or openssl's random number generator (!windows). randomnumbergenerator.create() way rng instance on .net core, , since works on both .net core , .net framework portable. of course, if you're generating iv, can call instance method symmetricalgorithm.generateiv() have use csprng internally; though documentation say

c++ - Why cannot clang++ deduce the type of a map of lambdas? -

i have following piece of code: enum relationaloperator { lt, lte, eq, gte, gt }; std::map<relationaloperator, bool (*)(const point&, const point&)> ops = { { gte, [](const point& a, const point& b) { return >= b; } }, { lte, [](const point& a, const point& b) { return <= b; } }, { eq, [](const point& a, const point& b) { return == b; } }, { gt, [](const point& a, const point& b) { return > b; } }, { lt, [](const point& a, const point& b) { return < b; } }, }; this code inside template , point template parameter. i tried replace type of variable ops auto clang++ says: src/utils.hpp:47:10: error: cannot deduce actual type variable 'ops' type 'auto' initializer list why that? thought keyword auto these kinds of situations, type long , obvious. first of all, each lambda has own type, given set of different lambdas, cannot factor them single type without manual c

akka - why actor module not support concurrent mailbox? -

i'm fresh akka, actor,i wonder why can't find concurrent mailbox use. result, must define dispatch actor send work actor.many times, not care data's sequence , in situation make message sequence cost time. i find create actor router props choice: val actorref: actorref = context.actorof(props[myactor] .withrouter(roundrobinpool(nrofinstances = 4)), name = "myactor") //or context.actorof(roundrobinpool(5).props(props[myactor]), "myactor") it create 4 actor instance return 1 actorref -- roundrobinpool handle , dispatch message these actors.

android - I/art: Can not find class: -

Image
hello there new such kind of android studio error. may warning have been facing issue of not finding classes. actually i'm working on android camera api application , problem front facing camera preview stretch. happens 2-3 devices huawei p8 lite . device stretches camera preview when switched front facing camera! i have camera preview class as: public class camerapreview extends surfaceview implements surfaceholder.callback { //variables de' preview private surfaceholder mholder; private list<camera.size> msupportedpreviewsizes; private camera.size mpreviewsize; private int focus_area_size=300; public static camera previewcamera; //////////////////////// //protected logger keys protected final string exception_key="xception"; ////////////////////////// public camerapreview(context context, camera camera) { super(context); //get camera previewcamera = camera; if(previe

java - File Not found exception in the master of a COMPSs application -

i running application implemented compss , getting following error in application standard output. ... [(2016-07-27 11:47:34,255) api] - no more tasks app 1 [errmgr] - warning: error master local copying file /home/compss/tmp/localhost/f5e5af5d-c2e4-4fa2-be7f-eca342207ec3/localhost/d866v2_1469612848882.it master workspace_java/guidance_0.9.8/tests/test_1/outputs/associations/phenoa/eurvsafr_for_1kg/chr_21/chr_21_phenoa_1kg_reduce_file_15.txt.gz replacing stack trace: java.nio.file.nosuchfileexception: workspace_java/guidance_0.9.8/tests/test_1/outputs/associations/phenoa/eurvsafr_for_1kg/chr_21/chr_21_phenoa_1kg_reduce_file_15.txt.gz @ sun.nio.fs.unixexception.translatetoioexception(unixexception.java:86) @ sun.nio.fs.unixexception.rethrowasioexception(unixexception.java:102) @ sun.nio.fs.unixexception.rethrowasioexception(unixexception.java:107)

java - Get all work hours from Jira -

i work hours jira. tried code beginning: import com.atlassian.jira.rest.client.jirarestclient; import com.atlassian.jira.rest.client.nullprogressmonitor; import com.atlassian.jira.rest.client.domain.basicproject; import com.atlassian.jira.rest.client.internal.jersey.jerseyjirarestclientfactory; import java.net.uri; public class jiraimpl { private static final string jira_url = "https://jira.atlassian.com"; private static final string jira_admin_username = "test"; private static final string jira_admin_password = "test"; public static void main(string[] args) throws exception { jirarestclient jira; jerseyjirarestclientfactory clientfactory = new jerseyjirarestclientfactory(); jira = clientfactory.createwithbasichttpauthentication(new uri(jira_url), jira_admin_username, jira_admin_password); system.out.println("connection established >> " + jira_url); iterable<

javascript - Reload Custom view type on click each time-Odoo8 -

i have created new view type form view , when create new thing form view , switch custom view see no update till refresh whole site. want know how reload custom view able retrieve data each time click on custom view. i have created view on java script , work except reloading data each time click view. i found code , have called function in views.js, inherit core web module var zoser_book = new openerp.model('zoser.book'); zoser_book.call('reload_controller'[view_type]).then(function(reload_ok){ console.log(reload_ok); }); then in python did this: def reload_controller(self, cr, uid, view_type, context = none): model_obj = self.pool.get('ir.model.data') print model_obj data_id = model_obj._get_id(cr, uid, 'zoser_book', 'zoser_book_views') print data_id view_id = model_obj.browse(cr, uid, data_id).res_id print view_id return { 'type': 'ir.actions.act_window', 'name': _('string'), 're

JXL read Hyperlink cell from Excel using Java -

Image
i trying read hyperlink cell excel spreadsheet i'm unable so. when go spreadsheet , remove hyperlink reads fine. did come across solution below in question ( how hyperlink address cell in excel using java? ) gethyperlink method works sheet , not cell confusing me. workbook wb = workbookfactory.create(new file("test.xls")); sheet s = wb.getsheetat(0); row r2 = s.getrow(1); // rows in poi 0 based cell cb2 = r2.getcell(1); // cells 0 based hyperlink h = cb2.gethyperlink(); if (h == null) { system.err.println("cell b2 didn't have hyperlink!"); } else { system.out.println("b2 : " + h.getlabel() + " -> " + h.getaddress()); } this code now import jxl.cell; import jxl.sheet; import jxl.workbook; import jxl.read.biff.biffexception; public string[] readusernamefromexcel() { file src = new file("c:/filepath.xls"); string ex[] = new string[10]; try { workbook wb = workbook.getworkbo

Nginx uswgi django subpath without uwsgi_modifier1 30; -

i've deploy django app running under subpath. this uswgi.ini file: [uwsgi] socket = :3031 http= :9000 chdir = . wsgi-file = docker.wsgi processes = 4 threads = 2 stats = :9191 enable-threads = true and nginx conf file server { location /my/subpath { include uwsgi_params; uwsgi_pass django:3031; } } now configuration django fails match urls since expect accepting request @ / , not @ /my/subpath if modify nginx conf this: server { location /my/subpath { include uwsgi_params; uwsgi_pass django:3031; uwsgi_param script_name /my/subpath; uwsgi_modifier1 30; } } it works, but note: ancient uwsgi versions used support called “uwsgi_modifier1 30” approach. not it. ugly hack ( source ) i can't head around on how configure nginx make working. from documentation of uwsgi there's possibility use mount point, can't figure out how should change uwsgi.ini file make working. honestly,

vba - Access Dictionary Data Type from Word -

i need access dictionary data type microsoft word. added reference scripting library, word has it's own dictionary data type can't turn off or put it's priority lower. confuses desired dictionary, decided use trick: sub routine() dim t t = createobject("scripting.dictionary") ' processing... end sub it works, think knowledge power, , don't late binding, please tell me how access dictionary data type word. using full name of class scripting.dictionary should resolve ambiguity of dictionary class consider. sub routine() dim d scripting.dictionary set d = new scripting.dictionary debug.print typename(d) end sub in way same doing while using createobject .

VB.NET - QueueUserWorkItem Completion -

i have array sources() containing few web page links, go through grabproxies() function. for each source in sources threadpool.queueuserworkitem(new waitcallback(addressof grabproxies), source) next i use simple variable incrementing method check if sources finished or not. issue isn't efficient, half of time doesn't detect (probably because 2 threads finish @ exact same time or something?) dim sources_counttemp integer private function grabproxies(source string) (...) if sources_counttemp = sources.count console.writeline("finished!") end if either way, it's not efficient way work. how can manage signal , complete small amount of code when finished? edit: variable method un-efficient ran 8 runs of of long function (20-30 seconds before finishes) , 4/8 times worked. (using 15 threads) edit 2: seems work more of time once used new random() on source array. means seems when time out issues etc happen makes not work much. is there way m

c# - How to prevent ExternalException which occurs on graphics object -

i'm working on project control updates , new image drawn on panel after every 10 seconds. following code clears panel first. draws border it. private void drawrectangle(color color) { using (var graphics = creategraphics()) using (var pen = new pen(color)) { graphics.clear(color.black); //external exception thrown here. graphics.drawrectangle(pen, 0, 0, size.width - 1, size.height - 1); } } normally works fine if lock windows(press win + l) after 10 seconds when graphics.clear(color.black) statement executed, application crashes. according msdn page : the clear method clears state of graphics object , should not called when graphics object cannot updated. example, if clear method called on secure desktop in terminal server session, externalexception may occur, leaving graphics object in inconsistent state. what should prevent crash? should check if windows locked or not? , case crash occur? update : same problem occurs when screen saver act

javascript - Angularjs check if two arrays have different elements -

i have array $scope.blinkingboxes=[1,3,2] i have array called $scope.clickedboxes , push few values in it. now if(angular.equals($scope.blinkingboxes, $scope.clickedboxes)){dosomething()} checks if both arrays same (i.e. same elements in same order) however want check if second array not contain element first array , perform action. how can achieve this? there no such built-in function you can use angular.foreach(array1, function(value, key) { angular.foreach(array2, function(value_1, key_1) { if (value === value_1) { // condition or action } }); });

concurrency - Chat bots: ensuring serial processing of messages on a per-conversation basis in clustered environment -

in context of writing messenger chat bot in cloud environment, i'm facing concurrency issues. specifically, i ensure incoming messages same conversation processed 1 after other. as constraint, i'm processing messages workers in cloud environment (i.e worker pool of variable size , worker instances potentially short-lived , may crash). also, low latency important. so abstracting little, requirements are: i have stream of incoming messages each of these messages has 'topic key' (the conversation id) the set of topics not known ahead-of-time , virtually infinite i want ensure messages of same topic processed serially on cluster of potentially ephemeral workers if possible, reliability guarantees e.g making sure each message processed once. my questions are: is there name concurrency scenario?. are there technologies (message brokers, coordination services, etc.) implement out of box? if not, algorithms can use implement on top of lower-level co

java - Jsch : End of IO Stream Read -

Image
i'm using jsch create ssh connection between app , service, service has authentication must passed along connection tunnel, used ssh following way: session session = jsch.getsession("user_name", "service_url.com", 1443); properties config = new properties(); config.put("kex", "diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1"); //config.put("kex", "diffie-hellman-group-exchange-sha256"); //tried individually //config.put("kex", "diffie-hellman-group1-sha1"); //tried individually config.put("stricthostkeychecking", "no"); session.setconfig(config); session.setpassword("abc123"); try{ session.connect(5000); // exception raises here }catch(jschexception hs){ hs.printstacktrace(); // exception caught here } but when reaching session.connect() i'm getting following exception before waiting 5000 ms mentioned in co

cant seem to update my values in ruby -

so have form color palette update live, i've been stuck problem days. this controller update def update @project = project.find_by(id: params[:id]) binding.pry @palette = @project.palette unless @project render json: {error: "project not found"}, status: 404 return end @project.update(project_params) @project.update_palette(palette_params) render json: project end one project has 1 palette private def project_params params.require(:project).permit(:name, :option, :id, :background_dark_color, :background_light_color, :dark_color1, :dark_color2, :light_color1, :light_color2) end def palette_params params.require(:palette).permit(:background_dark_color, :background_light_color, :dark_color1, :dark_color2, :light_color1, :light_color2) #=> [ :id, :name, :_destroy ]) end the error throwing me enter image description here added form <%= palette.label 'background_dark_color' %>:

gnu make - Makefile dependencies variable -

i have simple makefile. when i'm not using variable in dependencies list works fine. otherwise gives fallowing error: make: *** no rule make target 'ext/configxml.o', needed 'libledrgb-jni.so'. stop. furthermore when make print-led-cfg-src led-cfg-src = ../led-cfg/src so value set properly, altough if explicitly add rule file: ext/configxml.o: $(led-cfg-src)/%.cc @echo 'building file: $<' @${cxx} $(cxxflags) -c -o "$@" "$<" it looks problem led-cfg-src source file: make ext/configxml.o make: *** no rule make target '/configxml.cc', needed 'ext/configxml.o'. stop. but file exists: make list ls -la ../led-cfg/src total 340 drwxrwxr-x 2 gigi gigi 4096 lip 27 13:10 . drwxrwxr-x 12 gigi gigi 4096 lip 28 10:08 .. -rw-rw-r-- 1 gigi gigi 11918 lip 28 09:54 configxml.cc -rw-rw-r-- 1 gigi gigi 2891 lip 27 13:17 configxml.h here's source makefile: extobjs = ext/configxml.o ext/

c# - Redirecting CMD window output into RichTextWindow -

i writing c# winform app run , control several arduinos. arduinos programmed on fly can use same duino many tasks depending on need test. programming on fly easy see code below can see have run separate program called avrdude , send parameters. still ok ..... avrdude dos opens cmd window , puts output that. problem want output apps richtextwindow. searching around find several examples , try understand them seem have missed vital part why ask help. i trying redirect output avrdude empty string. have missed allow me capture output avrdude int richtextwindow. my code below: private void program_duino() { var choice = cbobx_device.selectedindex; string partno = ""; string programmer = ""; string baudrate = ""; switch (choice) { case 0: partno = "atmega2560"; programmer = "wiring"; baudrate = "115200";

Run tests inside Docker container with Jenkins -

we want give try setup ci/cd jenkins our project. project has elasticsearch , postgresql runtime dependencies , webdriver acceptance testing. in dev environment, set within 1 docker-compose.yml file , have acceptance.sh script run acceptance tests. after digging documentation found it's potentially possible build ci following steps: dockerize project pull project git repo somehow pull docker-compose.yml , project dockerfile - either: put in project repo put in separate repo (this how it's done now) put somewhere on server , jut copy over execute docker-compose up project's dockerfile have onbuilt section run tests. unit tests run through mix tests , acceptance through scripts/acceptance.sh . it'll cool run them in parallel. shutdown docker-compose , clean containers because first experience jenkins series of questions arise: is viable strategy? how connect tests output jenkins? how run , shut down docker-compose? do need/want write pip

c# - Running async methods in parallel -

i've got async method, getexpensivething() , performs expensive i/o work. how using it: // serial execution public async task<list<thing>> getthings() { var first = await getexpensivething(); var second = await getexpensivething(); return new list<thing>() { first, second }; } but since it's expensive method, want execute these calls in in parallel. have thought moving awaits have solved this: // serial execution public async task<list<thing>> getthings() { var first = getexpensivething(); var second = getexpensivething(); return new list<thing>() { await first, await second }; } that didn't work, wrapped them in tasks , works: // parallel execution public async task<list<thing>> getthings() { var first = task.run(() => { return getexpensivething(); }); var second = task.run(() => { return getexpensivething(); }); return new list<thing

Angular JS directive - location of CSS file relative to HTML -

my directive uses html file. html file uses css stylesheet. need distribute directive js, html , css files, css location definition needs relative html. note: this how solved location of html, have pending solve location of css file. i put css file in same folder html file, , defined in html: <link rel="stylesheet" href='somefile.css'> however points domain root, not html file location. any ideas how achieve this? i think there 2 ways fix issue don't know directives located: solution 1 - ancient html way if length of css small, can directly include in template html itself, through style tag. <style type="text/css"> add style rules here </style> solution 2 - angular way(most recommended) use nghref directive. in directive.js code, can put path of directive.html scope/rootscope variable , can access directive.html in directive.js link: function (scope, ielement, iattrs) { scope.htmlpath =

node.js - fs.readFileSync doesn't do anything in case the file doesn't exist -

i trying read content of file code: var content = fs.readfilesync(filename); it works fine when file such filename exists. however, doesn't if file doesn't exist. hangs there forever. one solution check if file exists before try read it, hoping part of fs module return undefined or error conveniently handle. this entire code, can see issues? can't. for (var i=0; i<configfiles.length;i++){ waterfallmain(configfiles[i]); } //var importdefinition = config.importdefinition; function waterfallmain(configfile){ async.waterfall([ function(callback){ sftphandler.downloadfile(credentials.host, credentials.username, credentials.password, credentials.path+configfile.importfilename, callback); console.log("downloading done. changing file encoding , reading data."); readfilesync_encoding(configfile.importfilename, "iso-8859-1", callback); }, function(fil

c# - Another one about multiple matching actions in ASP.NET Web Api 2 -

i've read these questions: multiple actions found match request: webapi web api routing - multiple actions found match request multiple actions found match request web api? and i've updated routeconfig follows: routes.maproute( name: "receipt", url: "api/{controller}/{action}/{id}", defaults: new { controller = "receipt", action = "post", source = urlparameter.optional } ); creating new route map hasn't helped fix problem in slightest here's relevant functions in controller: public httpresponsemessage post ([frombody]createreceiptviewmodel source) { try { // stuff happens here } catch (exception ex) { // went wrong, save exception data database // recorderror(ex, "post receipt", "receiptcontroller/post"); } } //public void recorderror(exception ex, string action = "", string origin = "pocketplooto api") //

c++ - Using SFINAE to disable template class member function -

is possible use sfinae , std::enable_if disable single member function of template class? i have code similar this: #include <type_traits> #include <iostream> #include <cassert> #include <string> class base { public: virtual int f() { return 0; } }; template<typename t> class derived : public base { private: t getvalue_() { return t(); } public: int f() override { assert((std::is_same<t, int>::value)); t val = getvalue_(); //return val; --> not possible if t not convertible int return *reinterpret_cast<int*>(&val); } }; template<typename t> class morederived : public derived<t> { public: int f() override { return 2; } }; int main() { derived<int> i; morederived<std::string> f; std::cout << f.f() << " " << i.f() << std::endl; } ideally, derived<t>::f() should disabled if t != int . because f

Mysql Stored procedure that accepts a date range from user and displays a list of open bugs -

i newbie mysql writing stored procedures , functions. faced lots of errors in writing code accepts user input , date time manipulation. have created table called 'bugs' below... create table 'bugs' ( id int(11) not null auto_increment primary key, title varchar(20) not null, severity int not null check(severity>0 && sevirity<5), opendate datetime not null default current_timestamp, closedate datetime default null )engine=myisam default charset=latin1; i want write below 2 things. block of code accepts user input(here title, severity, opendate, closedate) , insert 1 row. stored procedure accepts date range user , displays list of open bugs(for opendate between given date range , closedate beyond date range) can me code? you can write procedure : 1 . @ first call procedure php file(if have it) : $report1=$db->query("call procedure_name('".$opendate."','".$closedate."

hlsl - Get the MSAA sample number inside pixelshader for OIT -

Image
i try implement order independent transparency on own. finished without 1 thing... can see in picture below, oit msaa kind of wrong. think because of samples. because @ each triangle edge there 4 samples (and @ triangle edges). alphablending , oit , without msaa here shader code in hlsl: create lists rwbyteaddressbuffer trwfragmentlist : register(u1); void main(ps_input input) { float2 position = (input.pos.xy - float2(0.5,0.5)) / input.pos.w; uint nxposition = position.x; uint nyposition = position.y; uint vscreenaddress = nscreenwidth * nyposition + nxposition; float3 normal = normalize((float3)input.normal); float3 position = (float3)input.pos; float4 color = createphong(input); //float4 color = (float4)input.diffuse; // counter value , increment uint nnewfragmentaddress = 0; trwfragmentlist.interlockedadd(0, 44, nnewfragmentaddress); if (nnewfragmentaddress < 1000*1000*500) { uint pixel = 4 + nscree