Posts

Showing posts from September, 2011

node.js - Cant find methods in Express -

i have node js code this: var express = require('express') , app = express.createserver(); app.use(express.bodyparser()); app.post('/', function(request, response){ console.log(request.body); // json response.send(request.body); // echo result }); app.listen(3000); when run error this: , app = express.createserver(); ^ typeerror: object function createapplication() { var app = function(req, res, next) { app.handle(req, res, next); }; mixin(app, proto); mixin(app, eventemitter.prototype); app.request = { __proto__: req, app: app }; app.response = { __proto__: res, app: app }; app.init(); return app; } has no method 'createserver' @ object.<anonymous> (/users/anto_belgin/programs/node/appleconnect.js:2:19) @ module._compile (module.js:456:26) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12)

java - Provider for custom annotation -

how google guice create provider custom annotations. @superanno object test - custom annotation if annotation find, system automatically call provider convert in guice module: @provides @superanno object get() { return myobject.getinstance(); // example } in main class: @inject @superanno object injectedobject; public dostuff() { // stuff injected field } i recommend using more specific type object . question not entirely clear me used object since seems wanted to. please explain question further if not answer it.

jquery - draggable helper going behind table in jqgrid -

Image
i have been using jquery draggable rows has been implemented jqgrid.but when item dragged drag helper not going out of table boundary. can drop item. helper item not showing outside table during drag process. how can make possible show helper on top of jqgrid table? code snippet:- $(document).ready(function(){ var dragtext=''; $("#list2 tr").draggable({ helper:helptext, cursor : 'move', revert : 'invalid' }); function helptext(){ $("#tree li span").droppable(); console.log('drag'); dragtext=$(this).find("td:nth-child(5)").text(); return'<div id="draggablehelper">' + dragtext + '</div>'; }; }); you need helper div appended html body (or other containment area want) float around anywhere in containment area. a sample code: $("#list2 t

Using "-Filter" with a variable in PowerShell -

i try filter out this: get-adcomputer -filter {name -like "chalmw-dm*" -and enabled -eq "true" } .... this works charm , gets want... now want "name -like .... " part variable this: get-adcomputer -filter {name -like '$nameregex' -and enabled -eq "true" } | i checked several questions (for example, powershell ad module - variables in filter ). isn't working me. i tried following: $nameregex = "chalmw-dm*" $nameregex = "`"chalmw-dm*`"" and in get-adcomputer command ' , without. could give me hints? you don't need quotes around variable, change this: get-adcomputer -filter {name -like '$nameregex' -and enabled -eq "true" } into this: get-adcomputer -filter {name -like $nameregex -and enabled -eq "true" } and ftr: you're using wildcard matching here (operator -like ), not regular expressions (operator -match ).

c++ - How to receive HTTP GET and POST requests in C socket program? -

i trying create small c socket server. server sends out http/html responses fine enough. clients sending html requests , clients can different devices - mobile apps, browsers etc. need log requests type of devices requesting what. i happen know browser sends cookies , user-agent info server , want server able record cookie , user-agent strings well. so how enable reading of http headers in c/c++ server? what trying read socket. using recv, problem solved. thinking complex while solution simple.

autolayout - iOS 8 tableview cell constraints broken -

i'm not sure apple changed in ios 8 tableview cells constraints broken. they working fine in ios 7, cells appeared , behaved intended them to, no constraint conflicts log message xcode. but after upgrading phone ios 8 , running app, got constraint conflict xcode log messages. i haven't changed code or anything. related ios 8 new layoutmargins property? is else having same problem? hopefully i'm not not duplicating existing questions, please close if so. some clarification my app doesn't use interface builder, done code. as said, haven't changed layout code cells, work perfect normal on iphone 5 running ios 7 run app on ios 8 iphone 5, same code shows constraint conflicts of sudden: unable simultaneously satisfy constraints. @ least 1 of constraints in following list 1 don't want. try this: (1) @ each constraint , try figure out don't expect; (2) find code added unwanted constraint or constraints , fix it. (note: if you're seeing

java - Diffrentiate Common Http Errors in URL.openStream() -

i quite stuck i have differentiate common http errors occurred during url.openstream() . main purpose identify following http request errors: 400 (bad request) 401 (unauthorized) 403 (forbidden) 404 (not found) 500 (internal server error) till identify 404 catching filenotfoundexception. code snippet: try { file.createnewfile(); url url = new url(fileurl); urlconnection connection = url.openconnection(); connection.connect(); // download file inputstream input = new bufferedinputstream(url.openstream()); // store file outputstream output = new fileoutputstream(file); byte data[] = new byte[1024]; int count; while ((count = input.read(data)) != -1) { output.write(data, 0, count); log.e(tag, "writing"); } output.flush(); output.close(); input.close(); result = http_success; } catch (filenotfoundexception fnfe) { log.e(tag, "exception found filenotfoundexception=" +

css - Overflow hidden not working on container div -

i've included know, overflow hidden, word-wrap, height, width, max-width, long sentences still spill out of container. here jsfiddle > http://jsfiddle.net/acrane/2nhzmx1o/ below css of div text spilling out of. it's part of nav hover pops up. .nav-info, .nav-info-fixed { width: 100%; position: absolute; top: 0%; background-color: #fff; border-radius: 10px; z-index: 1000; height:100%; overflow: hidden; word-wrap: break-word; margin: 0 0 10px 0; background-color: rgba(255,255,255,.8); color: #000; } updated edit didn't want use ellipsis, wanted words wrap, solution , links jsfiddles in comments below accepted answer. you have no issue overflow. if set text-overflow ellipsis see, text correctly cropped. fact, container not have padding in combination border-round reason why looks issue. check this out better general understanding

how to call model in laravel from controller -

how call model in laravel. my code is: use jacopo\authentication\models\guide; class samplecontroller extends basecontroller { public function index() { $model='guide'; $guide=$model::where('guide_link','=',"guide")->get(); print_r($guide); } } this produce class 'guide' not found error. you need add namespace string: class samplecontroller extends basecontroller { public function index() { $model='jacopo\authentication\models\guide'; $guide=$model::where('guide_link','=',"guide")->get(); print_r($guide); } } you resolve ioc container, need register first: app::bind('guide', 'jacopo\authentication\models\guide'); and should able to: $model = app::make('guide'); $guide = $model::where('guide_link','=',"guide")->get(); but not option

php - Adding Anchor to every module in Joomla 3.1 -

i trying modify module template code add anchor title of each module. have extremely limited php knowledge, guidance helpful. i've found posts doing articles, code appears different modules. this code in module template. function modchrome_basic($module, &$params, &$attribs) { if (!empty ($module->content)) : ?> <?php echo $module->content; ?> <?php endif; } function modchrome_standard($module, &$params, &$attribs) { if (!empty ($module->content)) : ?> <div class="rt-block <?php if ($params->get('moduleclass_sfx')!='') : ?><?php echo $params->get('moduleclass_sfx'); ?><?php endif; ?>"> <div class="module-surround"> <?php if ($module->showtitle != 0) : ?> <div class="module-title"> <?php echo '<h2 class="title">';

css - How do I make the menu tabs the same width and center align the contents in them? -

here css code page: #drop-nav { width: 1000px; position: absolute; } #contentwrap { margin-top: 40px; } ul li ul li { padding: 10px 18px 5px 0px; text-align: left; width: 100%; display: table-cell; } ul { margin: 0px; padding: 0px; list-style-type: none; list-style-image: none; list-style-position: outside; overflow: visible; position: static; } ul li { border: 1px solid #000000; display: block; position: relative; float: left; background-color: white; } li ul { display: none; background-color: #3333ff; } ul li { padding: 10px 18px 5px 90px; background: #3333ff none repeat scroll 0% 50%; text-decoration: none; white-space: nowrap; color: #ffffff; overflow: visible; text-align: center; display: block; } ul li a:hover { background: #3366ff none repeat scroll 0% 50%; overflow: visible; } li:hover ul { display: block; position: relative; overflow: visible; } li:hover li { float: none; background-color: #3366ff; } li:hover { ba

javascript - Angular UI Bootstrap: Typeahead directive doesn't work properly with AngularJS v1.3 -

i've got typeahead directive in application , it's work fine angularjs v1.2.24. i've got v1.3 , there problem. fething data still works fine, function tied typeahead-on-select event doesn't invoke when select choice. want use v1.3 because v1.2.24 doesn't support $groupwatch on scope attribute of link function need typeahead directive.

Make go variable accept multiple types -

i develop library in go makes use of different file formats of debug package in go standard packages ( http://golang.org/pkg/debug/ ). idea open file , print out information file. automatically recognize correct file format testing relevant file types. instance, test if file simple mach-o or fat mach-o file, trying open file both open methods: file, err := macho.open(filename) if err != nil { fmt.println("not mach-o file.") } file, err = macho.openfat(filename) if err != nil { fmt.println("not fat mach-o file. exiting.") return } unfortunately file variable (of course) type checked, , following error: cannot assign *macho.fatfile file (type *macho.file) in multiple assignment i not sure of correct way of approaching this. can point me right direction how perfom properly? or don't declare file @ all, if you're not going it. if _, err := macho.open(filename); err != nil { fmt.println("not mach-o f

c - %s expects 'char *', but argument is 'char[100]' -

i have along lines of: #include <stdio.h> typedef struct { char s[100]; } literal; literal foo() { return (literal) {"foo"}; } int main(int argc, char **argv) { printf("%s", foo().s); return 0; } and error when compiling (with gcc): warning: format ‘%s’ expects argument of type ‘char *’, argument 2 has type ‘char[100]’ [-wformat=] any1 has ideas on how can fix it? , wrong function return type? edit problem (if not clear in discussion) c standard gcc using compile file. if use -std=c99 or -std=c11 works. it not error warning, not warnings -wall produces sensible. here compiler "kind-of" right: before evaluation argument array , not pointer, , taking address of temporary object bit dangerous. managed rid of warning using pointer explicitly printf("%s\n", &foo().s[0]); also should notice using rare animal, namely object of temporary lifetime , return value or function. since c99, there special

c++11 - Access static constexpr std::array without out-of-class definition -

i have class defines arrays. points.hpp class points { public: static constexpr std::array< double, 1 > a1 = { { +0.0 } }; static constexpr std::array< double, 2 > a2 = { { -1.0 / std::sqrt( 3.0 ), +1.0 / std::sqrt( 3.0 ) } }; }; my main file uses these arrays. main.cpp #include "points.hpp" int main() { // example on how access point. auto point = points::a2[0]; // point. } when compile code, using c++11 , g++ 4.8.2, following linker error: undefined reference `points::a2' i attempted create points.cpp file compiler can create object file it. points.cpp #include "points.hpp" but did not fix linker error. i under impression possible initialize variables static constexpr in c++11 in class declaration, , access them way i'm doing it, shown in question: https://stackoverflow.com/a/24527701/1991500 do need make constructor points , instantiate class? doing wro

java - Create New Strings in normal memory and in string pool -

this question has answer here: what java string pool , how “s” different new string(“s”)? [duplicate] 6 answers if example: string str1 = “abc”; string str2 = new string(“def”); then, case 1 : string str3 = str1.concat(str2) go in heap or pool? case 2 : string str4 = str2.concat(“hi”) go in heap or pool? in java, whichever string u create using new keyword created in heap memory. if create string without using new, created in string pool , called string constant. there 1 copy of string constant pool value means duplicates wont there in string pool.

javascript - Website not completely scrollable when using skrollr on mobile -

i have hard time getting skrollr work on mobile browsers: on desktop computer works fine when using safari ios page not scrollable. can scroll e.g. until second paragraph no further. i've tested safari on ios not other mobile browsers. paradoxically works on jsfiddle preview i've created: http://jsfiddle.net/gatl4ttn/3/ http://jsfiddle.net/gatl4ttn/3/embedded/result/ it not work self hosted version: http://www.finiam.de/test <div class="parallax-image-wrapper parallax-image-wrapper-100" data-anchor-target=".gap" data-bottom-top="transform:translate3d(0px, 200%, 0px)" data-top-bottom="transform:translate3d(0px, 0%, 0px)"> <div class="parallax-image parallax-image-100" style="background-image:url(http://placekitten.com/g/2000/1000)" data-anchor-target=".gap" data-bottom-top="transform: transl

animation - Android-Rotate and Expand imageview -

im trying rotate imageview in degrees , @ same time expand imageview's height ! code far : public class tonguehandler { imageview tongue; relativelayout.layoutparams tongue_params; objectanimator rotate_tongue; scaleanimation scale_tongue; animationset as; imageview frog; button btn; public tonguehandler(button btn,imageview frog,imageview tongue){ this.btn=btn; this.frog=frog; this.tongue=tongue; } public void initialize() { tongue.setbackgroundcolor(color.red); tongue_params=new relativelayout.layoutparams(10,100); tongue_params.leftmargin=frog.getleft()+frog.getwidth()/2; tongue_params.topmargin=frog.gettop()+frog.getheight()/2; tongue.setlayoutparams(tongue_params); animate(); } public void animate() { as=new animationset(true); rotate_tongue=objectanimator.offloat(tongue, "rotationx", 90.0f, 90+calcangle(frog,btn

android - How to get information from another intent? -

i new on android , don't understand how broadcast receiver works. in app have intent extends broadcast receiver, , have xmlfile edittextpreference. how text on xml file broadcast receiver intent? this xmlfile(res/xml/prefs.xml): <?xml version="1.0" encoding="utf-8"?> <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android" > <edittextpreference android:title="edittext" android:key="name" android:summary="enter name" /> </preferencescreen> you can add information intent this: intent = new intent(); i.putextra("preferencestext", textyoumeantosend); and in broadcast reciever can call string: getintent().getstringextra("preferencestext", somedefaultvalue); edit from http://developer.android.com/reference/android/content/broadcastreceiver.html a broadcastreceiver receive callbock on onreceive(co

php - preg_repalce matched partial data with correct regex -

this question has answer here: “unknown modifier 'g' in…” when using preg_match in php? 1 answer $str = b c; $str = preg_replace("/a|b|c\","" $str); above regex matched a, b , c excluded. @ first thought caused gobal thing, after researched preg_match has default global enabled. has gone wrong? you'll need quotes around string: $str = "a b c"; ...a comma between replacement text , source, , flip closing regex slash match opening one: $str = preg_replace("/a|b|c/", "", $str); that leave $str set [space][space]

javascript - Does not show error when registering on website PHP -

i have database setup , i'm making site user has register username, email , password. however, reason, whenever click on register without entering information, still registers database without showing error. here code. <?php // first execute our common code connection database , start session require("common.php"); // if statement checks determine whether registration form has been submitted // if has, registration code run, otherwise form displayed if(!empty($_post)) { // ensure user has entered non-empty username if(empty($_post['username'])) { // note die() terrible way of handling user errors // this. better display error form // , allow user correct mistake. however, // exercise implement yourself. $username_error = "please enter username"; } // ensure user has entered non-empty password if(empty($_post['password'])) { $password_error = "please ent

node.js - async waterfall callback isn't called within mongoose save -

i'm using express, mongoose, , async. within update method on controller, i'm calling following: //note: we're within constructor's prototype method, hence 'self'. body request body. async.waterfall([ function(callback) { self.collection.findbyid(body._id).exec(function(err, item) { if(item) { callback(null, item); } else { callback(err); } }); }, function(item, callback) { //callback(null, item); //makes task work, not need //merge 2 models together, save item.save( _.extend(item, body), function(err, item) { console.log('code here never seems called within waterfall'); callback(null, item); }); } ], function(err, results) { console.log('hello', err, results); self.res.json(results); });

android - AndroidKeyStore wiped out after device password change -

i working on android application based on client-server architecture. data security, using public-private key pair data encryption , signing. using androidkeystore storing key pair. below code generate key pair: keypairgeneratorspec spec = new keypairgeneratorspec.builder( mcontext) .setalias(mprivatekeyalias) .setsubject(new x500principal("cn=" + mprivatekeyalias)) .setserialnumber( biginteger.valueof(system.currenttimemillis())) .setstartdate(start.gettime()) .setenddate(end.gettime()).setkeysize(2048).build(); keypairgenerator kpgenerator = keypairgenerator.getinstance( "rsa", "androidkeystore"); kpgenerator.initialize(spec); // key pair saved in androidkeystore keypair pair = kpgenerator.generatekeypair(); after executing code, keystore releated files (cert , pkey files) generated @ '/data/misc/keystore/user_0/' directory. encrypting application sensitiv

javascript - How to access newly created elements by pure js? -

i made 'warning' layer use instead of 'alert()'. code : warning = document.getelementbyid('warning'); // line want make functional. code out side of warning(); line runs before 'elem:div#warning' made warning(). function warning() { = document.createelement('div'); document.body.appendchild(a); a.id = 'warning'; a.classname= 'warning'; } but don't know how access newly created , added element javascript. i think css works fine newly added elements. js not. i searched google, , found methods register newly created element automatically using prototype, hard understand me... so, trying is, access newly created element 'a' javascript executed before 'a' created. i tried method : if(document.getelementbyid('warning')) {alert('asdf')}; but useless... try fiddle , works me, did small change. function warning() { = document.createelement('div'); document.bo

openfire - How to remove self from memberlist in XMPP -

in openfire using xmpp, when create persistent room, users can add if invited. when send invite user room joining join using: <presence from="jid@hostname.com/resource" to="groupname@servicename.hostname.com/nickname"> <x xmlns="http://jabber.org/protocol/muc" /> </presence> the newly added participant member of room. when want leave room, use <presence type="unavailable" to="groupname@servicename.hostname.com" from="jid@hostname.com" > using leaves room not getting deleted memberlist of room. how remove memberlist? i requesting member list with: <iq from='crone1@shakespeare.lit/desktop' id='member3' to='coven@chat.shakespeare.lit' type='get'> <query xmlns='http://jabber.org/protocol/muc#admin'> <item affiliation='member'/> </query> </iq> or in openfire there link: group chat ->

c# - set multiple values to combobox -

i have combobox multiselect option , want set multiple value codebehind , here store : <ext:store id="storet" runat="server" pagesize="10"> <model> <ext:model id="model3" runat="server"> <fields> <ext:modelfield name="name" /> <ext:modelfield name="code" /> </fields> </ext:model> </model> </ext:store> <ext:combobox id="comboboxt" multiselect="true" storeid="storet" displayfield="name" valuefield="code"> </ext:combobox> i want pass setvalues multiple codes selected @ same time . please use combobox's selecteditems. <%@ page language="c#" %> <script runat="server"> protected void page_load(object sender, eventargs e) {

java - Artifacts disappearing from maven central? -

over course of last few hours, following artifact seems have disappeared maven central: groupid: org.apache.jena artifactid: jena-jdbc version: 1.1.0 it there, project building fine, of sudden: $ curl -i "http://repo.maven.apache.org/maven2/org/apache/jena/jena-jdbc/1.1.0/jena-jdbc-1.1.0.jar" http/1.1 404 not found server: nginx content-type: text/html content-length: 168 accept-ranges: bytes date: mon, 22 sep 2014 08:55:35 gmt via: 1.1 varnish connection: keep-alive x-served-by: cache-iad2121-iad x-cache: miss x-cache-hits: 0 x-timer: s1411376135.762460,vs0,ve53 what's going on here? mysteriously come back? can cause happen? has seen before? fwiw: workaround easy, download , install locally... why did go away? i think have wrong url. didn't mean e.g. jena-jdbc-core? http://repo1.maven.org/maven2/org/apache/jena/jena-jdbc-core/1.1.0/

java - MalformedURLException on reading file from HDFS -

i have following test program read file hdfs. public class filereader { public static final string namenode_ip = "172.32.17.209"; public static final string file_path = "/notice.html"; public static void main(string[] args) throws malformedurlexception, ioexception { string url = "hdfs://" + namenode_ip + file_path; inputstream = new url(url).openstream(); inputstreamreader isr = new inputstreamreader(is); bufferedreader br = new bufferedreader(isr); string line = br.readline(); while(line != null) { system.out.println(line); line = br.readline(); } } } it giving java.net.malformedurlexception exception in thread "main" java.net.malformedurlexception: unknown protocol: hdfs @ java.net.url.<init>(url.java:592) @ java.net.url.<init>(url.java:482) @ java.net.url.<init>(url.java:431) @ in.ksharma.hd

node.js - Dealing with MySql pooling and nodejs -

i run web server written in nodejs/ express deals mysql db. in order more efficient, use pooling mechanism of node-mysql. an still issues : - connection lost - cannot release release connection - there no release of undefined depending on request, various code pattern can used data , release connection : 1/ standard callback ..., function(err, rows){...} - may understood, release shall done before callback ? please confirm me ! - may use release @ first line of call function ? (because may have many case in case various callback. 2/ event - put connection.release in both events .on('error') , .on('end') . enough ? - happen if error called on 10th rows. both event called ? think not, got issue (can,not release release connection) following code : pool.getconnection(function(err, mysqlconnection) { if (err != null) { console.log(err); } else { mysqlconnection.query('use table'); var

Scala: detect cyrillic and latin characters in string? -

please simple scala method allows to: detect if string contains @ least 1 latin character detect if string characters latin detect if string contains @ least 1 cyrillic character detect if string characters cyrillic so far tried: scala> val pattern = new regex("[a-za-z]") pattern: scala.util.matching.regex = [a-za-z] scala> val s = "john" s: string = john scala> pattern findfirstin s res22: option[string] = some(j) thanks! here go 1. 1 latin char scala> ("[a-za-z]".r findfirstin "munich").isdefined res22: boolean = true 2. latin char scala> "munich".tolist.forall(c => ( c >= 'a' && c<= 'z') || (c >= 'a' && c <= 'z') ) res27: boolean = true 3. @ least 1 cyrillic char: ("\\p{iscyrillic}".r findfirstin "Москва").isdefined res5: boolean = true 4. chars cyrillic: val moscow = "Москва" "\\

xcode - UIImageview Fade -

i trying image fade out , fade in when click on button. there wrong code? image stays visible when click on button. - (ibaction)alpha:(id)sender { [uiview beginanimations:nil context:null]; [uiview setanimationcurve:uiviewanimationcurveeasein]; [uiview setanimationduration:2]; _image.alpha = 1; [uiview commitanimations]; [uiview setanimationdidstopselector:@selector(animationdidstop:finished:context:)]; } -(void)animationdidstop:(nsstring *)animationid finished:(nsnumber *)finished context:(void *)context { [uiview beginanimations:nil context:null]; [uiview setanimationduration:2]; _image.alpha = 0; [uiview commitanimations]; } you calling methods on uiview, class, not on instance of uiimageview want fade. you'll want like [self.myimageview beginanimations....

closures - Grails Criteria querying a list with ilike -

i want query list in criteria this: def patterns = ["abc%", "cde%"] def criteria = myentity.createcriteria(); def results = criteria.list { , { patterns.collect { not { ilike(name, it) } } } is possible? have query working? instead of collecting create collection of contents need iterate. def patterns = ["abc%", "cde%"] def criteria = myentity.createcriteria(); def results = criteria.list { , { patterns.each { not { ilike('name', it) } } }

Unable to install Linux font libraries - they freeze when accepting EULA -

i have tried build app in qt 4.8 while experimenting rebuilding qt statically, installed freetype... though realize there version installed. maybe culprit... something must have happened system fonts... have weird , unusual fonts available application. abyssinica sil - font starts "a" found info installing them, either apt-get or found deb package sudo apt-get --reinstall install msttcorefonts sudo apt-get --reinstall install ttf-mscorefonts-installer https://launchpad.net/ubuntu/quantal/i386/ttf-mscorefonts-installer - deb package either method gives me eula @ bottom - not clickable - , locks dpkg. how install fonts , bypass eula ? i able accept eula pressing tab highlighted <ok>

Actionscript 3 Playing videos back to back with in a sequence with no break inbetween -

i'm wondering @ possiblitity of setting array of videos play play absolutely no pause in between? there anyway set there no way to have buffering or pause in between sequential playback? example: import flash.events.netstatusevent; var videos:array = new array("ad01.flv", "ad02.flv", "ad03.flv"); var currentvideo:uint = 0; var duration:uint = 0; var ready:boolean = true; var nc:netconnection = new netconnection(); nc.connect(null); var ns:netstream = new netstream(nc); myvideo.attachnetstream(ns); ns.play(videos[currentvideo]); var listener:object = new object(); listener.onmetadata = function(evt:object):void { duration = evt.duration; ready = true; }; ns.client = listener; ns.addeventlistener(netstatusevent.net_status,nshandler ); function nshandler(evt:netstatusevent):void { if (ready && ns.time > 0 && ns.time >= (duration - 0.5)) { ready = false; currentvideo++; if (currentvideo < videos.length) { ns.play(videos

jquery - Need help refactoring JavaScript code to be easier to modify, maintain, and to be more robust -

the search page has lots of facets tracked breadcrumbs, additional sections can added narrow searches, saving of searches, result counts update in real-time, lots of stuff. i'm using javascript , jquery ui stuff, , code mash of functions , big ol' document ready function. when search triggered, criteria gathered based on shown in ui. example of facets, literally @ crumbs shown , @ data()/text/class/etc. determine criteria. what need how organize , design code type of application. don't have 1 coherent question, i'll make attempt @ few. is okay practice treat dom element object in say, java? example have breadcrumb, div. have functions creating crumbs, removing them, etc. treat text , data() fields of object. continuing off previous example, don't have crumb javascript object. should i? best way keep association between object , element, since these being created , deleted. slightly tangential, suggestions testing? nothing i've done unit tested doesn&#

Go escape comma in JSON -

http://play.golang.org/p/lf2zgayxei how escape comma in json tag in go? type aa struct { mystr string `json:"sub,ject"` } func main() { jsonstr := ` { "sub,ject": "i" } ` stt := new(aa) json.unmarshal([]byte(jsonstr), stt) fmt.println(stt) t, _ := strconv.unquote(jsonstr) fmt.println(t) } this not grab key , returns empty results. how escape comma? the code used json encoding package parse field tags in tags.go . code splits field name options @ first comma. not possible escape comma.

javascript - Mongoose update subdocument of subdocument -

my schema definition below. userschema has embedded cards in turn has many transactions.. var transactionschema = new schema({ merchantname: string, transactiontime: date, latitude: number, longitude: number, amount: number }); var cardschema = new schema({ cardissuer: string, lastfour: string, expirationdate: string, transactions : [transactionschema] }); /* * ...user schema... */ var userschema = new schema({ name: string, email: { type: string, lowercase: true }, role: { type: string, default: 'user' }, hashedpassword: string, provider: string, salt: string, imageurl: string, phonenumber: string, card: [cardschema] }); i want add transaction card in userschema not sure how in mongoose / mongodb i identify user , card follows.. the api call goes through auth middleware first function isauthenticated() { return compose() // validate jwt .use(function(req, res, next) { // allow access_token passed

css - Use function/mixin in Less selector -

i need repeat selector. there way in less css function/mixin? note: content of frame different. .slide1{ .frame{ .obj1{} .obj2{} .obj3{} } [data-fragment=1].active ~ .frame { .obj1{} .obj2{} /* frame1 css */ } [data-fragment=2].active ~ .frame { .obj2{} .obj3{} /* frame2 css */ } /* other frames ... */ } .slide2{ /* slide2 css */ } /* other slides ... */ to .slide1{ .frame{/* ... */} .frameselector(1){/* frame1 css */} .frameselector(2){/* frame2 css */} } .slide2{/* slide2 css */} yes, can form selector dynamically using mixin below. mixin accepts 2 parameters out of 1 frame number selector has generated , other set of rules (ruleset) applicable frame. passing rulesets mixins introduced in less v1.7.0 , hence code not work lower versions of less compiler. note: if properties/rules frames had common pieces can reduced further using loops, since different have pass ruleset corresponding each f

python - SQLAlchemy, select such A that has at least one B with raised flag -

i have 2 tables: class a(base): id = column(integer, primary_key=true) class b(base): id = column(integer, primary_key=true) a_id = column(integer, foreignkey('a.id')) = relationship(a) flag = column(boolean, default=false) as can see - each object b related 1 object a, also, more 1 object b can related single object a. need select a's have @ least 1 related b flag == false. i'm thinking on this: selection = session.query(a).\ join(b).\ filter( b.a_id == a.id, b.flag == false, ).\ group_by(a) but i'm not sure 2 things: if query correct? (i'm working huge amounts of data , it's quite complicated test out). if query correct point of sqlalchemy philosophy? (i'm newbie it). add backref relationship: class b(base): # ... = relationship(a, backref="b_s") then sqlalchemy verino of @erwin's sql version below: qry = session.

html - ionic dropdown select issue -

Image
i'm new ionic , have problem ionic dropdown select component.i've implemented dropdown , want display option selected in label.how can this? @ moment can select option , that's it. want show selected option in label. here want display option selected in "select bank label". this how implemented dropdown select component <label><h4><b>bank name*</b></h4></label> <div class="list"> <div class="item item-input item-select"> <div class="input-label"> select bank </div> <select> <option>bank1</option> <option>bank2</option> <option>bank3</option> </select> </div> </div> add model select. create variable on scope can use elsewhere. <select ng-model="myvariabl

Accessing "Spring MVC" application from a "Java EE Dynamic Web" application -

we have 2 applications 1 java ee dynamic web application accessed internet complex authentication mechanism. second 1 new application built on spring mvc framework (3.0 above). both applications deployed on same server. now need access details (like employee details based on employee id) new spring application java ee web application. i.e using method call new spring application java ee web application passing parameters ( empid ) , update details, etc. we not planning re-authenticate again new spring application. can 1 please how achieve this? you must configure both of applications use same session store in server. when querying new spring application can pass url following; http://<host>:<port>/newapplication/user/1?jsessionid=<javaeeapplicationsessionid> where javaeeapplicationsessionid current jsessionid logged using java ee application. way new spring application jsessionid in shared session store , not ask re-authenticate can fi

java - How to display selected columns of database in a Jtable? -

i populated jtable contents of database table want show selected columns of it. there way of doing this? or possible select column display in jtable ? here method of populating jtable private void update_table() { try { string sql = "select * members"; ps = conn.preparestatement(sql); rs = ps.executequery(); members_table.setmodel(dbutils.resultsettotablemodel(rs)); } catch (exception e) { joptionpane.showmessagedialog(null, e); } } my database table name "members". "members_table" name of jtable . you try changing sql statement select columns interested in. instance, if members has columns "memberid", "memberfirstname", "memberlastname" "memberaddressfk", , wanted display memberfirstname , memberlastname, change sql string sql = "select memberfirstname, memberlastname members"; you can find m

linux counting characters then output number of characters in a string entered by user and it also needs a while loop -

i have been trying linux count characters in string , out put them want user able enter string , amount of characters in string outputed have limited understanding of linux need thank you! so far have got this: #!/bin/bash x="this test" y="${x//[^s]}" echo "$y" echo "${#y}" but 1 type of character , it's not in while loop allow user quit if wan if can appretiated an example input "i pie" want program output "the string have entered has 10 characters you can use read input user , use ${#var} length: #!/bin/bash read -p "enter input text: " input echo "# of chars in input: ${#input}"

linux - php exec with sudo fails on CentOS -

i running centos 6, httpd executed user 'apache'. security reasons, want use sudo executed via exec user 'aq': <?php exec("/usr/bin/sudo -u aq somescript.sh",$output,$return_val);?> with visudo have added following line: apache = (aq) nopasswd: furthermore temporary gave apache login shell (/bin/bash), able test /usr/bin/sudo -u aq somescript.sh directly worked. php exec fails $return_val delivers '1' if sudo invoked. comment out line /etc/sudoers defaults requiretty i'v tested case in few ways ant 1 gives me success.

apache cayenne - Data lost during SelectQuery -

example: s i've got object of class in relationship objects b, c , d. if do: selectquery query = new selectquery(a.class); query.addprefetch("b").setsemantics(prefetchtreenode.disjoint_prefetch_semantics); query.addprefetch("c").setsemantics(prefetchtreenode.disjoint_prefetch_semantics); list<?> res = context.performquery(query); then later: selectquery query = new selectquery(a.class); query.addprefetch("d").setsemantics(prefetchtreenode.disjoint_prefetch_semantics); list<?> res = context.performquery(query); the relationships b , c invalidated (see datarowutils line 115). i'm using cayenne 3.0.2 behavior seems identical in versions 3.1 , 3.2m1 is there way work around issue? my idea override cayennedataobject in class function: public void writepropertydirectly(string propname, object val) { if(propname.equals("b") || propname.equals("c")) { if(val instanceof fault && readp

ArcGIS Javascript API - addLayers -

i working on project trying add feature layers arcgis online web map application using javascript api user can toggle layers on , off through html tick box. layers importing correctly , displayed when tick boxes bypassed can work tickboxes. have hacked code arcgis samples etc must small thing keep missing! here code - want layers toggle on , off on top of constant base map based on checkboxes user ticks on , off <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <!--the viewport meta tag used improve presentation , behavior of samples on ios devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>select feature layer</title> <link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/tundra/tundra.css"> <link rel="styles

java - How to speed up queries in sqlite android in db.execSql -

i have following code use enter data in database. public static void execsql(sqlitedatabase db, string sql) { string[] parts = sql.split(";"); (string entry : parts) { db.execsql(entry); } } initially "insert ......" in sql string, execute each insert cycle. total insert 22908. data input 4 minutes, think long time. data 7,95 mb. there way speed introduction , bring seconds ? insert location ( 'latitude' , 'updated' , 'id' , 'longitude' , 'created' ) values( '213.2000000' , '2014-08-25 11:07:42+00:00' , '1' , '321.0000000' , '2014-08-25 11:07:42+00:00' ); insert location ( 'latitude' , 'updated' , 'id' , 'longitude' , 'created' ) values( '42.7191000' , '2014-09-17 12:53:49+00:00' , '2' , '23.0834000' , '2014-09-17 12:53:49+00:00' ); ...................... here data sql varia

asp.net - I am unable to connect to a database. I have an error "Underlying provider failed to open" -

i unable connect database. have error "underlying provider failed on open". connection string <connectionstrings> <add name="elementcontext" connectionstring ="server=.; database=element; integrated security = sspi" providername="system.data.sqlclient"/> </connectionstrings> the controller using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc; using model_class_implementation.models; namespace model_class_implementation.controllers { public class elementcontroller : controller { public actionresult element_details() { elementcontext elementcontext = new elementcontext(); element element = elementcontext.elements.single(elem => elem.element_id == 1); return view(element); } } } the class contains dbcontext is using system; using system.collections.generic; using system.linq; using

objective c - Remote notifications for iOS 8 -

in notifications app not registred son , badge. this code: - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions: (nsdictionary *)launchoptions { //-- set notification if ([[[uidevice currentdevice] systemversion] floatvalue] >= 8.000000) { uiusernotificationsettings * settings = [uiusernotificationsettings settingsfortypes:uiusernotificationtypealert | uiusernotificationtypebadge | uiusernotificationtypesound categories:nil]; [[uiapplication sharedapplication] registerusernotificationsettings:settings]; [[uiapplication sharedapplication] registerforremotenotifications]; } else { //[[uiapplication sharedapplication] registerforremotenotificationtypes:(uiusernotificationtypebadge | uiusernotificationtypesound | uiusernotificationtypealert)]; [[uiapplication sharedapplication] registerforremotenotificationtypes:(uiremotenotificationtypebadge | uiremotenotificationtypesound | uiremotenotificationty