Posts

Showing posts from June, 2012

php - Nested collection fields in Sonata Admin (2.3) -

Image
i'm having problems creating form creating course. part of database scheme i'm trying create form: so i'm trying create course can create sessions , dates (moment) attached session. should this: in courseadmin class have: protected function configureformfields(formmapper $formmapper) { $formmapper ->add('name', 'text', array('label' => 'naam')) ->add('description', 'textarea', array('label' => 'beschrijving')) ->add('materials', 'textarea', array('label' => 'benodigde materialen')) ->add('numberofparticipants', 'number', array('label' => 'aantal deelnembers')) ->add('numberofdays', 'number', array('label' => 'aantal dagen')) ->add('pr

Polymer 1.x: Data binding -

i want select states in <google-chart> geo map element shown in jsbin . when select state, expect change color (to dark teal) instead, stays same color (light grey). follow these steps recreate problem: open jsbin . in section dom-module > <script> > properties > items > value , change array ['alabama', 0] ['alabama', 1] . notice state of alabama changes color light grey dark teal. hover mouse on state of alabama. notice value of select variable 1 state of alabama (and 0 other states). return value of array ['alabama', 0] . note previous step proves code generating geochart behaves expected when items property manually mutated. here's trouble begins... click state of alabama. in console, notice value of items[1] array ['alabama', 1] . notice select value 0 (unlike case when manually changed above). what problem here? i'm uncertain but perhaps solution involves implementing advice

jquery - Javascript redirect to page and append text -

i have forum can filter 'category1', 'category2', or 'all' now have dropdown has 3 options. javascript/jquery i'm doing this: $('#dropdown').on('change', function () { if ($('#dropdown').val() == 'category1') { window.location.href += "/cat1"; } else if ($('#dropdown').val() == 'category2') { window.location.href += "/cat2"; } else { window.location.replace(window.location.href); } }); the problem code above first change goes correctly say: "website/foo/bar/cat1" when change dropdown again cat2 goes , fails: "website/foo/bar/cat1/cat2" is there anyway can keep same url everytime change dropdown value? theres catch though. "website/foo/bar/" has "bar" can such this: "website/foo/something/" or "website/foo/else/" when add url += appending existing url. var url = "htt

Sessions, multiple PHP files, die() and authentication flags -

i have login built thusly: there admin.php script checks if $_session["auth_flag"] defined "true" (string") if not, admin.php include()'s login.php login.php generic login page module, sends xhttp request input do_login.php if credentials correct do_login.php sets $_session["auth_flag"] true , die("0") ; after login.php checks return of do_login.php if "0" location.reload() via javascript reloading page (admin.php) however after - $_session["auth_flag"] not set. does die() unset changes made $_session during same script? will post relevant snippets of code on request since there no errors in error.log besides [sun feb 07 20:45:28.957347 2016] [:error] [pid 1593] [client 89.201.9.253:18390] php notice: session had been started - ignoring session_start() in /mnt/disk/html/dev/prefs.php on line 3 [sun feb 07 20:45:28.957766 2016] [:error] [pid 1593] [client 89.201.9.253:18390] php notice: session

javascript - Bootstrap tabs - Next & previous Buttons -

i using bootstrap 3.4. i using tab-pills on form 3 tabs. i trying place next & previous buttons aid navigation between tab form. i have read post on topic (and bootply ), require, , applied necessary code. on form, in 3 tabs, see next1 button, never see other buttons. i figured out error class=active on <li class="active"> line of code> (or @ least error). i have searched google , figure out how js code working, cannot figure out correct simple issue. have exhausted attempts, turn assistance. can suggest how might correct this? here js code: $('.btnnext').click(function(){ $('.nav-pills > .active').next('li').find('a').trigger('click'); }); $('.btnprevious').click(function(){ $('.nav-pills > .active').prev('li').find('a').trigger('click'); }); here html code: <ul class="nav nav-pills"> <li class="active">

php - HTACCESS: Dynamic rewrite url with multiple variables -

Image
i've been working on couple of days , i'm wondering if point me in right direction please... i'm trying pass 2 variables in rewrite. unless given url file or directory, i'd urls dynamically rewritten follows: example.com/category -> example.com/index.php?p=category example.com/category/page -> example.com/index.php?p=category&article=page example.com/category2/page -> example.com/index.php?p=category2&article=page i'm having hard time trying turn following in dynamic: rewriterule ^category/(.+?)$ ?p=category&article=$1 [l] i'm trying doesnt work: rewriterule ^(.+?)/(.+?)$ ?p=$1&article=$2 [l] ...also trying doesnt work either: rewriterule ^(.*)/(.+?)$ ?p=$1&article=$2 [l] i'm trying avoid putting in following make work: rewriterule ^category2/(.+?)$ ?p=category2&article=$1 [l] here full code: options +followsymlinks rewriteengine on rewriterule ^category/(.+?)$ ?p=category&article=$

python - Flask not registering routes -

i have following code doesn't seem registering routes. #!/usr/bin/python import os,sys,json flask import flask, url_for class foo: server = flask(__name__) mountpoint = "/api" def __init__(self,startup="run",config="",mountpoint="/api"): self.mountpoint = mountpoint self.startup = startup self.server = server @server.route("/test") def test(self): return "hello world!" def getendpoints(self): server = self.server server.test_request_context(): print url_for('test') def start(self,**kwargs): getattr(self.server,self.startup)(**kwargs) if __name__ == "__main__": mon = foo() mon.getendpoints() mon.start(host='0.0.0.0',debug=true) if don't call "getendpoints" things seem run fine, /test returns 404. when calling "getendpoints" returns build error. i

gnu - Makefile evaluation, includes and loads -

say have makefile called bar in directory on include path make. load ./foo.so and have makefile in directory b. include bar the include succeeding, dump copy paste rather want. want load in bar go off, when include if had functions foo.so provides available. i tried in file bar path := ${shell pwd}/foo.so load ${path} but didn't work either because pwd gets within directory b wanted in directory a.

html - Not sure why flex-grow: 1 isn't working in my column layout -

i trying have views-cntnr take space not used views-cntnr , menubar divs. achieve this, have flex display set column direction. set flex-grow property views-cntnr 1. doesn't appear doing anything. jsfiddle note: not sure if matters have nested flex displays going on. html <script src="https://code.jquery.com/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <script src="https://code.jquery.com/jquery-2.1.4.js"></script> <script src="https://code.jquery.com/jquery-1.11.3.js"></script> <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <section class="analysis"> <div class="menubar"> <div class="view-ctrls text-center"> <div class="btn-group" role="group"> <button class="bt

iphone - iOS hardware volume buttons - tell press from hold -

ok, there're lots of questions on using iphone hardware volume buttons own purposes (e.g. camera shutter); i've seen based on receiving volume change notification. i need distinguish volume button press hold/release. sure implemented based off volume change notifications, this: on volume change event, if there's event coming shortly - that's hold (or quick double press); if no event coming within e.g. half second that's button press. but. there's app called snapchat; use volume button press take picture, , volume button hold record video while hold. , app tells press hold - meaning press event recognised immediately, not within half second. so question how that?

c++ - Java JNI error java.lang.UnsatisfiedLinkError: xxxx()V -

i have had rough time jni today, want integrate openalpr java project, using precompiled binaries work when run java_test.bat file. @ first java kept on telling me not locate openalprjni added path dlls build path , system path, after started experiencing openalprjni.alpr.initialize(ljava/lang/string;ljava/lang/string;ljava/lang/string;)v according documentation means library not ok, ok since test program running, have looked @ various forums , talked author of openalpr still cannot resolve issue, there here has had similar problem me fix this? in advance. please have in com.openalpr.jni.alpr . in line 12 find: private native void initialize(string country, string configfile, string runtimedir); this method matched header com_openalpr_jni_alpr.h : /* * class: com_openalpr_jni_alpr * method: initialize * signature: (ljava/lang/string;ljava/lang/string;ljava/lang/string;)v */ jniexport void jnicall java_com_openalpr_jni_alpr_initialize(jnienv *, jobj

php - Return multiple rows of an array from a mysqli query -

i have in functions.php file function getuserorders($userid){ global $conn; $query = "select * "; $query .= "from orders "; $query .= "where userid=" . $userid . " "; $odrset = mysqli_query($conn, $query); while ($odr = mysqli_fetch_assoc($odrset)){ return $odr; } } what neeed in orders.php file display specific fields , values returned $odr array snippet suggests $userid = sql_prep($_session['userid']) ; getuserorders($userid); echo $odr['title'].$odr['orderid'].'<br>' i able in functions.php file... function getuserorders($userid){ global $conn; $query = "select * "; $query .= "from orders "; $query .= "where userid=" . $userid . " "; $odrset = mysqli_query($conn, $query); confirm_query($odrset); while ($odr = mysqli_fetch_assoc($odrset)){ echo $odr['title'].$odr[&

c# - Xaml binding to attached property referencing another property -

re-worked per peter’s suggestion. i have xceed datetimepicker. accepts datetime? value display , bind to. i have special date – 1900-01-01 00:00:00 if pass date datetimepicker, treated if passed in null – ie, date not shown. when retrieve value, if date hasn’t been set ie null, return same special date – 1900-01-01 00:00:00. for other dates, whatever goes in goes out. in code behind (pseudo code): datetime specialdate = new datetime(1900,1,1,0,0,0) datetime testdate = new datetime(2016, 2, 8, 10, 0, 0); datetimepicker dtp = new datetimepicker(); // setting value. if (testdate != specialdate) dtp.value = testdate; // getting value if (dtp.value == null) return specialdate; else return (datetime)dtp.value; can achieve same kind of thing using xaml , binding ? use simple converter convert , convertback values: public class datetimetosentinaldateconverter :

C: how do dynamically allocate & free memory for a char array? -

how dynamically allocate , free memory char array? my malloc below not work. error thrown 'expected ';' @ end of declaration list.' char *string_buffer = malloc(128 * sizeof(char)); below attempt @ freeing string_buffer[128] char array: void rmv(struct tree_node *cwd) { struct list_node *child = cwd -> first_child; free(string = child -> tree -> string_buffer); printf("string memory free successful\n"); //free(cwd -> first_child -> tree); //free(cwd -> first_child); } rest of code: shell commands: cd = current directory ls = list mkdir = make directory rmdir = remove directory (unimplemented - need free memory) #include <stdio.h> /* fgets(), fprintf() , printf() */ #include <stdlib.h> /* exit_failure */ #include <ctype.h> /* isspace() */ #include <string.h> #include <stddef.h> // commands char exitprogram[] = "exit"; char listdirectory[] = "ls";

rubygems - Installing Bundle for Ruby -

i trying install bundle , keep on getting errors specific gems not being installed. example, byebug debugger not installed had install that, , eventmachine not installed, , json not installed install json , when run #bundle install i still the: an error occurred while installing json (1..7.7), , bundler cannot continue. make sure 'gem install json -v '1.7.7' succeeds before bundling how can install bundle? edit: gem install json -v '1.7.7' following error: new error message

Bookshelf.js accessing multiple tables that are related -

i'm dealing 3 tables. right can feed of user ( activities table) , activitytypes object (id,type activitytypes table), need related_user ( users table) object of given activity, i'll know details of related_user if column isn't empty. users id email username password_hash activitytypes id type activities id user_id (foreign key users, owner of activity) status activitytype_id (foreign key activitytypes) related_user (foreign key users. shows relation user_id, if there's any. if activitytype_id 2 or 3, shown "followed, "commented", etc.) my models var activitytype = db.model.extend({ tablename: 'activitytypes', hastimestamps: false }); var activity = db.model.extend({ tablename: 'activities', hastimestamps: true, activitytypes: function() { return this.belongsto(activitytype); } }); var user = db.model.extend({ tablename: 'users', hastimestamps: true, feed: function() { re

php - Eloquent event is not firing -

i want set password when changes in user model. i'm using boot method of model: <?php namespace app\model; class user extends \illuminate\database\eloquent\model { protected $table = 'users'; public static function boot() { //die('here'); // happens user::saving(function ($user) { //die('here'); // doesn't happen if ($user->isdirty('password')) { $user->password = // hash password... } }); } } i'm using save() method on model create entry in data base, apparently should fire creating event. i've emptied database table ensure new row being creating (it is), event not fire - , password raw un-ecrypted. way, i'm using illuminate/database ^5.2 in app (not laravel). update - capsule initialization $capsule = new illuminate\database\capsule\manager; $capsule->addconnection([ 'driver' => 'mysql', &#

sql - Incrementing Rank Value in Column -

i have table customers, products, , rank. each customer has 5 products: customer, product, rank cust a, product 3, 1 cust a, product 7, 2 cust a, product 6, 3 cust b, product 4, 1 cust b, product 6, 3 cust b, product 3, 5 i removed of rows (like cust b rank 2 , 4). how can go through table , wherever there break in rank (like missing 2 , 4) each customer , re-rank them (so 1,2,3 instead of 1,3,5) first, don't have change data in table. use row_number() function when query: select customer, product, row_number() on (partition customer order rank) rank t; if use approach, don't have worry future deletions. okay, if want change data, 1 method correlated subquery: update t set rank = (select count(*) t t2 t2.customer = t.customer , t2.rank <= t.rank );

javascript - Remove everything outside of body tags -

i have variable contains responsetext external html page: textfromfile = myrequest.responsetext; how delete outside of body tags? can delete html tags in string ( textfromfile ) using regex before that, appreciate if me removing characters outside of body tags (in other words, keep strings/ words within body tags of html page). ---- edited part ---- the html file reading in is: <html> <head> title </head> <body> <p> hello world! <br/> <a href = ”link.html”> click <b> here </b> </a> <br/> goodbye world! </p> </body> </html> when apply: var doc = new domparser().parsefromstring(myrequest.responsetext, "text/html"); alert(doc.body.innerhtml); the response is: title <p> hello world! <br> <a href="”link.html”"> click <b> here </b> </a> <br> goodbye world! </p> which shouldn't case 'title' ou

c++ - How do I call functions before setup? Or make a neopixels initializer before setup? [arduino] -

i need hand. i'm trying figure out how shuffle neopixel pins. right now, have function shuffles pins, don't know how define pins , start strips. i've got pastebin of have on here: http://pastebin.com/kzav95yr basically what's stumping me this: neopatterns strip1(32, neopixelpins[0], neo_grb + neo_khz800, &stripcomplete); i can't move setup function. can't after shufflepins() in setup, , can't move strip1.begin() etc out of function or start of loop(). so. how can this? need first shuffle pins, define strips, start them. needs reusable, because @ end of game, re-shuffles pins , starts over. i'm going have read through this: call function before main but if can give me hand this, appreciate it. i'm new c++. reference on neopatterns class came from: https://learn.adafruit.com/multi-tasking-the-arduino-part-3/using-neopatterns thanks! you want shuffle pin numbers, want before constructor called, it? much more simpl

Ember.js - How can I save data to session from authenticator? -

i have tried doing this.get('session') gives me nothing. i want save data session i seem information need authenticator can't seem able pass around. (tried couple of methods suggested on none seem able work autheticator) import ember 'ember'; import torii 'ember-simple-auth/authenticators/torii'; const { service } = ember.inject; export default torii.extend({ torii: service('torii'), authenticate(options) { return this._super(options).then(function (data) { console.log(data); }); } }); caller of autheticator (is info need accessible here already?) import ember 'ember'; export default ember.controller.extend({ session: ember.inject.service('session'), actions: { authenticatesession() { this.get('session').authenticate('authenticator:torii', 'google-token'); }, invalidatesession() { this.get('session').invali

jquery - Picture update without page refresh -

i in process of developing new web application. web application includes ability users create profile page picture on it. using regular html form allow users input profile information. i implement solution users able see profile picture uploaded. right using jquery file upload ( http://blueimp.github.io/jquery-file-upload/basic-plus.html ) upload picture server , write filename database @ works fine. problem picture on page doesn't update until users reloads page. newbie , not sure best approach implementing functionality. have done research on ajax calls, havent been able find guide on how implement in case. i building web application using bootstrap/jquery/jsp/servlets/. not using of popular java frameworks. newbie growing knowledge of web applications. how best implement functionality allows profile picture update without refreshing page, , there beginner guide anywhere online? thank you, it's bit difficult troubleshoot problem, without seeing code using

Is there any Java ORM which return Json instead of Object? -

it should compatible sql, mysql , oracle databases. i have gone through list of available orm solutions here didn't find return other entity object. you can use hibernate,openjpa,eclipse link. can send json ui java

javascript - Refreshing iframe error -

i using iframe in div block , trying change src through button click following code. function helloclick(){ var iframe = document.getelementbyid("iframediv"); iframe.src = "hello_world"; iframe.contentdocument.location.reload(true); } the hello_world file located in same folder file iframe defined. following error message every time click on button. uncaught typeerror: cannot read property 'location' of undefined how resolve issue? try below code snippet function helloclick(){ var iframe = document.getelementbyid("iframediv"); iframe.src = "hello_world"; iframe.src = iframe.src; } it should you.

pharo - What image can I use to experiment with Comet and WAListenerAdaptor in Seaside? -

how can give this example go. can't seem find image experiment with, still includes walisteneradaptor . any links? the new equivalent in pharo znzincserveradaptor starton: xxxx .

How to identify link label is clicked in my form closing event in c#? -

i have logout button link label on main form if user click logout link label yes logout successfully. but problem is closed directly main form without clicking logout link label. there no way write when user logout in log file because didn't click logout link label. so want identify logout link label in form_closing event? how can i? edit : under logout link label: stopwatch = applicationstate.currenttime.stopwatch; stopwatch.stop(); var timespent = stopwatch.elapsed.tostring(); application.exit(); thanks. you can handle situation in 2 ways: remove form's border user can not close directly (but in 1 have write code allow user move form). this.formborderstyle = system.windows.forms.formborderstyle.none; call logout method or event handler on form_closing but should have separate method of containing complete logic of logout rather event handler containing it.

Backup an Azure WebApp using Azure PowerShell -

i want backup azure webapp using powershell script. know manual way of backing web app through azure portal. looking programmatic way (preferably powershell) accomplish same can backup azure vm using powershell. possible? you can rest api can called powershell. walk through: websites-csm-backup

php - tinymce nanospell showing incorrect suggestion -

the tinymce plugin nano spell showing unliscenced version suggestion shown in image click here image when writing ffight or ttest , many different incorrect spellings shows similar suggest shown in image

python - Django - display several model queries either a template or nested templates -

i new django , have learned display model data in template (using django.generic listview in views) putting in table using like: {% each in model_list %} <td>{{each.attribute}}</td> {% endfor %} what should if want perform several queries on same model(data) , present each of returned dictionaries in different part of template view (imagine if had 1,000 baseball players , wanted display them in separate tables on same page corrosponding team)? my thought should use django documentation: https://docs.djangoproject.com/en/1.4/topics/class-based-views/ class publisherbooklistview(listview): context_object_name = "book_list" template_name = "books/books_by_publisher.html" def get_queryset(self): self.publisher = get_object_or_404(publisher, name__iexact=self.args[0]) return book.objects.filter(publisher=self.publisher) def get_context_data(self, **kwargs): # call base implementation first context context = super(publisherbookl

unit testing - How do you test loggers? In PHP -

consider following class: <?php namespace eveonline\logging; use log; use monolog\handler\streamhandler; use monolog\logger; class eveloghandler { public function requestlog($response, $filename) { $streamhandler = new streamhandler(storage_path($filename), logger::info); $loginstance = log::getmonolog(); $loginstance->sethandlers(array($streamhandler)); $loginstance->addinfo('fetched', [$response->getstatuscode(), $response->getbody()->getcontents()]); $response->getbody()->rewind(); } public function messagelog($message, $filename) { $streamhandler = new streamhandler(storage_path($filename), logger::info); $loginstance = log::getmonolog(); $loginstance->sethandlers(array($streamhandler)); $loginstance->addinfo('message', [$message]); } } now used in library building log out guzzle responses , until have been mocking out class method

c++ - Unable to run OpenCV code from beaglebone -

i trying run program using opencv in beaglebone black described @ end of link https://solarianprogrammer.com/2014/04/21/opencv-beaglebone-black-ubuntu/ i had compilation issues resolved using g++ `pkg-config --cflags --libs opencv` test_2.cpp -o test_2 it compiles, when try run using ./test_2 i error: cmem error: init: failed open /dev/cmem: 'no such file or directory' the cmemk kernel module not appear installed. commands such following run root install cmemk , allow opencl proceed properly. for available cmem ddr block size: ~512mb: modprobe cmemk phys_start=0xa0000000 phys_end=0xc0000000 pools=1x536870912 allowoverlap=1 i not sure why getting this, , i've been unable resolve few days already. please guide me right direction. regards so, had same problem (running latest debian release on beaglebone site - 8.5). i found link here - suggested these things: for older images this: sudo apt-get update sudo apt-ge

git : remote HEAD is ambiguous - how to push changes to another branch than the cloned one? -

i cloned remote rep, master , made changes. before pushing changes admin has created development branch. now " git remote show origin " command showing following ambiguous head branch. head branch (remote head ambiguous, may 1 of following): development master remote branches: development new (next fetch store in remotes/origin) master tracked local branch configured 'git pull': master merges remote master local ref configured 'git push': master pushes master (up date) i made changes cloned master . now, how push changes newly created development branch ? thanks if want have local branch called development "linked" remote development branch, current state (eg : master branch commits), run : # create new branch on current commit, , switch : $ git checkout -b development # push moidifcations remote "development" branch, # , tag local branch follow remote "development&qu