Posts

Showing posts from September, 2013

Rails 4 - Mapping a model dynamically on two different database tables -

i have multi domain app talking legacy database. in db have 2 tables different names, lets call them user_a , user_b . structure , data types same, difference data different domains. now, have single scaffold (model/controller/view) that, depending on domain, maps right db table. domain work model/controller called user maps internally db table user_a , , domain b work same model/controller user maps table user_b . i use resource :user in routes access model rails way. so somehow need overwrite model on initialization not quite sure how go it. how 1 go using rails activerecord? i don't have multitable db ready test with, educated guess @ solution: # respective models class user < activerecord::base end class domainauser < user self.table_name = "user_a" end class domainbuser < user self.table_name = "user_b" end # controller def set_user @user = if request.subdomain(0) == "domaina" domainaus...

Java MySQL Iterate Backwards through ResultSet -

i've executed query returns resultset of data iterate backwards over. in loop this: for (int = max; >=0; i--){ // } the problem don't have a column in db sequential, instead have id unique, skips numbers. so, using actual result set, there way can while(set.next()) {...} in reverse? thanks. you can traverse resultset backwards if have scrollable resultset.you can doing resultset.type_scroll_insensitive , resultset.concur_read_only when creating statement. then can use resultset.last() last entry , traverse backwards using resultset.previous() edit: if want results in descending order of non-sequential ids mentioned, can retrieve resultset in descending order doing order id desc , traverse resultset normally

Android strange behavior with android:top & android:right in defined shape -

Image
i have shape : <item> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#000000"></solid> </shape> </item> <item android:top="12dp" android:bottom="12dp"> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners android:radius="15dp"></corners> <solid android:color="#000000"></solid> <stroke android:width="5dp" android:color="#ffffff"></stroke> <padding android:bottom="12dp" android:left="12dp" android:right="12dp" android:top="12dp" /> </shape> </item> which look...

Why hiding method not work in c# -

this question has answer here: overriding vs method hiding [duplicate] 3 answers consider code: public class { public void method1() { console.writeline("a.method1"); } public virtual void method2() { console.writeline("a.method2"); } } public class b : { public new void method1() { console.writeline("b.method1"); } public override void method2() { console.writeline("b.method2"); } } and this: b b = new b(); b.method1(); b.method2(); console.writeline("*********************"); a = b; a.method1(); a.method2(); this result: b.method1 b.method2 a.method1 b.method2 my question why when call a.method1() a.method1 instead of getting b.method1.and why method hiding not work. note line:a = b ...

select - Socket data read wait time -

i have application listening on multiple sockets using select . if start processing request came in socket , in meanwhile if request on socket b arrives want know how long socket b request had wait before it. since single threaded application cannot spawn new thread , go select monitor again , instantly start processing request socket b. is there 'c' api available me metric or not possible get? there no straightforward way how measure interval between 'data ready' time , 'data read' time because there not timestamp written data. situation more complex because stream oriented socket may receive several data segments till select closed , not interval should measured. if application data processing longer packet processing in kernel can reasonable measurement in following way: print current time , unique data id based on application protocol when select wakes due socket b data availability. log packet received socket b. can use either network ...

jquery ui draggable with iframe wrong droppable position handle -

i'm having issue jquery ui drag/drop. need drag element iframe contains droppable area inside. when drag item on left side , drop iframe, didnt work expected. looks fiddle: jsfiddle.net/8jwxv/66/ js $('#my-frame').load(function () { $('.draggable').draggable({ appendto: 'body', helper: 'clone', iframefix: true, revert: 'invalid', connecttosortable: $('#my-frame').contents().find('.sortable'), cursorat: { top: 10, left: 0 }, drag: function(event,ui){ console.log(ui.offset); } }); $('#my-frame').contents().find('.sortable').sortable({ iframefix: true, cursorat: { top: 0, left: 0 } }); }); $('.draggable').on('dragstop',autoresize); function autoresize(){ var newheight; if(document.getelementbyid){ newheight=document.getelementbyid('my-frame').contentwind...

FATAL EXCEPTION on retrieving a Drawable or color only on Android < 4.0 -

i'm trying fix app , can't figure out what's problem. problem when run app on android version < 4.0 guess problem appcompat, have no idea how fix it. error when run this: 07-30 09:40:44.726 14081-14081/my.app.pag e/androidruntime﹕ fatal exception: main java.lang.runtimeexception: unable start activity componentinfo{my.app.pag/my.app.pag.mainactivity}: android.view.inflateexception: binary xml file line #2: error inflating class textview @ android.app.activitythread.performlaunchactivity(activitythread.java:1651) @ android.app.activitythread.handlelaunchactivity(activitythread.java:1667) @ android.app.activitythread.access$1500(activitythread.java:117) @ android.app.activitythread$h.handlemessage(activitythread.java:935) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:123) @ android.app.activitythread.main(activitythread.java:3687) ...

java - Hibernate update child from parent, joined column is not specified in generated sql query condition -

parent product entity, , child stock entity distinguished time(like hotel stock model stock of every booking day should different , manipulated separately) the productentity defined as: @entity @table(name = "product") public class productentity{ .... private long productid; private list<stockentity> stockentitylist; .... @id @column(name="productid") public long getproductid(){ return this.productid; } @onetomany(mappedby="productentity", fetch= fetchtype.eager cascade={cascadetype.all,cascadetype.persist,cascadetype.merge}, orphanremoval = true) public list<stockentity> getstockentitylist(){ return this.stockenitylist; } public void setstockentitylist(list<stockentity> stockentitylist){...} .... } and stockentity defined as: @entity @table(name = "stock") public class stockentity{ ...

2D android game Development tool in Linux OS -

i plan start making simple 2d android mobile game, i'm using linux ubuntu operating system... want ask how should start , software , game engine can use in linux os? you can use unity game engine has support android , easy start , learn https://unity3d.com has support , popular game engine , can use linux os. unity works on linux ubuntu on wine quit well.

After installation of github plugin into jenkins, restart not responding and showing errors -

even remove github plugin jenkins not working. running under tomcat7 server. hudson.util.hudsonfailedtoload: org.jvnet.hudson.reactor.reactorexception: java.io.ioexception: unable read /usr/share/tomcat7/.jenkins/config.xml @ hudson.webappmain$3.run(webappmain.java:237) caused by: org.jvnet.hudson.reactor.reactorexception: java.io.ioexception: unable read /usr/share/tomcat7/.jenkins/config.xml @ org.jvnet.hudson.reactor.reactor.execute(reactor.java:269) @ jenkins.initreactorrunner.run(initreactorrunner.java:44) @ jenkins.model.jenkins.executereactor(jenkins.java:914) @ jenkins.model.jenkins.<init>(jenkins.java:813) @ hudson.model.hudson.<init>(hudson.java:83) @ hudson.model.hudson.<init>(hudson.java:79) @ hudson.webappmain$3.run(webappmain.java:225) caused by: java.io.ioexception: unable read /usr/share/tomcat7/.jenkins/config.xml @ hudson.xmlfile.unmarshal(xmlfile.java:165) @ jenkins.model.jenkins$16.run(jenkins.java:2642) @ org.jvnet.hudson.reactor.taskgraphb...

php - Laravel - override default facade bindings - how? -

http://laravel.com/docs/5.1/facades facades listed on linked page @ bottom. question is... how override these service container bindings? example, request facade binds illuminate\http\request key request . want create own class inherits illuminate\http\request , bind request key, instead of current class. , can't find service provider binds this. so, kind of did it. first noticed these bindings hardcoded in illuminate\foundation\application::registercorecontaineraliases() extended class , overrode method change it. had call class in bootstrap\app.php , doing didn't help, still getting instance of illuminate\http\request . so discovered illuminate\http\request directly referenced in public\index.php tried changing there my\very\own\http\request , worked, implementation being used. finally, deleted version of application::registedcorecontaineraliases() , reverted bootstrap\app.php because working without change.

json ld - Adding a 'license' field to a schema.org Place record -

i have database of locations publish open data. each record can have 1 of several licenses depending on data sourced each record needs have license attached. i'm publishing data json-ld . sample record: { "@context": "http://schema.org", "@type": "place", "name": "metropolitan museum of art", "address": { "@type": "postaladdress", "streetaddress": "1000 5th ave", "addresslocality": "new york", "addressregion": "ny", "addresscountry": "united states", "postalcode": "10028-0198" }, "hasmap": "http://www.openstreetmap.org/?mlat=40.7784&mlon=-73.9627#map=15/40.7784/-73.9627", "geo": { "@type": "geocoordinates", "latitude": 40.7784, "longitude": -73.9627 }, "descr...

html - Trying to make my header image cover left, top, and right sides in CSS -

how can remove edges, or enhance header image cover left, top , right. project link on codepen: http://codepen.io/arizonawarriorone/pen/mjjbqm .masthead-heading, .masthead-intro { text-align: center; } .masthead { padding: 10em 0; } .masthead-intro { margin-bottom: 0.1em; } .masthead-heading { margin-top: 1.2em; } .masthead { background-image: url('http://jmdarter.com/wp-content/uploads/2012/11/sonoran-sunset-flare.jpg'); background-size: cover; border-top: 2em solid #ff6600; background-position: center; } <header class="masthead"> <p class="masthead-intro">hi, i'm</p> <h1 class="masthead-heading">tim</h1> </header> <section> </section> <section> </section> <section> </section> <footer> </footer> the body element has 8px margin around default in browsers , white space appear a...

sql - How do I get a value from a column comprising of multiple values separated by semicolon in teradata -

i have column mentioned below , need value of "cg" using teradata sql: cat=0;cg=dbeca43414a0a5f16431a3e1ff446252;eb_trk=5 cat=20349;cat=15032;cat=9394;cg=578b0f761490a5f164 cat=9355;cat=15032;cg=975f70b714d0a2b143a56055fbfd cat=42428;cat=15032;cg=bceb58e114a0a5f165405b20f7f cat=9355;cat=15032;cg=d93dfc1714c0a5616b212801fd73 i believe regexp_substr() in teradata same same function in oracle. following should work: select regexp_substr(regexp_substr(col, 'cg=[^;]+', 1, 1), '[^=]+', 1, 2) here sql fiddle oracle version.

linux - Vlc Check Stream Status -

i using vlc rebroadcast stream , side of things working well. after few hours however, need re authenticate , re-request stream. have script needs run , handle re-authentication , starting vlc. problem having how figure out if stream no longer working. when using say: pidof vlc i pid of process vlc. when checking top, can see vlc running , consuming cpu. however, when try play stream nothing happens. if run script again, stream restarts , can watch again. if stream has stopped, vlc continues run giving me no indication of whether stream running or vlc. the thing have spotted far when stream not running cpu usage seems spike according top . when stream running, cpu usage around 1% mark, when not running seems spike past 40%. have observed couple of times, can assume potentially way ensure stream running, not 100% confident in approach. does have knowledge on how confirm if actual stream running or if vlc process? should give credits @mundu here script created ...

database - How to insert large string in SQL Server -

i'm trying insert large string nvarchar(max) column, after inserting found, string cut. there 43601 characters stored. what wrong? it stores complete string when use select statement sql interface display number of characters...you can try reading thru .net/java or try getting data thru substring().. should see complete data...

Google Maps: Find all zip codes along route -

given 2 locations can calculate route in google maps. is possible find zip codes along route? given zip code, can expand area 10 km radius , find zip codes in area? what methods should use information? tutorials welcome. don't need complete working solution, although if 1 available nice. you need data source containing zipcode (zcta) polygons. 1 possible source this fusiontable . proof of concept proof of concept showing zcta polygons note: since queries zip code @ every point along route, take longer finish longer route is. code performs query (using google visualization api): function queryforzip(latlng) { //set query using current latlng var querystr = "select geometry, zip, latitude, longitude "+ tableid + " st_intersects(geometry, circle(latlng"+latlng+",1))"; var querytext = encodeuricomponent(querystr); var query = new google.visualization.query('http://www.google.com/fusiontables/gvizdata?tq=' ...

java - Spring JsonProcessingExceptin NoClassDefFoundError for rest template -

i using jackson parser, , works rest template when requesting when try post gives me following error: web.util.nestedservletexception: handler processing failed; nested exception java.lang.noclassdeffounderror: com/fasterxml/jackson/core/jsonprocessingexception i don't know went wrong. i'm trying send post request , body should object: @requestmapping(value = "dogcreated", method = requestmethod.post) @responsestatus(httpstatus.created) public string createdog(@modelattribute dog dog, bindingresult result, model model){ resttemplate rest = new resttemplate(); // list< httpmessageconverter<?> > messageconverters = new arraylist< httpmessageconverter<?> >(); // // empty list created // // messageconverters.add( new mappingjackson2httpmessageconverter() ); // messageconverters.add( new stringhttpmessageconverter() ); rest.getmessageconverters().add(new mappingjackson2httpmessageconverter());/*this ...

PayPal PHP SDK API - Get all Transactions -

i want use paypal php sdk api list payments/transactions. sandbox credentials i`m successfully, if switch live credentials result just: { "count": 0 } ...yes im switching live with: $apicontext->setconfig(array('mode' => 'live')); what failure? here full code: <?php // 1. autoload sdk package. include files , classes autoloader require __dir__ . '/autoload.php'; $apicontext = new \paypal\rest\apicontext( new \paypal\auth\oauthtokencredential( 'abc', // clientid 'def' // clientsecret ) ); $apicontext->setconfig(array('mode' => 'live')); #$apicontext = new \paypal\rest\apicontext( # new \paypal\auth\oauthtokencredential( # 'xyz', // clientid # 'xyzz' // clientsecret # ) #); // test //require 'createpayment.php'; //use paypal\api\payment; $payment = new \paypal\api\payment(); try { $params = array...

javascript - Variable name length vs performance -

how possible, huge difference in variable name length won't cause any performance loss in javascript? it tooks same time declare var = 0; takes declare var aaaaaaaaaaaaaaa = 0; tooks same time execute computations them. my fiddle demonstrate based on @cerbrus's comment: it causes negligibly small performance difference in practise, when declaring variable. afterwards, gets specific address in memory , , referred address, not variable name, won't affect performance anymore. however, talking scripting language used on web, shorter variable names can reduce filesize, , speed pageloads. 1 of features of js compilers, such google's .

wordpress - Disable visual editor based on role? -

i want disable visual editor form 'author' role form wordpress site. author see text editor when write post. you can use user_can_richedit filter tell wp disable rich editor author through code (put inside functions.php file): $user = wp_get_current_user(); if ( in_array( 'author', (array) $user->roles ) ) { add_filter( 'user_can_richedit' , '__return_false', 50 ); }

ios - Thread that work in background of project until the end of program -

i need write thread work in background of project. when should create , , example in appdelegate or others? if want run thread when user job,for example when click on button run thread work in background until end of program,for should do? in ios, program never ends unless crashes or user turns phone off. running "until end of program" very, long time. users not thank emptying battery. it asking far not best possible solution, , rejected if want put app app store. should explain trying achieve. in case posted wrong question, answer "use gcd". if don't know gcd is, google , apple's documentation friend.

php - Site running by the host entry -

i running 1 site host entry , pointing out server. for example, my site www.example.com , did host entry , pointing xxx.xxx.xxx.xxx ip. when run url browser pointing new ip correctly internal urls, javascripts , images calling it's original old server. is server configuration issue or else ? in technology website built with. may internal urls, javascripts , images stored in database in wordpress cms?

javascript - Gulp.src ignore option -

i can't ignore option of gulp.src working: 'use strict'; var gulp = require('gulp'); var debug = require('gulp-debug'); var config = { src: 'app/**/*.js', test: 'app/**/*.test.js' } gulp.task('default', function() { return gulp. src(config.src, {ignore: config.test}). pipe(debug({title: 'debug'})); }); output: [01:33:38] using gulpfile ~/projects/gulp-src/gulpfile.js [01:33:38] starting 'default'... [01:33:38] debug app/src.js [01:33:38] debug app/src.test.js [01:33:38] debug 2 items [01:33:38] finished 'default' after 19 ms according gulp api documentation, option object passed node-glob, has documented ignore option why code not work expected? misunderstanding something? use ignore option in favour of "!whatever/**" pattern. gulp not pass through ignore option (it ignores ignore :-). instead, gulp has own negation ( ! ) implementation, should use instead. thi...

javascript - Overriding parent model loading in nested Ember.js route -

i'm learning ember , trying figure how signup form. i have /users route before , have created users/new route. in users route load users store - , users/new route load users - not needed. should create separate users/index.js route index or there way override parent model loading should using? // app/router.js import ember 'ember'; import config './config/environment'; var router = ember.router.extend({ location: config.locationtype }); router.map(function() { this.resource('users', function() { this.route('new'); }); this.route('users', function() { this.route('new'); }); }); export default router; // routes/users.js import ember 'ember'; export default ember.route.extend({ model: function(){ return this.store.findall('user'); } }); // routes/users/new.js import ember 'ember'; export default ember.route.extend({ model: function(){ return this.store.cr...

angularjs - Generating loopback models after generating looback-angular-services? -

i've generated angular services database using loopback-lb-services , want make changes in database. so want know how can change it. because i've read after changing tables lb-services drop. please let me know how this. you need run lb-ng again updates. can automate using build system gulp (see https://github.com/strongloop/gulp-loopback-sdk-angular ).

Python - UnboundedLocalError -

import random def hilo(usernum, ran, c): c = c + 1 if ran > usernum: newnum = input("higher: ") hilo(int(newnum), ran, c) elif ran < usernum: newnum = input("lower: ") hilo(int(newnum), ran, c) else: print("that's it! took you", c, "tries!") def easylevel(): choice = input("\ntry , guess random number(1-10): ") if not choice: print("you need make guess. try again.") easylevel() else: choicenum = int(choice) if choicenum < 1 or choicenum > 10: print("that out of range. try again!") easylevel() count = 0 randnum = int(random.random() * 10 + 1) hilo(choicenum, randnum, count) #checks if user inputs out of range def checklevel(level, low, high): if level > high or level < low: print("that out of range. try again!") main() def main(): ...

c - Why it is not an error to increment array "a" in the below function? -

#include<stdio.h> void printd(char []); int main(void){ char a[100]; a[0]='a';a[1]='b';a[2]='c';a[4]='d'; printd(a); return 0; } void printd(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); } explanation: expecting result in lvalue error. working out error , giving bc output. why incrementing array "a" not error? if array passed function decays pointer array's first element. due inside printd() pointer a can incremented , decremented, point different elements of array a defined in main() . please note when declaring/defining function's parameter list type t expression t[] equivaltent t* . in question's specific case void printd(char a[]); is same as void printd(char * a); the code below shows equivalent behaviour op's code, pa behaving a in side printd() : #include <stdio.h> int main(void) { ...

php - How to find out if class properties are private or public? -

this question has answer here: php's function list objects's attributes 4 answers after creating class private, protected, , public variables, how can find out private, protected, , public (from outside class)? by way want know because want extract public model attributes set in /phalcon/mvc/model. to clarify: not looking list of attributes, scope of every attribute. get_class_vars() fit needs it returns array of properties visible in current scope. in case should return public properties.

Extracting url from string php -

i trying extract url out of string. format of string be: some text! numbers http://linktoimage.com/image i found post earlier extract urls text in php and think solution mentioned there work: <?php $string = "this friend's website http://example.com think coll"; echo explode(' ',strstr($string,'http://'))[0]; //"prints" http://example.com however not understand does. mind explaining me me ? you have string: this friend's website http://example.com think coll strstr($string,'http://') return http://example.com think coll explode(' ', ...) split resulting string @ space character resulting in array( 0 => 'http://example.com', 1 => 'i', 2 => 'think', 3 => 'it', 4 => 'is', 5 => 'coll' ) and [0] returns first item of array, is: http://example.com further reading: http://php.net/manual/en/functio...

jquery - Add next / prev image caption to slider navigation buttons -

i'm trying make next , previous buttons in slider show caption next , previous images, respectively. should when hover on next button caption next image in slider appears. ditto previous button. i've got slider created gallery field in advanced custom fields. have multiple sliders on same page, using same markup. difference background images, , captions of each image. markup simplified below, imagine 3-4 iterations of code below on 1 page (again, thing different between each iteration of slider background images , captions) <div class='theslider'> <div class="controls"> <button class="prev"></button> <button class="next"></button> </div> <div class="the-slides"> <ul> <li><div class='slide' style="background-image..."> <span>item caption 1</span> </li> <li><div class='s...

javascript - Inserting image to an editor -

i using summer note editor , want upload image folder when user select image file , @ same time want insert image editor, how can achieve that, have code upload image folder not editor... $(document).ready(function() { $('#summernote').summernote({ height: 510, onimageupload:function(files, editor, weleditable) { sendfile(files[0], editor, weleditable); } }); function sendfile(file, editor, weleditable) { data = new formdata(); data.append("file",file); $.ajax({ data: data, type: "post", url: 'savetheuploadedfile.php', cache: false, contenttype: false, processdata: false, success: function(url) { editor.insertimage(weleditable, url); } }); } }); i got answer, rather using editor object, replace ed...

javascript - Modifying href using jQuery generating inconsistent results -

when leveraging jquery modify href given link - using 'prop' or 'attr' - call succeeds. can see link change in developer tools, if right click on link , select "open link in new tab" works flawlessly. but if attempt click on link, in same tab, it, whatever reason, keeps sending me old (non-modified) link if it's cached on browser or something. occurs in firefox , chrome. anyone seen before?

while loop - Given value p, return last element of sequence < p - Fortran -

i have sequence of numbers follows: 1 , 1, 5, 13, 41, 121, 365, .... the first 2 values are: n(1) = 1 , n(2) = 1 as 3rd value, n(i) = 2*n(i-1) + 3*n(i-2) the issue facing is: if give argument of p, should return me last values of sequence < p (using fortran77). for instance, if p = 90, should return value 41. a = 1 b = 1 while b < p: c = 2 * b + 3 * = b b = c return the fortran equivalent is: function fct(p) result(a) integer, intent(in) :: p integer :: a, b, c = 1 b = 1 while (b < p) c = 2 * b + 3 * = b b = c enddo end function program test integer :: fct external fct print *,fct(90) end program

excel - Active X error 429 -

i have 2010 pp presentation calls 97-2000 excel graph, references stored procedures , data retrieval via sql. when trying call document i'm getting 429 error. upon debug, following code highlighted. set apppp = getobject(, "powerpoint.application") vb not skillset of mine plugging through best can, gratefully received. try instead: sub test() dim oppt object set oppt = createobject("powerpoint.application") if oppt nothing msgbox "no luck" else msgbox oppt.version oppt.quit set oppt = nothing end if end sub

generics - How to use Java Stream map for mapping between different types? -

i have 2 arrays of equal size: int[] permutation t[] source i want smth this arrays.stream(permutation).map(i -> source[i]).toarray(); but won't work saying: incompatible types: bad return type in lambda expression arrays.stream int[] give intstream map expect intunaryoperator (a function int -> int ). the function provide of type int -> t t object (it work if t integer due unboxing, not unbounded generic type parameter, assuming it's generic type). what looking use maptoobj instead, expects intfunction (a function int -> t ) , gives stream<t> : //you might want use overloaded toarray() method also. arrays.stream(permutation).maptoobj(i -> source[i]).toarray();

oop - Singleton pattern example : The pilot of an aircraft -

is pilot in aircraft or plane , example of singleton pattern ? this example demonstrates common problem of singletons. if absolutely sure program have only one plane , only one pilot, yes, can consider pilot singleton. however, 1 day might need more 1 plane in program, or more 1 pilot in plane. if seems improbable you, never know. therefore better not rely on global variables, singleton pattern kind of wrapper, explicitly tie plane , pilot. simplest example, might have pilot member in plane object (or maybe pilot& etc.) however, depends on nature pf program. air fight simulator, when sensible assume each plane has 1 fixed pilot? or airline simulator/manager, when have many planes, many pilots, , @ different time different pilots can fly same plane? in latter case, suggest no explicit tie between pilot , plane , intermediate object, say, flight , have pilot& , plane& members.

oop - Accessing object properties in javascript using for loop? -

consider following object: var nyc = { fullname: "new york city", mayor: "bill de blasio", population: 8000000, boroughs: 5 }; when try access each of properties using loop: for(var key in nyc){ console.log(nyc[key]); } it returns correct output(property values), but... for(var key in nyc){ console.log(nyc.key); } this return "undefined" on 4 lines why strange behavior, since both: console.log(nyc.fullname); console.log(nyc['fullname']); give same o/p. nyc.key looks property name key , not property name in variable key . first example, nyc[key] , correct way use property name variable. in javascript, can access object properties using dot notation , property name literal ( obj.foo ), or brackets notation , property name string ( obj["foo"] ). in second case, can use expression string, including variable lookup. (in es6, can use symbol s brackets notation, it's not relevant here.)

javascript - How to show marker content by default without any mouse event? -

i have written following code: for (var i=1; < latitude.length; i++) { var markercenter = new google.maps.latlng(latitude[i],longitude[i]); var marker = new google.maps.marker({ position: markercenter, animation: google.maps.animation.bounce }); marker.setmap(map); marker.setvisible(visible) markers.push(marker); addinfowindow(marker,location[i]); } function addinfowindow(marker, message) { var infowindow = new google.maps.infowindow({ content: message }); google.maps.event.addlistener(marker, 'click', function () { infowindow.open(map, marker); }); } when user selects or unselects check-box corresponding marker set visible according action. function markervisibility(check_box,lat,lon) { var index; (var = 1; < latitude.length; i++) { if (latitude[i] == lat && longitude[i] == lon) { index=i-1; break; } } //user selects c...

opengl - How do I convert a 2D transformation matrix (for homogeneous coordinates) into 3D in the z=0 plane? -

i have 3x3 transformation matrix 2d homogeneous coordinates: a b c d e f g h i'd pass opengl (using glmultmatrix ) in 2d application, opengl takes 4x4 matrices 3d homogeneous coordinates. i'd coordinates transformed 4x4 matrix end x , y same 3x3 matrix , z=0 . i've tried work out. vector x, y, 1 i'd end transformed vector ax + + c, dx + ey + f, gx + hy + i , means vector x, y, 0, 1 , i'd want end tranformed vector ax + + c, dx + ey + f, 0, ? . 1 matrix (as far can tell): a b 0 c d e 0 f 0 0 1 0 0 0 0 1 is correct? work? don't think matrix give result i'm looking for, don't quite understand should or shouldn't go in third , fourth rows (and fourth column). if want z-coordinate 0 , have pass zero-row. also, include perspective part in last row: a b 0 c d e 0 f 0 0 0 0 g h 0

javascript - iScroll zoom factor calculation -

i have problem , hope me out. jsfiddle: https://jsfiddle.net/estsiim/zjqptg9j/3/ html: <div id="wrapper"> <div id="content"> </div> </div> <br><br><br> <button id="btn">zoom view</button> css: #wrapper { width: 500px; height: 500px; border: 1px solid black; overflow: hidden; position: relative; } #content { width: 700px; height: 300px; background-color: blue; } javascript: var myscroll = new iscroll('#wrapper', { mousewheel: true, keybindings: true, wheelaction: 'zoom', scrollbars: true, scrollx: true, scrolly: true, zoommin: 0.1, zoom: true, mousewheelspeed: 20, }); var zoomfactor = 0.4; //need calculate somehow $('#btn').on('click', function() { myscroll.zoom(myscroll.scale - zoomfactor); }); so want iscroll ( https://gith...

jquery - I need to pass numerical arguments to a onclick function in javascript -

i need pass numerical arguments onclick function inside anchor tag in javascript.i wrote code follows not working. var lat1=latitude; var lon1=longtitude; u.append('<a data-role="button" id="direction" onclick="showdirection(lat1,lon1)" >view directions</a>'); you can use string concatenation that: u.append('<a data-role="button" id="direction" onclick="showdirection(' + lat1 + ',' + lon1 + ')" >view directions</a>'); that said, onxyz attributes aren't best way hook event handlers. consider: var = $('<a data-role="button" id="direction">view directions</a>'); a.appendto(u); a.on("click", showdirection.bind(a[0], lat1, lon1)); ...if want values of when hook handler, or var = $('<a data-role="button" id="direction">view directions</a>'); a.ap...

Filter data in couchbase View -

when write view in couchbase return whole doc return _sync":{} data, there way remove data response. here view function:- function map(doc, meta) { if (doc.type == 'user' && doc.user_id) { emit(doc.user_id, doc); } } first off, shouldn't ever have emit whole doc. makes index bigger on disk, , it's redudant since can whole doc view row (the doc id included, , sdks transparently fetch usually). in case though, may need second part of emit. select attributes interested in , emit them in array (like emit(doc.user_id, [doc.attributea, doc.attributeb]) ), "filtering out" _sync . only problem if later on add attributec users, won't automatically included (so filters out attributes not explicitly listed in map function). make sense?

html - Add Vertical and Horizontal Scrollbars to HTML5 Tables -

Image
i have table , want make both vertical , horizontal scrollable. when add div , becomes scrollable shrinks smaller size. want table occupy available width of screen , scrollable. rather make table scrolable reduce small size. below pic of table without div below code table. <div id="scroll-table"> <table > <caption> list data mysql </caption> <tr> <th class="center"><strong>id</strong></th> <th class="center"><strong>firstname</strong></th> <th class="center"><strong>lastname</strong></th> <th class="center"><strong>request</strong></th> <th class="center"><strong>purpose</strong></th> <th class="center">...

zsh - Remove current directory if in Git repo -

Image
i using agnoster theme oh-my-zsh in iterm2. possible hide current directory if you're in git repo avoid needless duplication, if how? here gist of zsh setup interestingly, the actual agnoster theme screenshot not duplicate directory (as expecting) as noted @4ae1e1 can fork theme , include conditional. in directory prompt here , prompt_dir() { prompt_segment blue black '%~' } include conditional display directory information if not in git directory, like prompt_dir() { if ! (git rev-parse --is-inside-work-tree >/dev/null 2>&1); prompt_segment blue black '%~' fi }

memory management - CONFIG_DEBUG_PAGEALLOC on ARM Linux kernel? -

i can not find patch of config_debug_pagealloc arm architecture. curious ask few questions. 1)is not implemented arm far ? 2)is reason not porting arm not detecting kernel memory corruption ? thank you. this implemented arm architecture. see here

nulls not working in Stacked area chart in ZingChart -

Image
i want graph image below, graph should stacked. right not stacked , when use stacked: true option, nulls not accepted , green areas joined. have not used bar, want width equal 2 specific dates. can suggest way it? you can view on site alnnovative.com/zingdemo2.php

c++ - STL sort doesn't sort my vector<pair<int,int> > well -

i trying solve more complex algorithmic problem , partial requirement involves sorting pairs of integers. here code ( i've commented irellevant part question) #include <fstream> #include <vector> #include <queue> #include <algorithm> using namespace std; ifstream fin("ai.in"); ofstream fout("ai.out"); #define maxn 1001 #define maxk 150001 // //int n; //int t1, t2, s1, s2, s3, s4, r1, r2, r3, r4; int k; int x,y; vector<pair<int,int> >v(maxk); int main() { // fin >> n; // // fin >> t1 >> t2 >> s1 >> s2 >> s3 >> s4 >> r1 >> r2 >> r3 >> r4; fin >> k; ( int = 1; <= k; ++i ) { fin >> x >> y; v[i].first = x; v[i].second = y; } sort(v.begin() + 1, v.begin() + n + 1); ( int = 1; <= k; ++i, fout << '\n' ) fout << v[i].first << ' ' <...

ios - Apple Mach-O Linker Error - linker command failed with exit code 1 -

Image
i have error in xcode. have done said in other questions same , have checked .m , .mm have removed file similar each other , still not working. it's making me crazy please me. i have added asset game in unity ( ios native ) , after error appear when want test on phone. 2 days i'm searching solution work. ld: warning: directory not found option '-l/volumes/phoenix/flight drift - test 21/librariesplugins/ios' ld: warning: directory not found option '-f/volumes/phoenix/flight drift - test 21/frameworksplugins/ios' ld: library not found -lonesignal clang: error: linker command failed exit code 1 (use -v see invocation) i have updated screenshots looking @ images have uploaded: remove inverted commas ("") around $(srcroot)/libraries in 'library search paths' remove inverted commas around $(srcroot)/unityads in 'header search paths' cannot 'framework search paths' have uploaded image that. (or...

multithreading - Can not start threads from pointer to function, C++ -

i trying start thread execution doing following: #include <thread> #include <stdio.h> typedef void (*callback_function)(void); void printer(){ printf("something\n"); } void dotask(callback_function a){ std::thread t1(a); } int main(){ callback_function print = printer; dotask(print); } executing piece of code, result core dumped. surprisingly, when change function dotask one: void dotask(callback_function a){ a(); } it works, or doing works: int main(){ callback_function print = printer; std::thread t1(printer); } does knows i'm missing or doing wrong? both cases wrong. object std::thread t1 lives until function dotask exits. thread object trying destroying while callback_function still works. should wait thread stop it's work , delete it. int main(){ callback_function print = printer; std::thread t1(printer); // other stuff t1.join(); }

jointjs - Adding remove functionality for elements -

i have been looking way add remove button equivalent 1 existing when hovering on links case of elements. cannot find official way far. the nearest tutorial http://jointjs.com/tutorial/html-elements shows example there's such button visible instead of appearing when hovering on element.

c# - Async RouteBase in ASP.NET with GetRouteDataAsync and GetVirtualPathAsync? -

i have custom asp.net route has io operations in it. now, assume these io operations can't cached (i.e. big). in way i'm looking asyncroutebase class with public async override task<routedata> getroutedataasync(httpcontextbase httpcontext) public async override task<virtualpathdata> getvirtualpathasync(requestcontext requestcontext, routevaluedictionary routevalues); does similar exist? (can't find it) is there place within asp.net pipeline can create myself? i'm using asp.net mvc 5.2.3.0 you cannot create asyncroutebase, because routes used asp.net mvc synchronous. have understand in order create async methods, must consume them asynchronously, can't magically make asynchronous adding async method. routing can't asynchronous various reasons, routes cached , created once @ time of executing first request. beware, routes cached, not change , can't changed in runtime because executed first, if routing make async db calls,...