Posts

Showing posts from June, 2010

join - Microsoft Access: Getting current record & creating child record before insert -

in access, i'd give user datasheet form key in data. datasheet merges 2 tables together, parent ( product ) , child ( book ). i've linked them using id s , share 1-to-1 relationship. however, while entering data, long key in book data, following error message shows up: you cannot add or change record because related record required in table product. and clueless do, thought giving administrator-only metadata product table help. when set "book" , create new row in product , data macro programatically create corresponding row same id in book table. sound feasible? anyway, need retrieve id of current record of book before insertion, wonder how'd able that. make sure foreign key (=field table linked parent table) of book table included in underlying query.

How to keep Firebase in sync with another database -

we need keep our firebase data in sync other databases full-text search (in elasticsearch ) , other kinds of queries firebase doesn't support. this needs close real-time possible, can't export nightly dump of firebase json or that, aside fact rather large. my initial thought run node.js client listens child_changed , child_added , child_removed etc... events of main lists, bit unweildy , reliable way of syncing if client re-connects after period of time? my next thought maintain list of "items changed" events , write every time item created/updated, similar firebase work queue example. queue contain full path data has changed , worker consumes , updates local database accordingly. the problem here every bit of code makes updates has remember write queue otherwise 2 systems out of sync. proxy code shouldn't hard write though. has else done similar success? for search queries, can integrate directly elasticsearch; there no need sync se

c# - IList in interface, List in implementation -

in interfaces there typically ilist<isometype> represent list-type members , expect implementation supporting add method. but in interface implementation, there ilist<isometype> = new list<isometype>() and everytime use list, have cast, example (this.mylist list<imytype>).addrange(sometype.tolist()); is there better way this? how avoid cast? - edit ask more information - instead of extension method, there small linq expression solve that? ilist<string> list = new list<string>(); var items = new[] { "1", "2", "3" }; items.tolist().foreach(x => list.add(x)); but not being straight forward, inverts being done. (the action on items add, not on list). anything better that? possible can done on list? addrange not method on ilist, add is, can make extension method: public static void addrange<t>(this ilist<t> list, ienumerable<t> values) { foreach(var value in values

javascript - HTML Blurry Canvas Images -

i use jcrop provide users friendly way of uploading images via ajax. these images have constraint width , height jcrop comes play. sake of brevity im doing follows: input file select via javascript file api loads image img tag. jcrop works image tag , renders result onto html canvas. now dodgy part. canvas image blurry... for arguments sake canvas set 400x200 crop size. if canvas width , height set via css results in blurry image result. around had set width , height via html attributes. have wonderful cropping solution can save images via ajax. crisp , clear:) <canvas id="preview" width="400" height="200"></canvas>

php - Loading bar to next page with bootstrap -

i have 1 question: on website, button "submit" starts loading new page limited time (defined in simple form). that's work perfectly. want when click "start" bar appears , starts loading defined time. use animated loading boostrap: <div class="progress progress-striped active"> <div class="bar" style="width: 40%;"></div> </div> how can that? javascript? how? :( thanks in advance. total data: data-percentage="60" total second: data-second="60" html <div class="progress progress-striped active"> <div class="bar" style="width: 0%;" data-percentage="60" data-second="20"></div> </div> <a id="clickme">click</a> js $('#clickme').click(function () { var me = $('.progress .bar'); var perc = me.attr("data-percentage"); var sec = me.

java - How to get the finalized text after resolving co-references using StandfordNLP -

hi started learning nlp , chose stanford api required tasks. able pos , ner tasks stuck co-reference resolution. able 'corefchaingraph' , able print representative mention , corresponding mentions console. but, know how finalized text after resolving co-references. can 1 me regarding this? example: input sentence: john smith talks eu. likes family of nations. expected ouput: john smith talks eu. john smith likes family of nations. it depends lot on approach take. try , solve looking @ role word plays in sentence , context carried forward. based on pos tags, try , map subject-verb-object model. once have subject , objects identified can build simple context carry forward rule system achieve want. e.g. based on tags below: [('john', 'nnp'), ('smith', 'nnp'), ('talks', 'vbz'), ('about', 'in'), ('the', 'dt'), ('eu.', 'nnp'), ('he', 'nnp'), ('li

Unable to send Mails through SMTP using Asp.Net -

i need send mails 60 100 students @ time when click on send button. working if have 6 7 students when start sending 60 students code shows following error insufficient system storage. server response was: many emails per connection. here code protected void btnsend_click(object sender, eventargs e) { if (drptopics.selectedvalue == "-1") { response.write(@"<script language='javascript'>alert('please select 1 topic');</script>"); } else { sqlconnection conn = new sqlconnection(); conn.connectionstring = "data source=xxxx; user id=sa; password=xxxx; initial catalog=xxxx; integrated security=sspi;"; conn.open(); sqlcommand cmd = new sqlcommand(); cmd.connection = conn; cmd.commandtext = "select email_1 student_info branch_code='ap' , student_id in(select student_id admissions branch_code='ap' , batch_id='&quo

java - Server-client file transfer null pointer exception -

i'm developing server client file transfer program on java, , couldn't figure out how fix following code don't know socket programming. code client side's codes: string receiverip = null; int serverport = 0; hostip = args[0]; serverport = integer.parseint(args[1]); string filetosend = args[2]; byte[] abyte = new byte[1]; int bytesr; socket clientsocket = null; socket connectsocket = null; bufferedoutputstream toclient = null; inputstream = null; try { toclient = new bufferedoutputstream(connectsocket.getoutputstream()); clientsocket = new socket(hostip, serverport); = clientsocket.getinputstream(); } catch (ioexception ex) { system.out.println(ex); } as problem, null pointer exception on line 14 (undoubtedly since connectsocket null), have no idea can assign on connectsocket(if on server side connection accept socket could've been assigned begin writing after connecion esta

Angularjs nested form input validation ng-repeat -

i want build nested form using ng-repeat following. since input fields required, want add error message in next line this: <span ng-show="submitted && editableform.[e.name].$error.required" class="error">required field</span> , know wrong "editableform.[e.name].$error.required", right way this? update tried adding <ng-form name="rowform"> , works when use hardcode name attribute, in case dynamically generated in [e.name] thanks leo nested form <form name="editableform" novalidate="novalidate"><div class="neweditable"> <ul ng-repeat="row in newrows"> <li ng-repeat="e in rowattrs"> <input type="text" ng-model="newrows[e.name]" name="e.name" ng-required="e.required"> </li> <li><a href="" ng-click="rm_row($index)">x</li> <

ruby - Sharing devise session between two rails apps -

i've got 2 apps running on different domains. rails 3.2 applications using same user database , same authentication gem (devise). is possible share session between 2 apps? tried setup application.config.secret_token same values, without success. since apps don't share other parts of stack database think nice place start. take @ this post how achieve that.

java - Desktop app - Hibernate (using JPA EntityManager) / Spring / Swing -driven extended session -

i'm having trouble extending jpa persistence context, la "open-session-in-conversation" pattern, swing two-tier java se desktop app working on. the benefits of me be: lazy loading objects gui allowing user edit / work objects without having reload them database- in case of edits other users. checked hibernate's versioning , error thrown if persistence context lasted duration of 'conversation' there lots of approaches detailed web use, hardly out there desktop use. can suggest suitable approach?

android - App Inventor App is too slow -

i've developed simple test app android app inventor. i've sent .apk file smartphone, installed , test it. app has screen view 2 buttons: play , stop. play starts player play method streaming server url string , stop button stops player. the problem when tap play button, remains in active state long time, until player starts sound. when tap stop button, player stops player button remains in active state long time play button. there no other methods, screens or components. at moment app "unusable" because of takes long time , i'm sure users should close app. why? problem? the problem phone spends lot of time opening file. unfortunately app inventor simple , doesn´t have lot of other media tools. can put progress bar while file charging, there aren´t many solutions... remind problem should in process of download file instead of phone. if put audio file in app resources, take less time. if make app eclipse, have more options. hope it´s usef

ios - AVAudioPlayer initWithURL not working to stream radio -

i'm trying stream radio in app. i'm using avaudioplayer, have error don't understand : nsstring *urlstring = @"http://broadcast.infomaniak.net/radionova-high.mp3"; nsurl *myurl = [nsurl urlwithstring:urlstring]; nserror *error; self.audioplayer = [[avaudioplayer alloc] initwithcontentsofurl:myurl error:&error]; if (self.audioplayer == nil){ nslog(@"error loading clip: %@", [error localizeddescription]); } else { self.audioplayer.delegate = self; self.audioplayer.volume = 0.5; [self.audioplayer play]; } and have following error : error loading clip: operation couldn’t completed. (osstatus error -43.) does see what's wrong ? edit : this apple docs say: the avaudioplayer class not provide support streaming audio based on http url's. url used initwithcontentsofurl: must file url (file://). is, local path. now ? :( download file document directoty play file nsstring *urlstring = @"htt

javascript - Making API Rest call using jQuery -

i'm trying make rest call jquery rest service. going consume data openmrs api . following instructors of this post. now, made call , still stacking parsing object json , showing on html page. got problems in doing that. sharing code on this jsfiddle. what different steps parse json response ? to explore object , using chrome console. wrote line example of can consume data (observation in case): `$('#result').html('<p>' + data[0].concept + '<p>');` ' in example data object. si navigate through other object; ex: $('#result').html('<p>' + data.results[0].concept.display + '<p>'); on js put : success: function (data) { console.log(data); so can use chrome console see how object made. below partial exemple of console.log output: object {results: array[15]} results: array[15] 0: object accessionnumber: null comment: null concept: object display: "patient r

windows 8 - w8 default tablet settings conflicts with WPF layout -

Image
i have wpf desktop app. i've gotten reports w8 users code completion window in our app not aligned correctly. investigated , found out setting in w8 tablet settings conflicts placement of popups in wpf default right handed , code completion popup looks when changed left handed code completion popup renders correctly is there way programmaticly force app use left handed settings, or ignore renders in w7? edit: got upwote can update solution, requires .net 4.5 private static readonly fieldinfo menudropalignmentfield; static mywindow() { menudropalignmentfield = typeof (systemparameters).getfield("_menudropalignment", bindingflags.nonpublic | bindingflags.static); system.diagnostics.debug.assert(menudropalignmentfield != null); ensurestandardpopupalignment(); systemparameters.staticpropertychanged += (s, e) => ensurestandardpopupalignment(); } private static void ensurestandardpopupalignment() { if (systemparameters.menudropa

Django - Clean permission table -

during development apps , models permissions removed or renamed. what's way clean leftovers permissions table without breaking something? for example: have app articles model article permissions. class article(models.model): title = ... text = ... class meta: permissions = ( ('can_edit_title', 'can edit title of article'), ('can_edit_text', 'can edit text of article'), ) i add permission command (with installed django_extension ): ./manage update_permissions but later realise, better name can_update_title . change model: class article(models.model): ... class meta: permissions = ( ('can_update_title', 'can update title of article'), ('can_update_text', 'can update text of article'), ) when update permissions there both permissions in django administration , confusing users - administrators.

xmpp - Ejabberd External Authentication : extauth script has exitted abruptly with reason 'normal' -

i'm trying enable external authentication in ejabberd installation. keep receiving following error message. extauth script has exitted abruptly reason 'normal' my ejabberd version 2.1.13. tried following configurations, 1.{auth_method, external}. {extauth_program,"php /tmp/test.php"}. 2.{auth_method, external}. {extauth_program,"/tmp/test.php"}. 3 {auth_method, external}. %%{extauth_program,"/tmp/test.php"}. all above configuration returns same error. what test.php script?, sure working?. maybe terminating error says. auth script supposed not terminate, keep running reading stdin. there example use guide here https://github.com/processone/ejabberd/blob/master/examples/extauth/check_pass_null.pl

wpf - c# InvalidEnumArgumentException: The value of argument 'direction' (3) is invalid for Enum type 'FocusNavigationDirection' -

i have wpf-c# application ribbon menu , several text box main panel. when focus 1 of them , press left arrow, following error. when press on other arrow works well. tried breakpoint on previewkeydoyn of specific textbox method exception thrown before can ran it. all other textbox in application work when press left arrow. system.componentmodel.invalidenumargumentexception: la valeur de l'argument 'direction' (3) n'est pas valide pour le type enum 'focusnavigationdirection'. nom du paramètre : direction à system.windows.input.keyboardnavigation.isindirection(rect fromrect, rect torect, focusnavigationdirection direction) à system.windows.input.keyboardnavigation.findnextindirection(dependencyobject sourceelement, rect sourcerect, dependencyobject container, focusnavigationdirection direction, double startrange, double endrange) à system.windows.input.keyboardnavigation.movenext(dependencyobject sourceelement, dependencyobject container, focusnavi

python - How do I lazily pass csv rows to executemany()? -

i'm using mysql connector/python 1.0.11 python 3.3 , mysql 5.6.12 load csv file table via cursor.executemany ('insert ... values'). sqlite3 or psycopg2 can pass _csv.reader object seq_of_parameters, mysql fails with: mysql.connector.errors.programmingerror: parameters query must list or tuple. fair enough, docs must sequence, , _csv.reader object enumerator (it defines iter , next ), not sequence. pass 'list(my_csv_reader)', i'm pretty sure not lazy, , these files can have 10^6+ rows. there way pass lazily? or wasting time because executemany() expand list before performing insert? (a hint cursor.py: "insert statements optimized batching data, using mysql multiple rows syntax.") maybe wrapping iterator in generator, ala http://www.logarithmic.net/pfh/blog/01193268742 . i'm looking forward thoughts!

jsf 2 - communicatio between xhtml page and backend bean -

my question if have 1 xhtml page components , 1 of them on sample <h:inputtext id="input" value="#{userbean.name}" valuechangelistener="#{userbean.valuechanged}"/> and if have appropriate method in backend bean: public valusechanged(valuechangeevent e){ (uiinput)input=(uiinput)e.getsource; uiselectone listbox = (uiselectone)input.findcomponent("listbox"); ...... } what send back-and bean, object e of valuechanged class. bath objects properties in relation component made changes or on sample page? , input value represents, after that?and why have line input.findcomponent("id_of_anoder_component") on sample? what send back-and bean, username.name mapped name field of userbean provided setter method provided , method valuechanged gets called whenever value of name changed. and input value represents input value represents value of backing bean field called name

javascript - How can function references be executed properly (1)? -

win points window . ns temporary namespace post. thought if wanted access settimeout , copy on function reference such: ns.settimeout = win.settimeout; however, execution throw error: ns_error_xpc_bad_op_on_wn_proto: illegal operation on wrappednative prototype object @ ... to fix error, did: ns.settimeout = function (arg1, arg2) { return win.settimeout(arg1, arg2); }; however, don't know why fixed it. don't know language mechanics causing behavior. this fixed problem b.c. changing calling object original when call it. return win.settimeout(arg1, arg2); will set context ( or ) window should be. other answers similar in fact change context correct value using bind apply .

http - Rel on REST API collection links -

i'm working on rest api, , 1 of resources collection of other resources, should return that: { "links":[ { "href":"http://my.rest.api/document/1", "rel":"something" }, { "href":"http://my.rest.api/document/2", "rel":"something" } ] } my question "rel" property. don't understand use. specify http method use? can explain me? thanks lot html 4 defines set of link types . key understandig sentence: user agents, search engines, etc. may interpret these link types in variety of ways. example, user agents may provide access linked documents through navigation bar. the same true rest. server , client must agree meaning possible values of rel . these come mind: parent : parent collection resource child of next : next resource in collection (if collection ordered) prev

java - How can I control an Android VM? -

i have eclipse android sdk. comes android emulator. when run application, eclipse installs newest version of app , runs on emulator, default. how can write program control android vm (or actual device connected via usb since work same way)? want able externally issue commands emulator, not simulate clicks. you can use command adb shell start -a android.intent.action.delete -d package:<your app package> .tell me working you.is there other way adb shell pm uninstall -k + yourpackagename

android - Unknown URI Error in insertImage -

trying saving bitmap gallery bitmap bitmap = bitmap.createbitmap(surfaceview.getwidth(), surfaceview.getheight(), bitmap.config.argb_8888); surfaceview.draw(new canvas(bitmap)); mediastore.images.media.insertimage(getcontentresolver(), bitmap, "foo" , "bar"); i ran application on emulator , got unsupportedoperationexception. 07-25 22:27:48.719: e/mediastore(1918): failed insert image 07-25 22:27:48.719: e/mediastore(1918): java.lang.unsupportedoperationexception: unknown uri: content://media/external/images/media 07-25 22:27:48.719: e/mediastore(1918): @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:168) 07-25 22:27:48.719: e/mediastore(1918): @ android.database.databaseutils.readexceptionfromparcel(databaseutils.java:136) 07-25 22:27:48.719: e/mediastore(1918): @ android.content.contentproviderproxy.insert(contentprovidernative.java:415) 07-25 22:27:48.719: e/mediastore(1918): @ android.content.contentresolver.i

css - Modal window on html5 + transition -

i use modal windows on html5 menu, transition doesn't work. me find errors. -webkit-transition: opacity 400ms ease-in; -moz-transition: opacity 400ms ease-in; transition: opacity 400ms ease-in; and here example in online redactor your display: none hiding dialog immediately, before transition starts.

How do you get inheritance working within JavaScript? -

i want constructor paper inherit constructor view . i've read there needs temporary constructor new f() , parent modified along child class prototype in code: function view() {}; function paper() {}; view.prototype = { location: { "city": "uk" } } function f() {}; f.prototype = view.prototype; paper.prototype = new f(); paper.prototype.constructor = paper; so when try modify paper 's prototype: paper.prototype.location.city = "us"; i find view 's prototype modified too!: var view = new view(); console.log(view.location); //us! not uk so what's wrong code? how can override prototype without affecting parent? inheritance in js tricky, you've discovered. perhaps smarter can enlighten on technical specifics why , possible solution use very tiny base.js framework, courtesy of dead edwards . edit: have restructured original code fit dean edward's framework. inheritance work once master sy

Active Admin - Devise email translation -

i trying translate e-mail body of activation, etc. emails devise sends out active admin admin_user, in devise.local.yml file couldn't find is. i've found subject translations. where can find it? best wishes, matt first have take add devise translation ( https://github.com/tigrish/devise-i18n/tree/master/config/locales ) language.yml file, check structure maintained after insertion: #config/locales/language.yml <language>: devise: :<blah>... after have make views project , mails follows: rails generate devise:views edit views in app/views/mailer good luck!

javascript - Populating a selectbox from html content split by commas -

i writing code form select box in has populated content of specific html part. managed id on specific part (it gets created automatically cms) can call part javascript. problem cant figure out how content split commas "red, blue, yellow" , split select box options. here part of javascript code have: function offerte(){ var kleuren = document.getelementbyid('product_kleuren'); // here has come code populate select box } and html part: <div><span class="extra_fields_name">kleuren</span>: <span id="product_kleuren" class="extra_fields_value">naturel, helder, zwart</span></div> <label class="offerte_lbl">kleur: </label><select id='kleuren' class='offerte_input'></select><br> i know not much, i'm still learning javascript cant figure out how content of specific html part split commas , seperate them values

php - Many new MySQL columns with one form -

i want put form on website let users add events private calendar. that, create new column in mysql each time user add event (always same form, 1 column each event title, example...) is possible? it possible using alter table however, not better have table called 'events' holds of them, column called 'userid' contains id of user event belongs to. then know every event exists in table, , users events query 1 table rows contain users id in userid column.

JQuery - Get the CSS class of an element -

i have anchor follows: <a href="#" class="menu">text</a> how can css class of anchor using jquery? so in case "menu". i able add , remove css classes can't find way css classes of element. can ? use the native property : $(selectororelement).get(0).classname note it's answered use attr('class') . not there no gain in using complex function instead of native dom property it's also, quite naturally, slower. see jsperf

WCF Serialization Error Using NetTCP -

using vs2012 , nettcpbinding. getting following error when call servicecontract client - service hosted in iis: there error while trying serialize parameter cs.servicecontracts.zzzzzz.common:getzipcodesresult. innerexception message 'type 'system.delegateserializationholder+delegateentry' data contract name 'delegateserializationholder.delegateentry: http://schemas.datacontract.org/2004/07/system ' not expected. consider using datacontractresolver or add types not known statically list of known types - example, using knowntypeattribute attribute or adding them list of known types passed datacontractserializer.'. please see innerexception more details. here servicecontract: [servicecontract(sessionmode = sessionmode.allowed, namespace = "cs.servicecontracts.zzzzzz.common", name = "izzzzzzcommonservice")] public interface izzzzzzcommonservice { [operationcontract] getzipcodesresponse getzipcodes(getzipcodesrequest reque

sql - MySQL WHERE with conditions/priority condtion -

this 1 weird 1 can't seem wrap head around. basically need search based on value has override. there 2 columns same content. 1 updated automatically , 1 manual. if automatic 1 not available use manual, , if manual not available use automatic one. lastly if both available use automatic unless , "override" flag enabled (probably third column). what need search based on parameter if 1 field, using set of priorities on columns. here example statement, not know might correct syntax use. where (isset(width)?(width_override?o_width:width):o_width) = {query} use if function. where if(width not null, if(width_override, o_width, width), o_width) = {query}

php - Facebook: Check if post id exists on fb user wall using read_stream -

i have app on facebook publishes stories on users wall. trying prevent spamming users wall same story being published multiple times did. after successful share store facebook post id on servers database. stuck @ part have check if post id stored on servers db exists on users wall before posting story? i requested publish_stream , read_stream! thank you. https://graph.facebook.com/<post_id>?access_token=<users access token> , if "truthy" response back, post exists, if graph api error/exception, doesn't exist.

php - Table 'stock1.products1' doesn't exist -

i'm creating database , table. here's code db , table creation : <?php //error_reporting(e_all); //connect mysql $db = mysql_connect('127.0.0.1', 'root', '') or die ('unable connect.check connection parameters'); //create main database if doesn't exists $query = 'create database stock1'; mysql_query($query, $db) or die (mysql_error($db)); //make sure our created db active 1 mysql_select_db('stock1', $db) or die (mysql_error($db)); //create products table $query = 'create table products1( product_id integer unsigned not null auto_increment, product_name varchar(40) not null, product_stock smallint unsigned not null default 0, primary key(product_id) )'; echo "success"; ?> after this, create file accepts 2 inputs , transmits data php file. here's html: <html> <head> <title>inventory -

css3 - CSS Transition Delay on Value Change -

riddle me this: i have empty span value waiting validation "confirmed" text string. text string needs automagically fade away after second or 2 (without user interaction). how can done pure css? since there no user initiated trigger :hover, best set rule based on exact text string value? seems inflexible. how set when second or 2 delay starts? this not seam work... <span class="validationtextstring" value=""></span> .validationtextstring[value=""] {opacity: 1.0; transition: opacity 0.3s linear 2s;} .validationtextstring[value="confirmed"] {opacity: 0.0;} thanks help. --update-- the above rule work. once - since value doesn't change after populated. there generic css value trigger on change rather specific value? or way reset rule after triggered? thanks again. it doesnt seem me possible pure css. because css called @ load time, has no way check if value 'confirmed'. see fiddle , tex

"main" java.lang.OutOfMemoryError in Hashtable sorting and reversing -

i trying sort arraylist of hashtable (arraylist>). hastable has 3345588 entries. when tried sort , assign reverse order in hastable found exception in thread "main" java.lang.outofmemoryerror @ java.util.hashtable.newentry(hashtable.java:91) @ java.util.hashtable.put(hashtable.java:766) my code below public static hashtable<string, integer> sortvalue( hashtable<string, integer> t) { // transfer list , sort arraylist<map.entry<string, integer>> l = new arraylist<entry<string, integer>>( t.entryset()); hashtable<string, integer> f = new hashtable<string, integer>(); collections.sort(l, new comparator<map.entry<string, integer>>() { public int compare(map.entry<string, integer> o1, map.entry<string, integer> o2) { return o1.getvalue().compareto(o2.getvalue()); } }); // create new normalized hash

c# - Users are overriding eachother's sessions on my asp.net app -

forgive me if dumb question newbie @ asp coming strict desktop background. having issue users how overriding previous user's session on web forms asp.net app. created small mobile phone web app allow 3 guys here @ work able punch in , out on smart phones if user punches in , user b punches in right after user see user b's punches if refresh phone. furthermore if user decides punch out end punching out user b. have heard term user state being tossed around thought asp.net handled automatically? seems me server running 1 session @ time. how can keep unique sessions running users? i under impression server ran different "sessions" or "appdomains" or "instances" if will, each user visited it. no, that's not case. asp.net support sessions, not in way. should @ httpcontext.session instead, helps keep track of session-based state. see "asp.net session state overview" more information.

jQuery - unrecognized expression: :nth-child -

i trying select :nth-child using jquery, show syntax error. error: syntax error, unrecognized expression: :nth-child here code var i; jquery('#' + id + ' .tab-pane').each(function (id, t) { var n = jquery(this).attr('id', 'pane-' + t); var p_id = n.attr('id'); jquery('#' + id + ' .nav-tabs li:nth-child(' + + ') a').attr('href', p_id); i++; }); please check code missing here on first iteration, there no value i . query looks this: jquery('#' + id + ' .nav-tabs li:nth-child(undefined) a').attr('href', p_id); on following iterations, undefined++ , nan , still won't work. this won't work. solution set i 1 (or whatever value necesary) on first loop: var = 1;

parsing - how to parse json data to mootools javascript? -

im using mootools. before getting json data {"id":"120","name":"bassara","year":["1999","2003"],"cc":["2.4","2.5","3.0"],"type":"4","trans":["1"],"wd":["1","3"],"fuel":["1","2"],"hand":["1"],"hybrid":["1"]} in javascript function get_cdata(){ var jsonrequest = new request.json({ url: 'ajax_model_info.php?cid=' + cid, onsuccess: function(car){ (car.id.[1],car.name.[1],car.year.[1]) } }).send(); } its ok. have data json [{"7":{"1":0}},{"7":{"2":0}},{"7":{"3":0}},{"10":{"1":0}},{"10":{"2":0}},{"3":{"1":0}},{"3":{"2":0}},{"3":{"3":0}},{"3":{"4"

emacs - What is the good way to input \ in auctex and _ when cdlatex is on? -

i input \ in auctex when type \, minibuffer prompt out ask me choose macro. think feature thing need real \ . there solution? and, type _ in text when cdlatex on, add $$ around , see subscript. looking answer! you need quoted-insert function. it's bound default c-q .

markerclusterer - Leaflet / Mapbox rendering issue (grey area) -

Image
for reason, map has big grey area on it, until move makes appear. but on first look, there's part missing. i've seen quite lot around web before never wondered how fix until now. this simple mapbox map using markerclustergroup clusters. here's screenshot , link page: http://vinpin.com/map so wondering, there easy known fix kind of behavior? i can add code snippets if required. thanks , have nice day! it seems map element size has changed since initialization , did not invalidate it. did change visibility (eg. display: none style), position (eg. position: absolute or position: fixed in affix), or removed html element dynamically (with js)? perhaps, loading resources in wrong order , styles loaded after leaflet.js ? or, perhaps changed margins or padding? these kind of operations can change size of other elements implicitly , leaflet applet loads tiles area covered old size. shows loaded tiles correctly in "grey" area, though, can scr

ruby on rails - Id column in schema.rb -

everytimes, have column event object (event-calendar gem) in schema.rb file t.integer "id", :null => false so of course, every time want create event have error "null value in column "id" violates not-null constraint" because of this. tried solution activerecord::statementinvalid: pg::error: error: null value in column "id" violates not-null constraint appears everytimes !!! know why column appears here, don't understand... any idea ? when created events model, sounds added id field. isn't necessary rails automatically creates field. event model in schema should like: create_table "events", :force => true |t| t.string "name" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end i rollback migration, assuming recent migration: rake db:rollback then update migration file , remove id create_table block: class createevent

python - BeautifulSoup. Find and replace all instances of a word with one from my list -

i have dictionary. key animals. value list of different animals. size of list , animals change each application use. each animal in list want search through beautifulsoup tree, find occurrences of animal , wrap in span tag/replace span tagged animal i having trouble passing variable re.compile() search these animals. i wondering can replace single word in string in beautifulsoup if has no tags nearby. windows 7, python 2.7, beautifulsoup 4 code someting this for key, value in animals.iteritems(): #go through dict if key == 'animals': name in value: #for name of animals in list animal_tag = soup.new_tag("span", id=key) #create new tag id=animals animal_tag.string = name #create new string name of animal name = soup.find(text=re.compile(r'^%s$' % name)) #find animals in doc - keeps throwing none type error #replace a

Flatten a list of strings and lists of strings and lists in Python -

this question has answer here: how can flatten lists without splitting strings? 4 answers similar questions have been asked before, solutions don't work use case (e.g., making flat list out of list of lists in python , flattening shallow list in python . have list of strings , lists, embedded list can contain strings , lists. want turn simple list of strings without splitting strings list of characters. import itertools list_of_menuitems = ['image10', ['image00', 'image01'], ['image02', ['image03', 'image04']]] chain = itertools.chain(*list_of_menuitems) resulting list: ['i', 'm', 'a', 'g', 'e', '1', '0', 'image00', 'image01', 'image02', ['image03', 'image04']] expected result: ['image10', 'image00

powershell - Creating Alias to `man` with arguments -online? -

i want create alias get-help [foo] -online . can't arguments work. i tried few things including set-alias -name mano -value "get-help -online" ps c:\program files\conemu> mano get-content cannot resolve alias 'mano' because refers term 'get-help -online', not recognized cmdlet, function, operable program, or script file. verify term , try again. @ line:1 char:5 + mano <<<< get-content + categoryinfo : objectnotfound: (mano:string) [], commandno tfoundexception + fullyqualifiederrorid : aliasnotresolvedexception you can't create alias arguments that. you can use function though. like... ps> function mano { get-help $args[0] -online } if want available every time start ps, can put in profile. see $profile .

security - CSP in Firefox 20.0: default-src none -

i have problem content security policy in firefox. basic code: <?php include_once 'corepolicies/csp.php'; ?> <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="scripts/script.js"></script> <link href="style/style.css" rel="stylesheet" type="text/css"/> </head> <body> <form id="formtest" method="post" action="index.php"> <input type="text" name="gettext"/> <input type="submit" value="insert"/> </form> <div id="indataform"> <?php if(isset($_post['gettext'])){

c# - Subclassing all classes in a 'chain' of subclasses -

i came example clarify question we start base class /// <summary> /// silly example class /// </summary> class cfilestream { protected readonly string filepath; public cfilestream(string filepath) { filepath = filepath; } public virtual void write(string s) { var stream = getstream(filepath); //etc } /// <summary> /// take filepath argument make subclassing easier /// </summary> protected virtual filestream getstream(string filepath) { return new filestream(filepath, filemode.openorcreate); } } create subclass it /// <summary> /// building on top of cfilestream, created encrypted version /// </summary> class cfilestreamencrypted : cfilestream { private readonly string _key; public cfilestreamencrypted(string filepath, string key):base(filepath) { _key = key; } /// <summary> /// added complexity, let's wrap pos

How do I get JBoss AS 7.2 to register my OSGi services when the bundle is loaded? -

i have created small sample project have reference implementation of osgi spring (i.e. blueprint), , can bundles install, resolve , start ok, service not registered when bundle starts. i've made entire project available on github can take @ source - jars output build in artifacts folder, can build project running gradle assemble . as i've understood blueprint specification, , particularly this guide , there no need activator class register services if configuration files in right place - in jar, have following under osgi-inf/blueprint/sillyservice.xml : <?xml version="1.0" encoding="utf-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <bean id="sillyservice" class="se.sunstone.silly.service.serviceimpl" init-method="startservice"> </bean> <service ref="helloservice" interface="com.sample.blueprint.helloworld.api.hello

java - How do I draw an image to a JPanel or JFrame? -

how draw image jpanel or jframe, have read oracle's tutorial on can't seem right. need image " beachroad.png " displayed on specific set of coordinates. here have far. public class level1 extends jframe implements actionlistener { static jlayeredpane everythingbutplayer; static level1 l1; public level1() { everythingbutplayer = new jlayeredpane(); bufferedimage img = null; try { img = imageio.read(new file("beachroad.png")); } catch (ioexception e) { } graphics g = img.getgraphics(); g.drawimage(img,0, 0, everythingbutplayer); this.add(everythingbutplayer); } and in main(), l1 = new level1(); l1.settitle("poop"); l1.setsize(1920, 1080); l1.setdefaultcloseoperation(jframe.exit_on_close); l1.setvisible(true); thanks in advance! try this: package com.sandbox; import javax.imageio.imageio; import javax.swing.jframe; import javax.swing.jpanel; import javax.swin

efficient cropping calculation in processing -

Image
i loading png in processing. png has lot of unused pixels around actual image. luckily pixels transparent. goal crop png show image , rid of unused pixels. first step calculate bounds of image. wanted check every pixel alpha value , see if pixel highest or lowest coordinate bounds. this: ------ ------ --->oo oooooo oooooo then realized needed until first non-alpha pixel , repeat backwards highest coordinate bound. this: ------ -->ooo oooooo ooo<-- ------ this mean less calculating same result. code got out of still seems complex. here is: class rect { //class storing boundries int xmin, xmax, ymin, ymax; rect() { } } pimage gfx; void setup() { size(800, 600); gfx = loadimage("resources/test.png"); rect _bounds = calcbounds(); //first calculate boundries cropimage(_bounds); //then crop image using boundries } void draw() { } rect calcbounds() { rect _bounds = new rect(); boolean _coordfound = false; gfx.loadpixels(); //x m

how to add remote slave to my master in buildbot? -

i trying add remote slave master. master behind firewall. how can 1 add remote slave master. have open new port ? if yes master.cfg file have 2 port number ? c['slaveportnum'] = 9989 can please me in regard. question might not clear because self dont know how this. couple of slave within network of master dont have worry firewall have add remote slave worried connection might not happen because of fire wall.

jquery - Making full hexagon a clickable link -

i've got quite simple problem think more advanced in css myself. basically, i'm trying make hexagons links in them not have text link full hexagon i'm struggling see how can done without hacking around. any suggestions fantastic! well, can use jquery: $(".about").click(function(){ window.location=$(this).find("a").attr("href"); return false; }); this make 'about us' tab clickable . source: http://css-tricks.com/snippets/jquery/make-entire-div-clickable/ jsfiddle: http://jsfiddle.net/imemine29/6abl9/1/ have made work 'about us' hex

Dump an entire HTTP request in Flask -

i using flask create json api's , use them software doesn't know http (just plain old network sockets). there way can dump entire http request console? headers, body , all? want able use dump talk on telnet connection, i'm looking whole request. if flask can't kind of logging, other ideas? the best way i've figure out use wireshark, , "follow tcp stream" feature. give me dump of entire http transaction, @ protocol level.

R: ifelse on string -

i populating new variable of dataframe, based on string conditions variable. receive following error msg: error in source == "httpwww.bgdailynews.com" | source == : operations possible numeric, logical or complex types my code follows: county <- ifelse(source == 'httpwww.bgdailynews.com' | 'www.bgdailynews.com', 'warren', ifelse(source == 'httpwww.hclocal.com' | 'www.hclocal.com', 'henry', ifelse(source == 'httpwww.kentucky.com' | 'www.kentucky.com', 'fayette', ifelse(source == 'httpwww.kentuckynewera.com' | 'www.kentuckynewera.com', 'christian') ))) i suggest break down nested ifelse statement more manageable chunks. but error telling you cannot use | that. 'a' | 'b' doesn't make sense since logical comparison. instead use %in% : source %in% c('htpwww.bgdailynews.com', 'www.bgdailynews.com') i think... if un

How to git rm a file whose name starts with ':' -

i've accidentally got file in repo named :web, . when typing git rm :web, seems think colon part of command , not start of filename: fatal: pathspec 'web,' did not match files quotes don't make difference. you need escape : (and not in shell, git itself): git rm '\:web,' or git rm \\:web, alternatively, use : -based pathspec error telling about. example: git rm :::web,