Posts

Showing posts from January, 2010

ruby - ActiveRecord updated_at error on rails 5 -

when manually set updated_at field of model in controller follows: el = model.find(id) el.update(updated_at: time.now, updated_by: "some_name") the minutes of created_at field change match of updated_at . this not happen when write above lines of code in console. any ideas ? edit: project background: i using rails 5, , mysql2 gem. the problem not arise when repeat commands in rails console. to preform action, make ajax call server client, , function in controller performs action. update: the same thing happens when using: el.update_attribute(:updated_by, "some_name") which should automatically handle updated_at field. command line output: img i not see created_at field modified anywhere. also, if relevant on windows 7, 64 bit. update 2: i pushed project heroku server , bug not persist. can conclude windows bug.

Angular reactive form - custom validator -

i have requirement input fields need masked. example, desired amount should displayed $44,444. can achieve input masking using text-mask ( https://github.com/text-mask/text-mask ). problem encountering masking breaks reactive form validators. component: import {withinloanrangedirective} './within-loan-range.directive' this.applicationform = this.fb.group({ desiredamount: ['', [validators.required, withinloanrangedirective] ] }) template: <input [textmask]="{mask: numbermask}" mdinput formcontrolname="desiredloanamount type="tel" > <!--type tel pop numpad--> <div> {{ applicationform.controls['desiredloanamount'].haserror('withinloanamountrange')}}</div> the validators checking min , max against masked input ($44,444) instead of (44444). there way format value before setting in model? you need create custom validator (directive) , strip out non-numeric characte...

java - Spring Kafka - All topics into the same consumer -

i'm trying consume multiple topics kafka using same @kafkalistener implementation, wanted have 1 consumer each topic (each 1 has 1 partition). in order achieve created @kafkalistener with topicpattern="topic1|topic2|topic3" , concurrentkafkalistenercontainerfactory concurrency 3 , groupid consumer_group . problem topics assigned same consumer , other 2 consumers become idle following log shows: 21:49:13.140 [org.springframework.kafka.kafkalistenerendpointcontainer#0-1-c-1] info o.a.k.c.c.i.consumercoordinator - setting newly assigned partitions [] group consumer_group 21:49:13.140 [org.springframework.kafka.kafkalistenerendpointcontainer#0-2-c-1] info o.a.k.c.c.i.consumercoordinator - setting newly assigned partitions [] group consumer_group 21:49:13.141 [org.springframework.kafka.kafkalistenerendpointcontainer#0-0-c-1] info o.a.k.c.c.i.consumercoordinator - setting newly assigned partitions [topic1, topic2, topic3] group consumer_group how can hint spring kaf...

haskell - “Illegal type synonym family application in instance” with functional dependency -

i have multi-parameter typeclass functional dependency: class multi b | -> b i have simple, non-injective type synonym family: type family fam i want write instance of multi uses fam in second parameter, this: instance multi (maybe a) (fam a) however, instance not accepted. ghc complains following error message: error: • illegal type synonym family application in instance: fam • in instance declaration ‘multi (maybe a) (fam a)’ fortunately, there workaround. can perform usual trick moving type out of instance head , equality constraint: instance (b ~ fam a) => multi (maybe a) b this instance accepted! however, got thinking, , started wonder why transformation not applied all instances of multi . after all, doesn’t functional dependency imply there can 1 b per a , anyway? in situation, seems there no reason ghc should reject first instance. i found ghc trac ticket #3485 , describes similar situation, typeclass did not involve functional dependency...

php - 502 Bad Gateway Error, when attempting to upload files to Wordpress -

i having difficult time figuring out why cannot upload files wordpress uploads folder. have tried scour web no avail of has fixed this. keep getting 502 bad gateway error once submit button pressed. commented area storing files database. need file moved @ point. have created quick , dirty little php script uses methods. if stands out please let me know. <?php /* template name: testfileupload */ /** * created phpstorm. * user: ccombs * date: 7/27/2017 * time: 1:31 pm */ require_once(abspath . "wp-admin" . '/includes/image.php'); require_once(abspath . "wp-admin" . '/includes/file.php'); require_once(abspath . "wp-admin" . '/includes/media.php'); $file = $_files['uploaded_file']; $fileoverride = array('test_form' => false); /*//file upload resume , error checking if($_files['uploaded_file']['size'] != 0) { $externaldb->insert('emp_resume', array( 're...

javascript - Code folding in bookdown -

the code folding option in rmarkdown html documents awesome. option makes programmatic methodology transparent interested, without forcing audience scroll through miles of code. tight placement of code prose , interactive graphical output makes whole project more accessible wider audience, , furthermore reduces need additional documentation. for larger project, i'm using bookdown, , works great. problem there no code-folding option. code folding not enabled in bookdown. (see enable code folding in bookdown ) i know don't need option make happen. need paste right code in right place or places. code , where? a viable alternative put code chunk below chunk's outputs in page. or, finally, put them appendix. html not reproducible rbookdown. global hide/show button entire page to use @yihui's hint button fold code in html output, need paste following code in external file (i named header.html here): edit: modified function toggle_r button shows hide...

javascript - JqueryUI visual to scale Div from a specific DOM location -

i have code opens/shows div using fade/ease. want visually show hidden div origination link clicked , on closing should close/collapse link. link small icon. code example scale in jqueryui example follows var options = {}; // effects have required parameters if ( selectedeffect === "scale" ) { options = { percent: 50 }; } else if ( selectedeffect === "size" ) { options = { to: { width: 280, height: 185 } }; } // run effect $( "#effect" ).show( selectedeffect, options, 500, callback ); }; i seen done not want re-invent wheel if 1 knows solution. put time no success. please help i tried number of ways. not merge out visually small icon on top right corner leave alone getting fade out icon location

performance - copy speeds drop a lot between freenas and windows vm's in ESXI -

i'm having strange problem freenas server. so, i'm using freenas server, installed vm in esxi server. know not best way it, it's way can @ moment. also, followed instructions freenas guys, , works, try , solve setup. freenas server gets @ moment 16 gig ecc ram, has 2 cores xeon 5520, , passthrough pci card 6 * 2 tb drives. installed on usb stick. freenas server has nfs share, that's mounted dataset in esxi, used installing other vm's. @ moment, there's 1 other vm, windows 10 vm, works well. only, there's 1 thing noticed. i've got other shares on freenas, mounted in windows network drives. because both these network drives windows in fact running on same disks, expecting awesome copy speeds between these two. now, when try this(copy file network drive windows) in beginning, reaches speeds on 200 mbps, after 5 seconds, drops 5 mbps. noticed disk in task manager goes 100%, , networking spiking lot. tried other kind of virtual nic port, , chang...

sas - Sum consecutive observations by some variable -

i'm learning use sas, bear me bit. have following sample patient data on prescription usage , i'd try combine observations form more of patient story, keep timeline intact: data have; input dose $2. id $4. supply date $8.; datalines; "5" 1234 30 01012015 "10" 1234 30 02012015 "10" 1234 30 03012015 "5" 1234 30 04012015 "2" 1234 30 05012015 "5" 4321 30 07012016 "2" 9876 30 05012016 "2" 9876 30 06012016 "10" 9876 30 07012016 ; run; where dose dosage in mg, id patient id, supply number of days' supply of medication, , date date of refill. i'd consolidate of observations when @ patient 1234 can see taking 5mg 30 days, 10mg 60 days, 5 mg again 30 days, etc. of summation , group commands i've learned combine observations 1 , 4 together, patient story dosage increased , decreased, , i'd keep intact don't know how. so this: data want; input dose $2. id...

spring mvc - How to map List<Item> in POST method RequestMapping -

spring boot 1.5.4 need take list<orderto> in post method. controler: @postmapping("/orderlist") public string confirmorder( , @requestparam(name = "id", required = false) list<integer> idl , @requestparam(name = "selected", required = false) list<integer> selectedl , @requestparam(name = "typename", required = false) list<string> typenamel // ...another lists // ,@modelattribute list<orderto> notwork ) { // collect lists the best option found lists fields of class. maybe i'm missing something. view: <form action="orderlist" method="post" id="catalogform"> <table class="table table-hover table-bordered table-striped table-condensed"> <tr> <th><#--...--></th> </tr> <...

typescript - Bind Input Values in Modal with Angular not working with ngModel -

Image
we trying build profile page option open modal window edit same user information. using angular 4 / typescript / firebase / angularfire2 . seeing user's profile data on main screen not showing "value" input fields when modal window launched (see picture). the displayed values (blacked out) show not same data when trying edit. firebase node content example (node: /users) note: copied internet browser copy of structure of record /users node. kgammm5pyvmemxyrxcjah3gooyb4 address: "1234 fake street" businesslinkcode: "" city: "faketown" email: "john@smith.com" modifieddate: "2017-07-25" modifiedtime: "1:20:33 pm" name: "john smith" phone: "1234567890" photourl: "https://firebasestorage.googleapis.com/v0/b/tow..." position: "assistant" state_: "north fake state" zipcode: "12345" component ts (abbreviated): import { component, ...

jquery - Get a single value from JSON object -

Image
so have object or array (not sure how call it) returned jquert json. when try print "console.log(pdata) - following: is possible somehow print value of address. want assign variable , use somewhere else. thanks. simply pdata[0][0].address or pdata[0][0]['address']

java - JRE not using classpath specified by manifest file of runnable jar -

first post, sorry poor formatting. have java program developed in eclipse. exported program jar (myjar.jar), , put of external jars program depends on folder called lib lives in same location myjar.jar. in order set classpath have manifest file following format: main-class: exe.mymain class-path: lib/jar_1.jar lib/jar_2.jar ... lib/jar_n.jar manifest-version: 1.0 however, when attempt run program using "java -jar myjar.jar" classes jars live in lib not being loaded (i'm getting classnotfoundexception) . used following code in program print classpath: classloader cl = classloader.getsystemclassloader(); url[] urls = ((urlclassloader)cl).geturls(); for(url url:urls){ system.out.println(url.getfile()); } and when run code classpath "myjar.jar". i have 2 questions: 1.) above code give me classpath jre @ run time, or being given address of main class? 2.) given above code indeed give me classpath jre @ run time, doing wrong? please feel free...

ios - CATextLayer in SCNBox shows in portrait mode -

i trying write text onto scnbox node. see text in box text orientation portrait. how make landscape? screenshot calayer *layer = [calayer new]; [layer setframe:cgrectmake(0, 0, 100, 100)]; [layer setbackgroundcolor:[uicolor redcolor].cgcolor]; catextlayer *textlayer = [catextlayer new]; [textlayer setframe:[layer bounds]]; [textlayer setfontsize:24]; [textlayer setstring:@"test"]; [textlayer setalignmentmode:kcaalignmentleft]; [textlayer setforegroundcolor:[uicolor blackcolor].cgcolor]; [textlayer display]; [layer addsublayer:textlayer]; scnbox *box = [scnbox boxwithwidth:1 height:2 length:0.005 chamferradius:0.0]; [[[box firstmaterial] diffuse] setcontents:layer]; // [[[box firstmaterial] diffuse] setcontents:[uicolor redcolor]]; [[box firstmaterial] setlightingmodelname:scnlightingmodelconstant]; [[box firstmaterial] setdoublesided:yes]; scnnode *node = [scnnode nodewithgeometry:box];

cloudera - Load a text file into Apache Kudu table? -

how load text file apache kudu table? does source file need in hdfs space first? if doesn't share same hdfs space other hadoop ecosystem programs (ie/ hive, impala), there apache kudu equivalent of: hdfs dfs -put /path/to/file before try load file?

java - Control Task with another Task in JavaFX -

here's i'm trying do: task 1 runs , @ same time executes task 2, task 2 has method runs every 15 seconds (for use timer class), method stops task 1 , after finishing resumes task 1. problem when try call task 1 in task 2 , execute .isrunning() or .wait() following error appears "task must used fx application thread". dont understand if error appearing because i'm using timer class running task 2 or because cant reference task withint task. here code task 2: public void unfollowusers(timer t, task<void> likestask, webdriver driver) throws interruptedexception { if (!userstounfollow.isempty() && likestask.isrunning()) { likestask.wait(); //some code likestask.notify(); } else if (!userstounfollow.isempty()) { //some code } else { t.cancel(); } } public task<void> unfollowstask(task<void> likestask, webdriver driver) throws interruptede...

php - Displaying two parameters from database that need to be paired together in a list under the common name -

i have ban list database system holds rule type( category ) , specific rule it. i have multiple rules same rule type name, cannot figure out how make website display both sets of rules category, underneath name header of rule type. example: have 2 categories: ban rules. conduct rules. but ban rules has 2 rows in database , cannot figure out how display them both in list format underneath title "ban rules". <?php $sql = "select * minecraft"; $result = mysql_query($sql); $row = mysql_fetch_array($result); if(mysql_num_rows($result) > 0 ) { echo "<div class='row'>"; echo "<div class='col-lg-12'>"; echo "<ul style='background-color:transparent;' class='list-group-item'>"; echo "rules:"; echo "</ul>"; } while($row = mysql_fetch_array($result)) { echo "<div class='row'>"; echo "<div...

dynamic Objects with variables in c# -

is possible build dynamic objects having property name set value of variable? for instance seems standard... dynamic elem = new object(); elem.name = "myname"; but how implemented?... string fn = "firstname"; string ln = "lastname"; dynamic elem = new object(); elem.fn = "john"; elem.ln = "doe"; where able call properties like... string fn = elem.firstname; the expandoobject implements idictionary<string, object> , meaning can add properties using string key. dynamic person = new expandoobject(); person.firstname = "alex"; var ln = "lastname"; (person idictionary<string, object>)[ln] = "keysmith";

Use authentication token in follow-up requests in Postman -

Image
my app api requires authentication via authentication token. in short, send request /authentication endpoint , responds json object containing token, like: {"token": "xxxxxxxxxxxxxxxxxxxxxx"} every other api endpoint in our application requires authentication header containing token. now, in postman it's possible authentication request, copy token, open next endpoint , paste authentication header in manually. becomes tedious , time-consuming when testing lots of endpoints. is there way have postman save , automatically add authentication token 1 request in follow-up requests? even better, postman automatically send /authentication request prior of other requests? postman allows wide variety of options when crafting api requests. in case, can create global variable token when receive by: var jsondata = json.parse(responsebody); postman.setglobalvariable('token', jsondata.token); this go in tests tab, in order execute scri...

python - How do I install this PIP package from Github? -

i trying access crunchbase data through rest api using python. there package available on github gives me following documentation. how "package" ? the crunchbase api provides restful interface data found on crunchbase. response in json format. register follow steps below start using crunchbase api: sign login & api key browse documentation. setup pip install git+git://github.com/anglinb/python-crunchbase** up & running import crunchbase intialize crunchbase object api key. git+git://github.com/anglinb/python-crunchbase pip install git+https://github.com/anglinb/python-crunchbase.git you missing https update: make sure have git installed on system.

Can I use a "displaced" array base in Go? -

i have problem solved using "displaced array base". is, in c set pointer array-base + offset, , access array using ptr[x] array[offset + x] without addition. is such thing possible in go? i've read, can't find support (including statement there no pointer arithmetic in go), slices , other things i'm unfamiliar far, i'd more experienced opinion. edit consider 3 possible scenarios: i create array, , want use "middle index" of array base: sign_values := { -1, -1, -1, -1, -1, 0, 1, 1, 1, 1, 1 } sign := sign + 5 = f(x) // returns [-5 .. 5] sign_i = sign[i] i create array, , want use "negative offset" of array base: to_lower := { 'a', 'b', 'c', 'd', 'e', ..., 'z' } tolower := to_lower - 'a' func tolower(ch byte) byte { if isupper(ch) { return tolower[ch] } return ch } i create array , want use "excessive positive" index base. same others,...

Select rows with highest value in one column in SQL -

in mysql, trying select 1 row each "foreign_id". must row highest value in column "time" (which of type datetime). can me how sql select statement must like? thank you! great! trying hours find solution :( this table: primary_id | foreign_id | name | time ---------------------------------------------------- 1 | 3 | | 2017-05-18 01:02:03 2 | 3 | b | 2017-05-19 01:02:03 3 | 3 | c | 2017-05-20 01:02:03 4 | 5 | d | 2017-07-18 01:02:03 5 | 5 | e | 2017-07-20 01:02:03 6 | 5 | f | 2017-07-18 01:02:03 and result should like: primary_id | foreign_id | name | time ---------------------------------------------------- 3 | 3 | c | 2017-05-20 01:02:03 5 | 5 | e | 2017-07-20 01:02:03 i tried order intermediate result time (descending) , select first row using limit 1. cannot 1 row each foreign_id. an...

debugging - 'Cannot output file filename.exe Permission denied' error in C++ Code::Blocks -

i got error while ago when compiling project, , i've gotten every few days since then, in different projects, , solution worked restarting. people said open task manager , close file, couldn't find file. people said delete main.o in obj/debug or obj/release folder, reappeared when compile. else should try? it's inconveniencing having restart every time pops up. check put project maybe in file have no access run code::blocks admin make sure program not still running go task manager , kill it

Python loop for getting list of elements on few pages -

Image
in application have table users,but table can have more 1 page users. want list users in pages selenium webdriver python. need algorithm gonna count users in first page click on second page count there , until pages done, , return entire list. have idea don't know how realize that, below: def users(driver): list_users = [] list_users in range(n): #selector click on second page num = num + 1 #getting users 1 page driver.find_elements_by_css_selector(".even .odd") #click on second page until pages exist driver.find_elements_by_link_text("%s" % num) until nosuchelementexception return list_users i know it's not close working algorithm tried explain want assuming need total number of people , have logged in... people = driver.find_element_by_xpath('//* [@id="frmlist_ohrmlistcomponent"]/div[1]/ul/li[1]').text print people yields "1-50 of 53...

php - Symfony3 – Form submission with clearMissing – nullified properties always – how to fix this? -

i'm using "symfony ~3.3". if send in request bar property (without zyx because don't need change it), error: type error: argument 1 passed appbundle\entity\foo::setzyx() must of type string, null given, called in /full/path/to/project/vendor/symfony/symfony/src/symfony/component/propertyaccess/propertyaccessor.php on line 636 my question simple: why clearmissing parameter ignored , how achive editing selected properties? some code here: controller: class foocontroller extends controller { /** * @rest\patch("/foo/{id}", requirements={"id": "\d+"}) * * @rest\requestparam(name="bar", nullable=true) * @rest\requestparam(name="zyx", nullable=true) * * @param int $id * @param paramfetcher $pf * * @return response * * @throws \symfony\component\httpkernel\exception\notfoundhttpexception * @throws \symfony\component\httpkernel\exc...

php - ServiceNotFoundException' 'Unable to resolve service "Router" to a factory -

i'm using zend framework 3 doctrine 2 , giving me error dnt know why fatal error: uncaught exception 'zend\servicemanager\exception\servicenotfoundexception' message 'unable resolve service "router" factory; provided during configuration?' in c:\xampp\htdocs\zendf\vendor\zendframework\zend-servicemanager\src\servicemanager.php:681 stack trace: #0 c:\xampp\htdocs\zendf\vendor\zendframework\zend-servicemanager\src\servicemanager.php(757): zend\servicemanager\servicemanager->getfactory('router') #1 c:\xampp\htdocs\zendf\vendor\zendframework\zend-servicemanager\src\servicemanager.php(200): zend\servicemanager\servicemanager->docreate('router') #2 c:\xampp\htdocs\zendf\vendor\zendframework\zend-mvc\src\application.php(158): zend\servicemanager\servicemanager->get('router') #3 c:\xampp\htdocs\zendf\vendor\zendframework\zend-mvc\src\application.php(273): zend\mvc\application->bootstrap(array) ...

PHP Switch statements Error -

i made site , added pm thing , when go pm.php gives me error: fatal error: switch statements may contain 1 default clause in /home/vol10_3/hidden.com/hidden/htdocs/includes/classes/pm.class.php on line 673 code: function get_new_messages($uid=null,$type='pm') { if(!$uid) $uid = userid(); global $db; switch($type) { case 'pm': default: { $count = $db->count(tbl($this->tbl),"message_id"," message_to '%#$uid#%' , message_box='in' , message_type='pm' , message_status='unread'"); } break; case 'notification': default: { $count = $db->count(tbl($this->tbl),"message_id"," message_to '%#$uid#%' , message_box='in' , message_type='notification' , message_status='unread...

java - JavaFX bind a controller variable to a component property -

Image
say have controller with @fxml private observablelist<string> mystrings = fxcollections.observablearraylist(); is possible write fxml wire listview mystrings items? my first try was: <listview> <items fx:id="mystrings"/> </listview> but complains fx:id not valid in position. tried <listview items="${controller.mystrings}"/> ...but couldn't resolve value. please not post solution: <listview fx:id="mystringslistview"/> // in controller @fxml private listview<string> mystringslistview; @fxml public void initialize() { mystringslistview.setitems(mystrings); } this doing amount of indirection , boilerplate here hurts me. the following works <?xml version="1.0" encoding="utf-8"?> <?import javafx.scene.layout.borderpane?> <?import javafx.scene.control.listview?> <borderpane xmlns:fx="http://javafx.com/fxml/1" fx:controll...

How to Enable CORS for Docker Apache httpd server? -

i need create apache server host files , them ajax. so, i'm using docker deploy server. my docker image httpd:2.4. i deployed server following command : docker run -p 80:80 -dit --name file-server \ -v /sources/docker/apache-server/www/:/usr/local/apache2/htdocs/ httpd:2.4 but when want make request ajax, result: xmlhttprequest cannot load http://server/kml/example.kml . no 'access-control-allow-origin' header present on requested resource. origin 'null' therefore not allowed access. so, want follow next steps how enable cors apache httpd server? (step-by-step process) . not know how add command in httpd.conf of component. , don't have httpd.conf template replace with: v /sources/docker/apache-server/my-httpd.conf:/usr/local/apache2/conf/httpd.conf please me question.

SQL Server : sorting letters with number -

Image
i'm not @ sql - below have tried far searching. can see in picture barangayname not in order. can see there 'z , s, , 1' between letter b , brgy 10 , brgy 11 far each other. select * dbo.barangay order substring(a.barangayname, patindex('%[0-9]%', a.barangayname), len(a.barangayname)) i tried work out you. let's take following sample data: declare @table table(id int,name varchar(100)) insert @table values(134,'brgy 1') insert @table values(256,'brgy 100') insert @table values(687,'sample 1 z1') insert @table values(954,'brgy 11 zn9') insert @table values(887,'brgy 10 zn11') insert @table values(785,'brgy 098 xys') insert @table values(785,'zone 2 wer') the following select statement: select * @table order 2 will result as: but using following code, custom sorting you, ;with cte as( select *, substring(name, 0, charindex(' ', name)) spart, ltrim(rtri...

node.js - I'm confused with the epoll in libuv network I/O -

these days i'm reading source code of node.js, here i'm confused: in libuv's uv__io_poll function, firstly, in while loop pool out every i/o watchers , events interseted about, , run uv__epoll_ctl() register events system's epoll. while (!queue_empty(&loop->watcher_queue)) { q = queue_head(&loop->watcher_queue); queue_remove(q); queue_init(q); w = queue_data(q, uv__io_t, watcher_queue); assert(w->pevents != 0); assert(w->fd >= 0); assert(w->fd < (int) loop->nwatchers); e.events = w->pevents; e.data = w->fd; if (w->events == 0) op = uv__epoll_ctl_add; else op = uv__epoll_ctl_mod; if (uv__epoll_ctl(loop->backend_fd, op, w->fd, &e)) { if (errno != eexist) abort(); if (uv__epoll_ctl(loop->backend_fd, uv__epoll_ctl_mod, w->fd, &e)) abort(); } w->events = w->pevents; } and in infinite loop run uv__...

windows - Powerline renders fine for zsh but not bash in VS Code -

Image
i'm using bash on ubuntu on windows. installed powerline , looks great. powerline on bash on ubuntu on windows. in vs code, not. in vs code, when start zsh, good. powerline on zsh in vs code. can explain , me fix it?

jquery - Is it possible that when click button addclass on another html page -

is possible when click button addclass on html page using jquery ? for example, a.html <button class="btn_click">when click, add 'active' class on b.html</button> b.html <div class="active">active</div> is possible? without server side intermediary wouldn't possible. you'd need send results of button click server update value , either pushed there page or other page poll , ask changes. think of way. in facebook, if you're on 2 different computers , send message someone, message sent shows on other computer also. there servers involved. but send directly? no. suppose might possible if 2 pages or tabs in same browser on same computer , used browser plugin. otherwise, there huge security risks if possible way.

How to finda file that had been copied and the name changed? -

a little background. i'm trying build owncloud server. part of i've installed several dependencies, including nginx. @ end of should able type in ip address , should bring owncloud start page. that's background. when type in address ngixn page. tried make change page in /var/www/html/index.nginx-default.html file , nothing changes. i've poked around , haven't found file same contents. i'm sure there's way pipe or diff way using contents of 1 know find 1 system using. don't know how it. appreciated. thank you.

dom - select2 for dynamically added select not working -

i trying select2 awesome tool work with. facing following issue. uncaught typeerror: $(...).find(...).select2 not function this error occurs after try initialise select2 "select" element added in dom based on click action. while same thing works select present in dom.

html - Show Button in Last Row of the Table only using Javascript -

Image
i have 4-column table last column containing "+" button. function add additional column when clicked. being shown in of rows, want displayed on last row of table. here's code <table class="table table-responsive table-bordered" style="width:100%" id="heightconfig"> <tbody id="heightconfigbody"> @if (model != null) { @foreach (var data in model.reverse()) { <tr> <td style="width:40%"> <label><b>recorded time:</b> <input type="text" id="recorddate" class="recorddate" value="@data.recorddate.tostring("yyyy-mm-dd")" disabled></label> </td> <td style="width:40%"> <label><b>height (cm):</b> <input type="text" id="columntypedata" class="c...

javascript - List view search list filter using jquery -

i have small bugs in search result, here html <input type="text" class="form-control" id="populernamekey"> list item: <ul id="destpopuler"> <li class="country">england</li> <li class="testing"><a href="#">liverpool</a></li> <li class="testing"><a href="#">london</a></li> <li class="country">italy</li> <li class="testing"><a href="#">roma</a></li> <li class="testing"><a href="#">milan</a></li> </ul> and full javascript jsfiddle nb: [bug] if typing "spain" letter letter, result lost. want still exist , still confused fix it. help? thank you in code problem when type liverpol lower case first , text value have proper value, upper case first. should same input value , ...

c++ - How to use only 1 template value for a function in a class which has 2 templates values -

i'm trying implement hashmap in c++. class template <typename k, typename v> class hashmap { public: unsigned int map_size = 100; v* values_arr = new v[map_size]; int hash(std::string); //i want 1 hash function std::string int hash(k); //then used integral types }; now function expect called k (key) string template <typename k, typename v> int hashmap<std::string, v>::hash(std::string value) { //this line error std::cout << "you hashing string"; return 0; } and 1 want used when key in integral template <typename k, typename v> int hashmap<k, v>::hash(k value) { std::cout << "you hashing an integral"; return 0; } i'm trying encode logic declaring function hashmap<std::string, v> think should work i'm not positive. error (i commented line it's on) error c3860 template argument list following class template name must list parameters in order used...

c++ - Do I have to delete/release GetCapturedStdOut when using google test? -

i have following simple test test_f(mytest, outputcomparetest) { capturestderr(); capturestdout(); std::string actualoutput = testing::internal::getcapturedstdout(); std::string matchingsample = "some string compare output"; expect_eq(actualoutput, matchingsample); expect_eq(getcapturedstderr(), ""); } the question here have release/delete captured buffer in order not keep forever , other test can recapture output without problem. i have been looking in googletest docs seems there not predefined function releases captured buffer capturestderr() , capturestdout(). mean lifetime of objects limited lifetime of test? may have missed not indicated in documentation. partially indicated fact can't assign pointer it. std::string* actualoutput = &testing::internal::getcapturedstdout(); ... delete actualoutput; actualoutput = nullptr; because getcapturedstdout seems me non lvalue. want sure don't have delete , if how it.

operators - how to use ruby to assign a default if a value is nil? -

i have following default 5 if there not value json_element['limit'] : json_element['limit'] = 500 limit ||= json_element['limit'].to_i limit ||= 5 this current implementation, seems 1 line long. as amndan says, idea here order things in order of precedence, highest lowest, left right, speaking: def do_thing(limit_override) limit ||= limit_override || input || default end in case you're testing hash property , converting integer, have options: limit ||= json_element['limit'] ? json_element['limit'].to_i : 5 or to_i whatever if it's ever less efficient: limit ||= (json_element['limit'] || 5).to_i

java - Joining multiple IntStream -

this question has answer here: adding 2 java 8 streams, or element stream 7 answers i trying integers, getting on stream, however, being added new stream of integers using later on. to populate new stream of integers, make multiple intstreams , append them new 1 using intstream builder, such: is there better way approach this: intstream rightside = intstream.range(8, this.rows.getslotamount()).map(value -> value + 9); intstream leftside = intstream.range(0, this.rows.getslotamount()).map(value -> value % 9); intstream top = intstream.range(0, 9); intstream bottom = intstream.range(this.rows.getslotamount() - 9, this.rows.getslotamount()); intstream.builder slots = intstream.builder(); rightside.foreach(slots::add); leftside.foreach(slots::add); top.foreach(slots::add); bottom.foreach(slots::add); slots.build().fo...

regex - What is the difference between Python's re.search and re.match? -

what difference between search() , match() functions in python re module ? i've read documentation ( current documentation ), never seem remember it. keep having , re-learn it. i'm hoping answer examples (perhaps) stick in head. or @ least i'll have better place return question , take less time re-learn it. re.match anchored @ beginning of string. has nothing newlines, not same using ^ in pattern. as re.match documentation says: if 0 or more characters @ beginning of string match regular expression pattern, return corresponding matchobject instance. return none if string not match pattern; note different zero-length match. note: if want locate match anywhere in string, use search() instead. re.search searches entire string, the documentation says : scan through string looking location regular expression pattern produces match, , return corresponding matchobject instance. return none if no position i...