Posts

Showing posts from September, 2014

List files with git ls-files from root instead of current working directory -

i'm looking command similar following, lists repository root, rather current working directory: git ls-files --cached --others --exclude-standard if possible i'd rather not use bash/batch, since i'm looking cross-platform solution. if can create alias, git config --global alias.ls-files-root "! git ls-files" then should able do git ls-files-root --cached --others --exclude-standard explanation: aliases starting '!' executed shell commands top-level directory. related: is there way git root directory in 1 command? .

java - Do I need a web-service for this case? Data-synchronization over multiple clients -

Image
i'm new in area , little bit confused current thoughts on web-service implementation application. want synchronize connected clients current data on mysql db. came use web-services coordination purposes, got stuck. the way tried implement is... the web-service running deamon check/listen on crud operations affecting db data. once crud operation has been occured undetakes notify connected clients , each client in turn refreshes jtable current db data , informs user change took place on db. this i'm stuck... the way i'm thinking it's (maybe?) wrong, since conceptually web-services awaiting client requests , send him corresponding response. here, there no client requests. web-service sends response (noification), must multicast since it's unaware of "calling" client -there's no request. therefore, in order client send request must "cron" time web-service if change on db has been occured. web-service responts true or false crud deta

node.js - node-imap module fetch gmail list folders(labels) -

i'm trying fetch gmail folders list (labels actually) . i'm using node js , module : https://github.com/mscdex/node-imap i want fetch folders , sub folders. documentation author left not bright. any idea this? finally after hard working found answer, how folders not google every email system use imap standards after connection imap server folders function. function getfolders(username, callback) { var folders = []; if (connection[username]) { connection[username].once('ready', function() { connection[username].getboxes(function (err, boxes) { if (err) { // todo : parse error here } else { folders = imapnestedfolders(boxes); } return callback(err, folders); }); }); } else { return framework.httperror(500, self); } } the parse folder pretty nested tree json object function function imapnestedfolders(folders) { var folders = []

javascript - Three.js Applying a random image to each of the faces of each cube in a group of cubes -

i new three.js , webgl please bear me :) using http://mrdoob.github.com/three.js/examples/webgl_geometry_hierarchy.html starting point able map 6 images each of faces of cube. cube gets replicated creating effect show here: http://assemblylondon.com/clients/dmsr/ss16/1/ what have array of x amount of images (let's 12) , have each of these 12 images applied randomly each of faces of each of cubes. having done extensive research on topic, not sure if possible, appreciate further clarification or confirmation. here's code atm: var camera, scene, renderer; var geometry, group; var mousex = 0, mousey = 0; var windowhalfx = window.innerwidth / 2; var windowhalfy = window.innerheight / 2; document.addeventlistener( 'mousemove', ondocumentmousemove, false ); init(); animate(); function init() { container = document.createelement( 'div' ); document.body.appendchi

css - Input fields are longer than grid in IE and Mozilla -

i cannot find class collidating contact form. form in bootstrap fields extend grid in mozilla , ie. what issue? <section> <div class="container"> <div class="row"> <div class="col-md-6 col-sm-12"> </div> <div class="col-md-6 col-sm-12"> <h2>formularz kontaktowy</h2> <?php echo do_shortcode ('[contact-form-7 id="81" title="kontakt"]'); ?> </div> </div> </div> </section> size="s": defines number of characters “s” appear in text box. more text can typed, not appear @ once in text box. note: in cases, size="40" should provide more adequate space text box. so fix issue there work around. in case can give width input field. input.wpcf7-text[type=&quo

How to insert multiple table rows after specific row with Jquery? -

i have html table each row has data element. this: <tr class="logreader-header-row"> <td class="logtable-header" colspan="100%" data-date="2015-05-12"> <img class="logreader-header-controller" src="images/logreader-dropdown.png"> 2015-05-12 </td> </tr> <tr class="logreader-header-row"> <td class="logtable-header" colspan="100%" data-date="2015-05-11"> <img class="logreader-header-controller" src="images/logreader-dropdown.png"> 2015-05-11 </td> </tr> <tr class="logreader-header-row"> <td class="logtable-header" colspan="100%" data-date="2015-05-07"> <img class="logreader-header-controller" src="images/logreader-dropdown.png"> 2015-05-07 </td> </tr> every row h

angularjs - error in angular.mock.inject when testing service -

i want make test of service in angularjs there problem injector. here service: var projectapp = angular.module("projectapp", []); projectapp.service("worktimeservice", function(){ this.workhours = function(workhours){ return workhours; } } here test: describe("unit: testing services", function(){ var worktimeservice; beforeeach(function(){ module("projectapp"); }); beforeeach(inject(function(_worktimeservice_){ worktimeservice = _worktimeservice_; })); it('should have funtion', function(){ expect(angular.isfunction(worktimeservice.workhours)).tobe(true); }); }); i have made in tutorials jasmine says worktimeservice undefined.

c++ - Sparse eigenvalues using eigen3/sparse -

is there distinct , effective way of finding eigenvalues , eigenvectors of real, symmetrical, large, let's 10000x10000, sparse matrix in eigen3 ? there eigenvalue solver dense matrices doesn't make use of property of matrix e.g. it's symmetry. furthermore don't want store matrix in dense. or (alternative) there better (+better documented) library that? armadillo using eigs_sym note computing all eigenvalues expensive operation whatever do, done find k largest, or smallest eigenvalues (which do).

mongodb - SalatDAO deserialization of typed class with list -

i have following case classes: case class network(val name : string, val mac : string) case class field[t](var value : t, var source : string = "") case class device(var _id : objectid = new objectid, var device_type : field[string] = field[string](""), var networks : field[list[network]] = new field[list[network]](list[network]())) { def hasmac(mac : string) : boolean = { networks.value.foreach { n => if(n.mac == mac) return true } return false } } i able serialize/deserialze instances of device. however, after deserializtion, hasmac method crashed exception: "classcastexception: com.mongodb.basicdblist cannot cast scala.collection.immutable.list" when device class defined this case class device(var _id : objectid = new objectid, var device_type : field[string] = field[string](""), var networks : list[network] = list[network]()) { def hasmac(mac

c++ - Fail to use function template with array as parameter inside a class -

i created function template. works fine if use in functions. now, i'd use inside class can't make code compile: #include <qlist> // function template template <typename t> void array2qlist(qlist<t> &outlist, const t in[], int &insize) { (int = 0; < insize; ++i) outlist.append(in[i]); } // class using template class parser { public: parser(const unsigned char buffer[], const int numbytes){ array2qlist<>(frame, buffer, numbytes); // 1 fails } ~parser(){} qlist<unsigned char> frame; }; // main int main(int argc, char *argv[]) { int size = 50; unsigned char buffer[size]; qlist<unsigned char> frame; array2qlist<unsigned char>(frame, buffer, size); // 1 works parser parser = parser(buffer, size); return 0; } the error is: ..\sandbox\main.cpp: in constructor 'parser::parser(const unsigned char*, int)': ..\sandbox\main.cpp:20: error: n

how to Copy data from an existing remote database(MySQL) to another local MySQL database with different schema? -

i want copy data mysql remote database other mysql database whith different schema (table , column names primary , foreign key constraint) i want bring data db1.person , put db2.user while mapping db1.person.id db2.user.id , same name , email column. i intend make process run twice week great have script it. remote database db1 has table person : id name email local database db2 has table user id name email group_id and group id label description take @ free database manager http://dbeaver.jkiss.org/ dbeaver job copying tables on different schemas or databases. has small footprint , copying fast.

javascript - Fade element out and fade in data from Array - jQuery -

i have 4 div items on page, i'm trying inner html of these items fade out randomly, take row array , fade in - in place, make sense? // items repopulate faded out info var testimonialsarray = [ "<div class='change'><h1>box 5</h1><p>lorem ipsum</p></div>", "<div class='change'><h1>box 6</h1><p>lorem ipsum</p></div>", "<div class='change'><h1>box 7</h1><p>lorem ipsum</p></div>", "<div class='change'><h1>box 8</h1><p>lorem ipsum</p></div>", "<div class='change'><h1>box 9</h1><p>lorem ipsum</p></div>" ]; // find random div , fade out var order = math.floor((math.random()* $('.change').length )+1); $('.box').eq(order).find('.change').fadeout(); .......fade in ne

python - Finding values in a dictionary if key matches in a range -

i have list , dictionary: l = [1, 4, 22, 33] dict = {1: 'red', 17: 'green', 33: 'blue'}; my goal return new list composed values (colors) associated each element in l if between key key+16 . i know how retrieve value if element of list matches key in dictionary, don't know how consider each key range , assign color every element in l . the expected output be: ['red', 'red', 'green', 'blue'] i know generating list dict able iterate on 2 lists, finding values in range. problem working 2 of more 80,000 elements per list, time , thought dictionary better. you can integer division: >>> l = [1, 4, 22, 33] >>> dct = {1: 'red', 17: 'green', 33: 'blue'} # don't name own dictionary dict >>> [dct[16*((x-1)//16)+1] x in l] ['red', 'red', 'green', 'blue'] basically, maps every number e.g. 1 16 inclusive 1 , every number

css - background-size: cover and iOS – we're not friends -

i’m looking simple solution since hours, can’t find any. problem: have site , use background-size: cover display header picture in full size. works fine on every browser, looks terrible on ios-device. example: http://www.dnu-films.ch/site/ idea? lot!

mongodb - Custom action in the edit view of sonata admin Bundle -

i'm working sonata admin bundle , want add custom action in edit view ( update update , close or delete). searched, didn't find solution. did before in list view. have tried make same thing in case following answer sonataadmin custom form action not work , got error could not load type "actions" when add ->add('_action', 'actions', array( 'actions' => array( 'view' => array('template' => 'atsadminbundle:crud:form__action_confirmation.html.twig') ) )) ; in configureformfields() any 1 can me plz ? this because configureformfields() doesn't accept entry. can in configurelistfields() . if want add action in edit form, buttons: "update", "update , close" or "delete", have override following template: vendor/sonata-project/admin-bundle/resources/views/crud/base_edit_form.html.twig copy file in app/

c# - How to find multiple values in array? -

my code below looks 1 letter, how can combination of letters? ex.: find letters "ac" in array , output them textbox2 string[] alphabet = new string[] { "a", "b", "c"}; (int letter = 0; letter < alphabet.length; letter++) { if (textbox1.text == alphabet[letter]) textbox2.text = alphabet[letter]; } i guess want check if letters of array entered in textbox: bool valid = textbox1.text.all(c => alphabet.contains(c.tostring())); if char[] write: bool valid = textbox1.text.all(alphabet.contains); then use enumerable.except set difference: var notvalidletters = textbox1.text.except(alphabet); textbox2.text = "following not valid letters: " + string.join(", ", notvalidletters);

Load Runner Session ID Changes Indefinitely -

good day i'm trying perform load testing loadrunner 11. here's issue: i've got automatically generated script after actions recording need catch session id. web_reg_save_param() in next way: web_reg_save_param("s_id", "lb=set-cookie: jsessionid=", "rb=; path=/app/;", last); web_add_cookie("s_id; domain={host}"); i catch id response (tree view): d2b6f5b05a1366c395f8e86d8212f324 compare replay log , see: "s_id = 75c78912ae78d26bdbde73ebd9adb510". compare 2 ids above next request id , see 3rd id (tree view): 80fe367101229fa34eb6429f4822e595 why have 3 different ids? let me know if have provide information. you should use(search=all) below code. provided right , left boundary correct: web_reg_save_param("s_id", "lb=set-cookie: jsessionid=", "rb=; path=/app/;", "search=all", last); web_add_cookie("{s_id}; domain={host}"); for details refer hp

PHP AJAX JSON Drop Down value on form submission -

i want retain value of drop down when form submitted. have 2 drop down- department , project interlinked through ajax. when submit, page reloaded, , default values of department , project comes out departments , projects, wish retain value selected user. this code. pardon rest of code if missing showing required code. <html><head><script type="text/javascript"> function showdept(){ $('#deptdropdown').empty(); $('#deptdropdown').append("<option value='0'> departments </option>"); $('#projectdropdown').append("<option value='0'> projects </option>"); $.ajax({ type:"post", url:"departmentdropdown.php", contenttype:"application/json; charset:utf-8", datatype:"json", success: function(data){

scala - In Slick 3.0, why is the newly-introduced `Streaming` useful? -

i found slick 3.0 introduced new feature called streaming http://slick.typesafe.com/doc/3.0.0-rc1/database.html#streaming i'm not familiar akka. streaming seems lazy or async value, not clear me understand why useful, , when useful.. does have ideas this? so lets imagine following use case: a "slow" client wants large dataset server. client sends request server loads data database, stores in memory , passes down client. and here we're faced problems: client handles data not fast wanted => can't release memory => may result in out of memory error. reactive streams solve problem using backpressure . can wrap slick's publisher around akka source , "feed" client via akka http. the thing backpressure propagated through tcp via akka http down publisher represents database query. that means read database fast client can consume data. p.s little aspect reactive streams can applied. you can find more information here:

Passing java object to python -

i prototyping interface our application allow other people use python, our application written in java. pass of our data java app python code unsure how pass object python. have done simple java->python function call using simple parameters using jython , found useful trying do. given class below, how can use in python/jython input function/class: public class testobject { private double[] values; private int length; private int anothervariable; //getters, setters } one solution. use sort of message system, queue, or broker of sort serialize/deserialize, or pass messages between python , java. create sort workers/producer/consumers put work on queues processed in python, or java. also consider checking out inspiration: https://www.py4j.org/ py4j used heavily by/for pyspark , hadoop type stuff. to answer question more immediately. example using json-simple .: import org.apache.commons.io.fileutils; import org.json.simple.jsonobject; //import

c# - Modular Programs in Framework of Larger Program -

i developing testing software in c# various problem solving strategies. program follows general structure of following: user chooses series of “strategy modules” user chooses number of “worlds” user tells program run “scenario” created depending on how strategy module decides interact world. final performance of scenario tabulated given objective set of grading criteria. each “world” datafile contains whole mess of information delineated time (think of table noting state of world per second). world immutable, no action taken “strategy module” affects data in this, “strategy module” can see row-by-row. each “strategy module” has specific set of rules how observes “world” , how reacts (along taking few user inputs parameters affect how this). each strategy module must stored in separate file (not compiled directly program), can updated/modified/deleted without updating framework of program running them. the way see it, strategy modules little mini-programs (also written in

javascript - three.js project won't upload a background image on IOS -

Image
please see project: http://webgl.unilimes.com/project/3dhouse/ on desktop, images uploaded fine using camera button: however, unfortunately, on ios not case: the image cropped, there's lots of weird lines across , in no way represents background image uploaded. furthermore, desktop app reads images exif data , moves model accordingly, whilst ios not here 2 example images picture of scene . picture location any pointers going wrong appreciated. i've seen background imagery uploaded three.js on ios before, im hoping there solution, exif reader don't know. thanks

windows phone 8.1 - WP8.1 transparent gradient -

Image
if use linear gradient way in wp 8.1: <grid height="20"> <grid.background> <lineargradientbrush endpoint="0.5,1" startpoint="0.5,0"> <gradientstop color="transparent" offset="0"/> <gradientstop color="black" offset="1"/> </lineargradientbrush> </grid.background> </grid> i picture this: when understand right, due deficient in alpha value transition. windows xaml there markupextensions , fix issue, windowsphone cannot use markupextensions . is there solid workaround, satisfies needs this? (and yes, should transparent, should fade out scrollbar on bottom , scrollbar has content of different colors. can trick around making "transparent" color color of surrounding.) okay guess problem white color...? the problem transparent same #ffffff full transparency, in argb notation #00ffffff . want transparent #000

jquery - How to set a div class depending on a variable value -

i trying set div class depending on variable set process. the reason trying create dashboard type page show if servers or down among other things. if there better way of doing happy try different option. code (from comment): <script> var server.v1 = "down" </script> <script> var servers.v2 = "up" </script> <div id=servers> <script> if document.getelementbyid("servers").innerhtml = v2 == { div class="componentsuccess" } else { div class="componentfail" } </script> using jquery, tagged question with, it's pretty straight forward var $mydiv = $(/* div */); var isvalid = /* code here check */ var classname = isvalid? 'valid' : 'invalid'; $mydiv.addclass(classname); obviously simplified example, you'll want toggle class , make sure doesn't both classes , on.

Combine PHP session and MySQL for query login state -

my compeny current php website has users logging in using session. keeping field in session $_session['user_id'] , when logging out unset field. user data name, address, balance saved in mysql user table. want create query returns logged in user , balance on 500$. how approach such task? consider have lot of users looping through sessions in session folder , querying db , matching results in not possibility. second option saving user login state in user table. setting 1 when user log in , 0 when log out. simplest option current code base , company bureaucracy. can think problem synchronization if session expire third option transfer responsibility of session db session_set_save_handler. what think best practice? (i'd add @ofir_baruch said, avoiding multiple calls db in order update last user's loggin time) add time-stamp "last login",in: user's table in db (lets call it: db's time-stamp) in user's session (lets call

node.js - How to handle this error when use nodejs writing a chat server? -

here code: var net = require('net'); var clientlist = []; var chatserver = net.createserver(function(socket){ socket.write("hi\n"); clientlist.push(socket); socket.setencoding('utf-8'); socket.on('data', function(data){ (var = 0; < clientlist.length; i++) { clientlist[i].write(data); }; socket.end(); }); }).listen(4000); when access http://127.0.0.1:4000 , give me response: hi / http/1.1 host: localhost:4000 connection: keep-alive cache-control: max-age=0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 user-agent: mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/42.0.2311.135 safari/537.36 accept-encoding: gzip, deflate, sdch accept-language: en-us,en;q=0.8,zh-cn;q=0.6,zh;q=0.4 but program crashed: here output form console: c:\users\elqstux\desktop>node wy.js events.js:85 throw er; // unhandled 'error&

android - Installed java 64 bit but still gettin error opening eclipse -

Image
i using java 32 bit , eclipse juno 32 bit till yesterday.today installed java 64 , eclipse luna 64 bit on computer.my os windows 7 64bit. i getting error when try open eclipse. i have looked @ many solitions none of them worked. my console when asked java version shows. and my java_home set c:\program files (x86)\java\jdk1.7.0_05 jdk_home set c:\program files (x86)\java\jdk1.7.0_05 and java folder in programs(x86) folder the version shown in console 1.7.0_79 , version in error message not same.where going wrong? your java_home , jdk_home still pointing 32bit version. must change them 64 bit version or edit eclipse.ini following command: -vm [path 64 bit jdk]

Android Studio Project Encoding Default Value -

i'm using android studio 1.2, when create project, open file encodings setting window via file -> settings -> editor -> file encodings , there project encoding option defaults gbk on computer (windows 7 64 bit). manually change utf-8 each project, there way let default utf-8 directly? thanks in advance. please have try, works me. file -> other settings -> default settings, find "file encodings", change project encoding utf-8.

c# - Httphandler registration not working -

i have handler called msidownloadhandler lets client download msi file if exists, , otherwise creates msi file , lets client download it. though have registered handler in web.config this: <handlers> <add name="msidownloadhandler" verb="*" path="*.msi" type="msidownloadhandler, managementconsolev2, version=1.0.0.0, culture=neutral" resourcetype="file" /> </handlers> <validation validateintegratedmodeconfiguration="false" /> the handler break point not hit , error: the resource looking has been removed, had name changed, or temporarily unavailable. what doing wrong?? you used: resourcetype="file" /> but said, handler meant work if there no file on server location mapped path of uri. such handler, want resourcetype="unspecified" .

c# - data val required not generated using Client Side Validation -

i trying use client side validation in mvc using data annotations. data val attribute not generated , client side validation not working. my approach : public partial class user : baseentity { public user() { this.userroles = new list<userrole>(); } public int userid { get; set; } public string firstname { get; set; } public string lastname { get; set; } } i using above class partial class extension: [metadatatype(typeof(usermetadata))] public partial class user { } public class usermetadata { [required] public string firstname { get; set; } [required] public string lastname { get; set; } } including view : @using (html.beginform("add", "user", formmethod.post, new { @class = "form-horizontal"})) { @html.antiforgerytoken() @html.validationsummary(true) @html.partial("_userdetails", model) <

tortoisesvn - Need to implement SVN hooks on Windows -

i working on svn on windows , increasing knowledge boundaries exploring svn in deep. came through hooks can helpful tracking records. working on windows 7 , visualsvn. need implement post-commit hook automate process ina way if develpoer commits in file in repo, email triggered containing file , autor. please let know file need modify , how. use visualsvnserverhooks.exe built-in hook: https://www.visualsvn.com/support/topic/00018/ .

ffmpeg - basetime for strftime segment filename template -

i have big mp3 file, started recording @ 17:24. trying split 2 minute segments: ffmpeg -y -i test.mp3 -map 0 -c copy -f segment -segment_time 120 -reset_timestamps 1 -strftime 1 '1/test-%h-%m.mp3' need segment names test-17-24.mp3, test-17-26.mp3, ... , actual first segment named current time, no segments created $ date tue may 12 06:52:04 msk 2015 $ ffmpeg -y -i test.mp3 -map 0 -c copy -f segment -segment_time 120 -reset_timestamps 1 -strftime 1 '1/test-%h-%m.mp3' ffmpeg version n-72058-g3ecc063 copyright (c) 2000-2015 ffmpeg developers input #0, mp3, 'test.mp3': duration: 05:45:05.94, start: 0.000000, bitrate: 171 kb/s stream #0:0: audio: mp3, 48000 hz, stereo, s16p, 171 kb/s [segment @ 000000000051d560] codec stream 0 not use global headers container format requires global headers output #0, segment, '1/test-%h-%m.mp3': metadata: encoder : lavf56.33.100 stream #0:0: audio: mp3, 48000 hz, stereo, 171 kb/s stream mappin

c++ - Focus not changing upon tab key in a nested CWnd-Derived Class -

environment: vs2013, mfc, c++ i have cdialog derived dialog 2 static buttons (ok, cancel), created dialog editor. additionally dialog should contain dynamically created instance of cwnd-derived class, contains 2 edit boxes. problem cannot move focus via tab-key between edit boxes , cannot make 1 of boxes have initial focus when opening dialog. when hit tab key 1st editbox gets focussed , point on can't move focus tab key away (clicking mouse works). i created cwnd ws_ex_controlparent style, still doesn't work move focus. where's problem? i've done far: //the cdialog-class should container cwnd //.h class cdlgselcatalogitem : public cdialog { clistfilterinput _ctrllist; //cwnd-derived, contains 2 edit-boxes } //.cpp bool cdlgselcatalogitem::oninitdialog() { crect rectlist(10, 10, 100, 50); _ctrllist.create(rectlist, this); } //the cwnd-derived class contains 2 edit-boxes //.h class clistfilterinput : public cwnd { bool create(const rect& rec

How to implement Google Analytics v4 on a Project in Android Studion imported from legacy Eclipse ADT -

Image
my legacy application project doesn't have application class. so, official document doesn't help. don't know following code should go: /** * enum used identify tracker needs used tracking. * * single tracker enough purposes. in case need multiple trackers, * storing them in application object helps ensure created once per * application instance. */ public enum trackername { app_tracker, // tracker used in app. global_tracker, // tracker used apps company. eg: roll-up tracking. ecommerce_tracker, // tracker used ecommerce transactions company. } hashmap<trackername, tracker> mtrackers = new hashmap<trackername, tracker>(); and these code: synchronized tracker gettracker(trackername trackerid) { if (!mtrackers.containskey(trackerid)) { googleanalytics analytics = googleanalytics.getinstance(this); tracker t = (trackerid == trackername.app_tracker) ? analytics.newtracker(property_id) : (trackerid == trackername.global_tr

c - gdb giving a function name followed by a number instead of file and line number -

i have segmentation fault in program, , i'm using gdb identify it's happening. however, not able see clear line number error occurring. below screenshot of output. program received signal sigsegv, segmentation fault. [switching thread 20065168 (lwp 4645)] 0x007e537f in _int_free () /lib/libc.so.6 (gdb) backtrace #0 0x007e537f in _int_free () /lib/libc.so.6 #1 0x007e90f0 in free () /lib/libc.so.6 #2 0x080d9e67 in crypto_free () #3 0xbfd15f7c in ?? () #4 0xbfd16108 in ?? () #5 0x08070b3e in function_random.19532 () #6 0x00000001 in ?? () #7 0x00000000 in ?? () (gdb) frame 5 piece of code have written, don't quite understand means. can please explain? most likely, in case, debug symbols not present in binary. why, gdb not able read debugging info , display them. re-compile code, debugging enabled. example: gcc , use -g options.

forms - PHP Dynamically added elements on Submit grab values -

solved i found issue, while creating new row accidently grabbing tag , creating new form wrap every time added row. so ended being: form row 1 form 2 row 2 form 3 row 3 form end i trying submit form dynamically added fields keep getting initial one. setup htmldom form<br/> div->item<br/> --input<br/> --selectoption<br/> --textarea<br/> --radiobutton<br/> div->item(endwrap) i have jquery grab initial wrap variable, once click add row elements +1 count. i have tried following on form submit: foreach ($_post['user'] $key=>$value ) { echo $key . " : " . $value; } <input id="user" type="text" name="user[]" autocomplete="off"/> however shows me user of first item -> wrap or row. my question best way iterate on dynamically added elements inside form on submission can add values db. thank you! direction valid tutorial appreciated (had no luck

PHP Soap and REST based service best practise -

i working on library implement soap , rest based client letting library user decide between soap or rest. my question is; service consuming has ton of operations/functions call, debtor_getall, debtor_create, debtor_update, debtor_find_by_name , forth. should represent each operation/function service offers method in interface this interface iservice { public function debtor_get_all(); public function debtor_create($params); public function debtor_update($params); public function debtor_find_by_name($name); } or should try abstract service , implement like interface iservice { public function get( $debtor_id ); public function post( $params ); public function put( $params ); } in order soap , rest adhere same "vocabulary"? first option gives me ton of methods implement, each doing unique job. second options gives me less methods implement more complex logic per method. more complex since get() method have handle both debtor_get_all debtor_find_by_name. th

python - NameError: global name 'b' is not defined -

i have script wih following structure: def func(): bfile=open(b, 'r') cfile=open(c, 'r') dfile=open(d, 'r') if __name__=='__main__': if len(sys.argv)==1: print 'guidence' sys.exit() else: opts,args=getopt.getopt(sys.argv,'b:c:d:a') a=false opt,arg in opts: if opt=='-a': a=true elif opt=='-b': b=arg elif opt=='-c': c=arg elif opt=='-d': d=arg func() i run in way: # python script.py -b file1 -c file1 -d file1 in func() nameerror: global name 'b' not defined i define global file1. no work. update i know problem is: result of print opts [] . has not values. why? you have 2 issues. first, getopt stops if encounters non-option. since sys.argv[0] script name, it's non-option , parsing stops the

f# - Why would the following errors occur in Xamarin Studio on OS X but not in Visual Studio? -

Image
i'm trying understand why i'm getting following errors when running tests in xamarin studio 5.9.1 (build 3) on os x. system.io.filenotfoundexception : not load file or assembly 'system.net.http, version=1.5.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' or 1 of dependencies. system.typeloadexception : type load exception has occurred. all projects build , same tests run fine in visual studio on windows using same solution. i am seeing warning when building test project on os x, despite having installed , added reference. all projects referencing myproject.fsproj must install nuget package microsoft.bcl.build. more information, see http://go.microsoft.com/fwlink/?linkid=317569 . i still don't know why xamarin behaves differently visual studio, root cause test project targeting .net 4.5 whereas main project targeting .net 4.0 thanks @7sharp9 help.

php - PHP_SELF and GET parameters -

when using $_server['php_self'] in form redirect page itself, such this: <form method = "get" action = "<?php echo $_server['php_self']; ?>"> ...some html </form> when user submits form uri doesn't show parameters: http://example.com/page.php instead of (the 1 i'm trying do) http://example.com.page.php?parameter=value resulting in, when user refreshes page, not process parameters because not there. how can resolve this? you can put empty form action in following example: <form action="" method="get"> all parameters preserved

rspec - Rails capybara feature spec No 'Access-Control-Allow-Origin' -

i have feature spec, part of page load. hit local url more data. i.e. using http://fullcalendar.io/ loads it's events via ajax events: { url: 'calendar_events.json', type: 'get', error: function(response) { ... }}, i getting xmlhttprequest cannot load http://localhost:3000/calendar_events.json?start=2014-01-20&end=2014-01-27. no 'access-control-allow-origin' header present on requested resource. origin 'null' therefore not allowed access. response had http status code 404. not sure how resolve. tried adding response.headers['access-control-allow-origin'] = '*' response.headers['access-control-allow-methods'] = 'post, put, delete, get, options' response.headers['access-control-request-method'] = '*' response.headers['access-control-allow-headers'] = 'origin, x-requested-with, content-type,

php - CakePhp i18n translation words order in .po files -

currently in view have this: <span style="color: #2363a2;"><?php echo __('accèdez à tous les %spronostics%s d\'%s', '<span style="font-weight: bold; text-transform: uppercase">', '</span>', appcontroller::getsitename()); ?></span> in .po file have this: msgid "accèdez à tous les %spronostics%s d'%s" msgstr "reach %s %spicks%s" the translation (from french - msgid - english - msgstr -) wrong. the 1st %s value in msgstr should 3rd %s value in msgid. did researches related i18n cakephp didn't find nothing related issue. do know how 'set order' of translated %s ? thanks. i've had issues in past when passing replacement arguments multiple function arguments. using array tends more reliable:- __( 'accèdez à tous les %spronostics%s d\'%s', [ '<span style="font-weight: bold; text-transform: uppercase">

sql - Create insert function in php -

hello have logs table in database , in every user action log in, log out, edit, delete, create, want logged. here current code in every action: $action = "log in"; //if user log in $query = "insert tbllogs (logorigin, logaction, loguser, logdate, logoutcome) values (:origin, :action, :user, :dt, :outcome)"; $stmt = $dbc->prepare($query); $stmt->bindparam(':origin', $ip); $stmt->bindparam(':action', $action); $stmt->bindparam(':user', $_session['id']); $stmt->bindparam(':dt', $datetime); $stmt->bindparam(':outcome', $outcome); $stmt->execute(); what wanted instead of repeating code in every user action, want create function this. problem

python - Django Edit Form Queryset made of Query + Current Selected Option - How to get? -

my forms.py class createvesselform(forms.modelform): class meta: model = vessel exclude = ['active'] # filtering choices def __init__(self, *args, **kwargs): super(createvesselform, self).__init__(*args, **kwargs) # filtering free slots self.fields['slot'].queryset = slot.objects.filter(is_free=true) # filtering free storages self.fields['storage'].queryset = storage.objects.filter(is_free=true) the slot field foreignkey , storage field manytomany field. in views.py, time save form change status of "is_free" false. when time edit item(vessel) - getting form instance - options selected before, no longer appear in form fields because queryset filtering status=true. the perfect form queryset me be: for foreignkey the current selected item "vessel.slot" + slot.objects.filter(is_free=true) ? for manytomany the current selected item "vessel.storage" + storage.objects.filter(is_free=true) ?

android - fb like button not shown in webview loading local html -

i use mwebview.loadurl("file:///android_asset/test.html") button not shown. , logcat show fb:like failed resize in 120s. how can resolve it? test.html <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) return; js = d.createelement(s); js.id = id; js.src = "https://connect.facebook.net/en_us/sdk.js#xfbml=1&version=v2.3&appid=xxxxxxxxxx"; fjs.parentnode.insertbefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>

php - PDO main variable naming. Is it a connection, or a handler, or a handle? -

in code below there variable named "dbh". describe variable "connection", "handler", "handle" or else? might seem trivial , non important question, know correct term call variable know call when talk it. try { $dbh = new pdo("mysql:host=".db_server.";dbname=".db_name, db_user, db_pass); } catch(pdoexception $e) { echo $e->getmessage(); } it's "handle" db class. in case, it's referencing pdo class instance, , think that's should call it.

gmail - how to send a mail to contacts in particular label -

i have bunch of emails from:do-not-reply@organisation.com organisation can reply particular sender of organisation reply-to:sender@gmail.com (all mails different senders) .. marked mails organisation seperate label called my_label .. now problem is, how can send(compose) mail senders in label my_label ??. kindly, me!!. thank in advance. labels messages not contacts, can't that. instead can create contact group senders: create new contact group. select emails label. drag , drop emails new contact group.

sql server 2008 - Select all days from a table missing some dates -

i have table data below, , i'm trying sum column b , group day. works great. days have no data in table @ all. want show these days having sum 0, i'm bit confused on how there. date, column b 05/24/90, 5 05/24/90, 27 05/26/90, 19 05/27/90, 24 what want have in end is 05/24/90, 32 05/25/90, 0 05/25/90, 19 05/27/90, 24 etc... something should work: declare @mindate date = (select min([date]) yourtable); declare @maxdate date = (select max([date]) yourtable); cte_dates ( select @mindate dates union select dateadd(day,1,dates) cte_dates dates < @maxdate ) select a.dates, sum(isnull(b.[column b],0)) cte_dates left join yourtable on a.dates = b.dates group a.dates

c# - Why do I get error 'File does not contain a valid CIL image' when debugging from Visual Studio Code editor? -

i'm running visual studio code on max os x , seeing error. works fine when run directly terminal using dnx .run any suggestions on how can fix this? error trace terminal 'mono' --debug --debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:57332 'program.cs' cannot open assembly 'program.cs': file not contain valid cil image. asp.net 5 explicitly stated microsoft not yet supported, , there other debugging limitations, https://code.visualstudio.com/docs/faq so wait, wait, wait.

css - How to control primefaces default component size -

i had issue while using p:sticky p:panel , have fixed width size p:panel . that code: <p:panel id="scrolltopid" style="height: 21px; position:static; top: auto; width:99.4%;">......</p:panel> <p:sticky target="scrolltopid"/> after loading page <p:panel> had width:99.4% when scroll p:panel reach top , automatically width size getting high width:99.4% . like: element.style { height: 21px; position: static; top: auto; width: 1290.17px; z-index: 1005; } any idea fix width gave width:99.4%? it takes 99.4% of width of parent container, dependend on value of value of css position. if either changes due being sticky on top, can see behaviour. use browser developer tool firebug see changes , originates from. i'm afraid have advanced css behave want (this in fact not pf issue)

javascript - Don't Grab Word With Regex If It Has Tags Around It JS -

i having trouble regex, , tbh not sure if possible. ok if text has [code] tags around it, text inside not parsed. let me show mean: [b]this text appear bold[/b] [code] [b]this text not appear bold, bold tags still shown[/b] [/code] so trying check , see if text has [code] tags around it. have tried regex: /((?!\[code\])\[b\](.*)\[\/b\](?!\[\/code\]))/gi so thought (?!\[code\]) not display text if had around it, still not working. if text has [code] around it, text inside higlighted, [code] tag not be. how go showing bold if not have code tags around it? to avoid way match first , capture it. replace text enclosed between [b] tags except when theses tags between [code] tags, can write: txt=txt.replace(/(\[code\][\s\s]*?\[\/code\])|\[b\]([\s\s]*?)\[\/b\]/g, function (m, g1, g2) { return g1 ? g1 : '<b>' + g2 + '</b>'; }); so when group 1 exists returned without change. when not defined replacement string returned.

Convert SQL to linq to SQL with cross apply -

this question has answer here: how write cross apply query in linq-to-sql? 2 answers any idea how convert cross apply sql query linq-to-sql? select * dbo.company inner join dbo.contact c on c.contid = dbo.company.compcontactid or dbo.company.compcontactid null inner join dbo.company_program cp on cp.compid = dbo.company.compid or dbo.company.compid null inner join dbo.program p on cp.progid = p.progprogramid inner join dbo.division d on d.divid = p.progdivisionid inner join dbo.phonetype pt on pt.phtphonetypeid = c.contphonetypeid or c.contphonetypeid null inner join dbo.phonenumber ph on ph.phoneid = pt.phtphoneid or pt.phtphoneid null cross apply (select top 1* dbo.participation p p.participationid = dbo.company.compparticipationid or dbo.company.compparticipationid null ) part divid = 29 cr

ios - UITextView that expands dynamically doesn't expand UIScrollview using auto layout -

Image
i have scrollview has 2 views in content view. 1 of views has 2 textviews expand dynamically. when textviews expand, scrollview not. :( i tried setting contentsize height height of 1 of textviews (although have 2 textviews) described here messed labels etc. under textview (they wouldn't push down/follow height of textview). i have in viewdidlayoutsubviews right now. cgrect contentrect = cgrectzero; (uiview *view in self.scrollview.subviews) { contentrect = cgrectunion(contentrect, view.frame); } self.scrollview.contentsize = contentrect.size; is there else can try scrollview expand textview? can change auto layout?

vb.net - Connect four winner -

i'm trying check winner vertically , horizontally in connect 4. have playing board of 7,6 when click button change labels color. labels in 2 dimensional array. loop have created make see if there winner every time button clicked, doesn't work. dim board(7,6) integer dim labelboard (7,6) label labelboard(0,0) = l00 'i have 41 others integer = 0 3 k integer = 0 3 if pturn =1 tag= "p1" 'horizontal win integer = 0 3 k integer = 0 6 if labelboard(i, k).tag.tostring = "p1" andalso labelboard(i + 1, k).tag.tostring = "p1" andalso labelboard(i + 2, k).tag.tostring = "p1" andalso labelboard(i + 3, k).tag.tostring = "p1" msgbox("game on player 1 wins.") end if next next your current posted code d

java - Android: Substring & IF -

this question has answer here: how compare strings in java? 23 answers i have problem following code. cut string "data1", give "data2" , check string. phone says "ab not ab", not know why? -.- any ideas? string data1 = "abc"; string data2 = ""; data2 = data1.substring(0, 2); if(data2 == "ab") { toast.maketext(this, data2 + " ab" , toast.length_long).show(); } else { toast.maketext(this, data2 + " not ab", toast.length_long).show(); } thanks ... in java compare strings using method equals() . more info here change if statement follows if(data2.equals("ab")) { toast.maketext(this, data2 + " ab" , toast.length_long).show(); } else { toast.maketext(this, data2 + " not ab", toast.length_long).show(); }

php - How to prevent duplicate records from insert to my table? -

this question has answer here: mysql - make existing field unique 7 answers +-----+--------------+--------+-----------+ | id | a_no | status | req_date | +-----+--------------+--------+-----------+ | 1 | 6019-6039120 | 0 |2015-03-01 | | 2 | 6019-6039120 | 0 |2015-03-01 | | 4 | 6019-6039120 | 0 |2015-03-02 | | 5 | 6019-6039121 | 0 |2015-03-02 | | 6 | 6019-6039134 | 0 |2015-03-02 | | 7 | 6019-6039134 | 0 |2015-03-02 | | 8 | 6019-6039120 | 0 |2015-03-03 | | 9 | 6019-6039129 | 0 |2015-03-03 | | 10 | 6019-6039145 | 0 |2015-03-04 | | 11 | 6019-6039167 | 0 |2015-03-04 | +-----+--------------+--------+-----------+ this table structure, can see id=1 , id=2 have same data. how prevent same data insert table? add unique constraint/index: create unique index idx_table_3 on table(a_no, s

c# - Directory.GetFiles() performance issues -

using system.io.directory.getfiles() , find images .png extension located on nas server. string searchingstring = "zllk9"; // original var filelist1= directory.getfiles(directorypath).select(p => new fileinfo(p)).where(q => q.name.substring(0, q.name.lastindexof('.')).split('_').first() == searchingstring); // fixed var filelist2 = directory.getfiles(directorypath, string.format("{0}_*.png", searchingstring)); there 2 ways find out files contain "zllkk9" words. the first 'original' way using linq slow find out files. performance issues don't know different 'fixed' way? i need understanding difference 2 ways carefully. the first way slow 2 reasons: you're constructing fileinfo object each file. there's no need if want file name. constructing fileinfo relatively light, it's unnecessary , instantiations slow down if you're querying lot of files. since need file's name