Posts

Showing posts from August, 2014

Pass HTML Form Date to VB Variable for SQL insertion -

alright, have simple asp page (summary.asp) - see code: <html> <body> <form action = "summary.asp" method="post"> select day: <input type ="date" name = "selecteddate" /> <input type="submit" value = "submit"/> </form> <% dim selecteddate set selecteddate = date selecteddate=request.form("selecteddate") after want use date selected part of sql query: if selecteddate<>"" sql = "select location_name, [product code], sum(salesquantity) units [sales data] eventenddate = convert(date, getdate()) group [product code],location_name" ... end if %> where intend replace "convert(date, getdate())" date selected in form. i have not yet got part insert date form sql string. know date format html form in right format sql (yyyy-mm-dd), looks vb not format date? maybe i'm missing something, appreciated. thanks... hope makes sen

Calculating days between today and a date field in an Access table -

hi i'm trying calculate number of days between date field in current access table , todays date. here have: days on report: datediff("d",[reportdate],[date()]) the problem having when run query pop box asking "date()" i trying avoid adding column "today" , doing days between column , reportdate column if possible. reportdate column existing in table. days on report field/column creating. when not enclosed in square brackets, date() function call returns current system date. putting square brackets around turns field name . since there no field name, query treats parameter , prompts value. solution: rid of square brackets.

user interface - Build list of Panels for management in C# with Rudimentary Form Builder -

i'm working in form builder allows me input select custom code. i'm trying build rudimentary window manager shows , hide's panels. i'm using .visible , system.drawing.point in form onclick: public void togglepanel(panel panel) { if(panel.visible) { panel.visible = false; } else { panel.visible = true; panel.position = new system.drawing.point(panel1.right + 5, panel1.top); } } currently closeallpanels long list of declarations, i.e. panel2.visible = false; how can generate list of these panels? can using getmembers() method? i'm new c#, i'm not sure class i'd need run getmembers() on generate list. or there easier way i'm missing? if of panels in same container, like: list<panel> panels = new list<panel>(this.controls.oftype<panel>()); console.writeline("# of panels: " + panels.count.tostring()); foreach(panel pnl in panels)

gorm - grails derived property creating column in database -

i'm using grails 2.4.4. i have domain class post { integer nbroffavorites static hasmany = [ favorites : favorite ] static mappings = { nbroffavorites formula: '(select count(1) favorite f (f.post_id = id))' } } the problem nbroffavorites being created in database, retrieving doesn't take account formula. is there wrong in syntax ? thanks yes there typo in syntax. change mappings mapping , like: static mapping = { nbroffavorites formula: '(select count(1) favorite f (f.post_id = id))' } ref# grails domain: mapping

ruby on rails - master failed to start, check stderr log for details -

i'm trying start unicorn , keep getting error constantly. my unicorn.rb ( https://gist.github.com/anonymous/d1f3d9bcdd1a6c4d8435 ) command i'm using start unicorn: /home/app/adsgold/# unicorn_rails master -c config/unicorn.rb -d -e production commands i've tried: /home/app/adsgold/# unicorn_rails -c config/unicorn.rb -d -e production /home/app/adsgold/# unicorn_rails master -c config/unicorn.rb -d -e production -p 3000 /home/app/adsgold/# bundle exec master unicorn -c unicorn.cnf -e production -d complete error beeing shown: https://gist.github.com/anonymous/828d9677f928fa671762 it looks have rvm , ruby installed system-wide. may cause lots of issues. rvm documentation warns that . try install rvm , ruby user, owns app directory. in case consistent system. by way, have directory /home/deploy/apps/shared on environment? writable app? according unicorn config following things depend on it: pid "/home/deploy/apps/shared/pids/unicorn.pid

Run function from Button or URL in Laravel -

i have following test function, want call directly url or clicking link blade view. public function callmedirectlyfromurl() { return "i have been called url :)"; } my question: possible call function directly button-click or url link blade view in laravel? here solution: we assume have function callmedirectlyfromurl in yourcontroller , here how can call function directly url, hyperlink or button. create route route::get('/pagelink', 'yourcontroller@callmedirectlyfromurl'); add link in view blade php file <a href="{{action('yourcontroller@callmedirectlyfromurl')}}">link name/embedded button</a> this has been tested on laravel 4.2 -> 5.2 far. by clicking on link or call url www.somedomain.com/pagelink function executed directly.

python - Random and list slicing working strangely with online world list -

i don't know how use python interact internet. can't seem find beginner learning besides codeacademy course. anyway wanted try , make hangman game randomly selected word english dictionary. need world list have not definitions. can print out entire world list things aren't acting right when try select specific portion of or run through random.choice() import urllib import random webpage = urllib.urlopen("http://www-01.sil.org/linguistics/wordlists/english/wordlist/wordsen.txt").read() print random.choice(webpage) is have tried printing webpage[0: ] or webpage[0: 10] or random number , first doesn't work @ second prints 3 words or 3 pieces of words on separate lines. each of words on separate line in file, when open url large string of words new line characters. around need split string separate lines. luckily python has inbuilt methods things in case if add: webpage = webpage.splitlines() between 3rd , 4th line work, resulting in foll

android - JavaScript Exception Is Lost In Promise Chain -

i new javascript promises , trying implement them phonegap code on android device. want log exceptions , looks exceptions swallowed somewhere. see sample code below. exception thrown due call non-existent function "thiswillfail" not show anywhere. commented out irrelevant code , added code force addrecord promise called. code checks if record exists and, if not, return addrecord promise error is. not using 3rd party libraries. doing wrong? edit: if add promise in chain "dosomethingwithrecord", promise called when expectation skip catch. function testpromiseexceptionhandling() { var record = null; var checkforrecord = function () { return new promise(function (resolve, reject) { //getdata( // function (data) { var data = ""; if (data != "") { //record = new record(data); record = "existed"; resolve(); } else return addrecord();

node.js - Correct usage of Iron router? -

i'm beginning meteor , iron router. i'm trying make multi-page application using iron router. i've been able make basic structure, i've noticed, before changing new page, meteor sends code current application, not exactly, want. question is: should use routecontrollers store page logic? if not, how can prevent sending code? thanks answer.

R - for value in dataframe, create a new dataframe with the value -

i'm having issue referencing df filter out values in df hold in new df. an example: df1 <- c("a", "b", "c", "d") value <- c(1, 2, 3, 4) df1 <- as.data.frame(cbind(df1, value)) names(df1) <- c("id", "value") df2 <- c("a", "b") names(df2) <- c("id") what see final dataset this: id value 1 b 2 i'm not sure if loop or use of %in% operator , appreciated... in case, try: output <- df1[df1$id %in% c("a","b"),] for more generalised cases: match_ids <- c("a","b","another id","yet id") output <- df[df$id %in% match_ids]

entity framework - EF other way to Sum() new Column -

i got stuck on query calculate new column. cannot explain briefly see snippet code below. from user in context.table select new { total = user.total, paid = user.paid, balance = //should total - paid assign result } i have tried query var result = in context.enrollmentrequests a.schoolyear == schoolyear select new { a.studentid, name = a.student.firstname + " " + a.student.middlename + " " + a.student.lastname, tuition = context.miscs.where(m => m.yearlevel == a.yearlevel && m.schoolyear == schoolyear && m.term == a.term && m.courseid == a.courseid) .select(ms => new { amount = ms.amount }) .union(context.studentcharges

ide - Selecting only the content between two brackets -

i phpstore when press ctrl+w selection the content between brackets , brackets in on step. there config force select content without brackets? update: consider following example: if(true) { echo "hi"; | echo "bye"; } the caret @ end of second line. pressing ctrl+w triple times select block+brackets.

javascript - How to override content security policy while including script in browser JS console? -

i trying include jquery on existing website using console way: var script = document.createelement('script'); script.src = 'http://code.jquery.com/jquery-1.11.1.min.js'; script.type = 'text/javascript'; document.getelementsbytagname('head')[0].appendchild(script); then got error: content security policy: page's settings blocked loading of resource @ http://code.jquery.com/jquery-1.11.1.min.js .. during development might want include external javascript. might not want copy paste entire jquery code since not neat. how override content security policy development purposes? this useful quick testing. might want convert script writing browser extension later on. note (update): writing script on existing website , not have control on setting content-security-policy header. you can turn off csp entire browser in firefox disabling security.csp.enable in about:config menu. if this, should use entirely separate browser testing . ex

numpy - MPI for python broadcast -

hi guys new here please excuse me if make errors. use python write code masters project , started using mpi4py make code parallel since have available 12 cores , time purposes. cannot reason bcast function work. want work out t2 in root process broadcast other processes. code follows: from mpi4py import mpi qutip import* scipy import* pylab import* numpy import* comm = mpi.comm_world rank = comm.get_rank() size = comm.get_size() n0=10 n1=n0 n2=n0 d_ep=0.031 i_s=qeye(2) if rank==0: t2=0 k in range (0,n1): n1=basis(n1+n2,k+n1) kk=k+1 t2=t2+kk*(n1*n1.dag()) t2=(d_ep/n1)*tensor(i_s,t2) else: t2=0 comm.bcast(t2, root=0) print t2,rank but when run code output looks this: 0 1 0 2 0 3 0 4 quantum object: dims = [[2, 4], [2, 4]], shape = [8, 8], type = oper, isherm = true qobj data = [[ 0. 0. 0. 0. 0. 0. 0. 0. ] [ 0. 0. 0. 0. 0. 0. 0. 0. ] [ 0. 0. 0.015

ssl - Java 6 ECDHE Cipher Suite Support -

the java cryptography architecture standard algorithm name documentation page java 6 lists ecdhe cipher suites. expect supported in java 6. yet neither ootb java 6 nor addition of jce unlimited strength policy files enabling them. the book bulletproof ssl , tls indicates java 6 supports ecdhe, caveat: enable , prioritize ecdhe suites on server. java 6 , 7 clients support these, , happily use them. (but note java 6 must switch using v3 handshake in order utilize ecdhe suites @ client level.) i'm assuming v3 handshake means sslv3? haven't tried if works, sslv3 not viable option due poodle vulnerability. what missing? the ssl/tls implementation "jsse" in java 1.6 , later supports ecdhe suites if there available (jce) provider needed ecc primitives. java 1.6 ootb not include such ecc provider, can add one. java 7 , 8 do include sunecc provider. this seems hot topic today. see https://security.stackexchange.com/questions/74270/which-fo

When does SCCM download updates -

i'm pretty sure know answer want sure. we have sccm 2012 r2. lately i've been receiving complaints boss when deploying updates saturating our internet line. i've configured distribution points not distribute updates during day via scheduling , rate limits in each distribution point can assume when creating deployment package update downloading files microsoft. true? what need able either proactively or reactively download updates in off hours ... occurred me, done through wusus console maybe? you should not have open wsus console, configuration should done through sccm console. sccm configure when , wsus go , check in microsoft. in sccm console go /administration/site configuration/sites/configure site components/software update point. on 'sync schedule' tab can see when wsus scheduled sync microsoft.

printing - Do Javascript changes to the DOM affect the print version of a page? -

there page need sorting via javascript. if such sorting, , user decides print page, original dom printed or updated dom? i see being original dom, reloads page, , applies @media print styles, or see switching css page. if there difference between browsers, care chrome , firefox. in both chrome , ff see updated dom in print preview , in chrome's network tab, no new interaction server logged. http://jsfiddle.net/zll4814s/ <h1 id="headertag">hello</h1> <button onclick="changetext()">click change text</button> js window.changetext = function() { document.getelementbyid('headertag').innerhtml = "bye"; window.print(); }

core data - Why is NSPersistentStoreCoordinator not recognizing my managed object model? -

Image
i trying create coredata store icloud. following example code in icloud programming guide core data , have piece of code: nspersistentstorecoordinator *coordinator = [[nspersistentstorecoordinator alloc] initwithmanagedobjectmodel: salonbook.xcdatamodeld]; this image of managed object model i'm getting error: use of undeclared identifier 'salonbook'. why? you're getting error because you're telling variable named salonbook , not declared. need pass reference nsmanagedobjectmodel instance here. commonly means you'd use self.managedobjectmodel , depends on rest of code. steps need be: create nsmanagedobjectmodel instance model file create nspersistentstorecoordinator using model object.

asp.net mvc - Styling a dropdownlist using bootstrap -

@using (html.beginform()) { <label class="btn btn-success">genre</label> @html.dropdownlist("moviegenre", "all") title: @html.textbox("searchstring") <input type="submit" class="btn btn-warning" data-loading-text="finished" value="filter" /> </p> can advise how style dropdown list in mvc using bootstrap. getting dropdownlist objects table , works fine can't style other defualt. @html.dropdownlist("moviegenre", (selectlist)viewbag.genre, "select genre", new { @class = "form-control" }) here code struggling grey area of drop down lists , styling

c++ - Take variable number of arguments and put them in std::vector -

i'm making class - let's call container - containing std::vector , special logic decides how vector values picked. want add method adding multiple values class 1 call. method adds 1 item: void loopgenerator::add(randomstripe &stripe) { stripes.push_back(new singlestripe(stripe)); } i'd similar method called this: loopgenerator gen = loopgenerator(); gen.add(randomstripe(), randomstripe(), randomstripe() ... , as want ... ); and add parameters inner std::vector . is possible standard libraries, or best without them? you can use std::initializer_list. example #include <initializer_list> #include <algorithm> #include <vector> #include <iterator> //... void loopgenerator::add( std::initializer_list<randomstripe> stripe ) { std::transform( stripe.begin(), stripe.end(), std::back_inserter( stripes ), []( const randomstripe &s ) { return new singlestripe( s ); } )

c++ - subsructing getchar's return value -

suppose have file consists of single string a1 if write this: char ch = getchar(); char ch1 = getchar(); cout << ch - 'a' << " " << ch1 - '0' << endl; i have 0 1 in output. if write this: cout << getchar() - 'a' << " " << getchar() - '0' << endl; i have -48 49 . doesnt getchar() return normal char? why result isn't same? you're getting issue because 2 calls getchar() evaluated in unspecified order, , compiler happens evaluate rightmost 1 first. c++ has rather loose rules regarding order of evaluation of subexpressions in expression, allow more optimisation opportunities. cout line 1 expression, following guaranteed: the first getchar() evaluated before first - the second getchar() evaluated before second - the first - evaluated before first << the second - evaluated before third << the << s evaluated in order left. n

Generic function with AnyObject fails -

i'm trying use generic function i'm getting segmentation fault. i'd simplify handling of restkit results creating generic function handle all. function cast array of result desired type, , call callback. here's code class func handlerestkitresult<t:anyobject>(mappingresult:rkmappingresult!,callback:([t])->void){ var resultarray = mappingresult.array(); if (resultarray [t]){ callback(resultarray [t]) } } seems have no errors. when run it, segmentation default, , handlerestkitresult<t:anyobject> . specifically anyobject part. if remove however, warning t not conform anyobject. am missing here? i'm know theres way can pass name of class/type string, , sort of magic. i'm still wondering whats going wrong here. thanks :)

javascript - Stop a bitmap when it collides with another bitmap -

i learning createjs , having issue game working on. i have keyboard movement , impact detection figured out, not happens after bitmaps collide. right pass through each other, , console logs impact. want happen when player (bitmap) hits wall (bitmap), player can no longer move in direction anymore. can help? <script type="text/javascript"> var stage; //big, root level container display objects //assign keycodes readable variables var keycode_a = 65; var keycode_d = 68; var keycode_w = 87; var keycode_s = 83; alphathreshold = 1; function init(){ stage = new createjs.stage("mycanvas"); startgame(); } function startgame(){ //load bitmaps player = new createjs.bitmap("assets/player-square.jpg"); player.x = 10; player.y = 200; stage.addchild(player); mazesquare = new createjs.bitmap("assets/maze-test.png"); mazesquare.x = 250; mazesquare.y = 0; stage.addchild(mazesquare); //mov

ob start - PHP multiple ob_start() and ob_end_clean() function not work -

Image
i have index page : <?php ob_start(); session_name('d12tyu'); @session_start(); ob_end_clean(); require abspath .'/config.php'; require abspath . '/class/backup.php'; ?> <!doctype html> <html> ....... html+<?php ?> code </html> in backup class have code download backup file : class db_backup { //other code public function download($file) { ob_start(); $filename = $this->dir . $file; $fp = fopen($filename, "rb"); header("pragma: public"); header("expires: 0"); header("cache-control: must-revalidate, post-check=0, pre-check=0"); header("cache-control: public"); header("content-description: file transfer"); header("content-type: application/octet-stream"); header("content-length: " . filesize($filename)); header("content-disposition: attachment;filename = " . $file . &qu

javascript - Positioning from fixed to static -

i need have fixed div on screen between points, defined whether elements on top of screen or not. i tried accomplish changing position via jquery. problem found is, @ bottom point, when change position fixed static , div jumps away, instead of start scrolling point on. here jsbin: http://jsbin.com/woroyejahe/5/ thanks just position of lower div , set top css style position: absolute .

java - Apache HTTP Client: build simulator using multithreaded environment -

i building standalone java application generate load on system, simulating real world conditions. the application multithreaded, using concurrent framework generate lots of pooled threads, each of runs "sessions". when session complete, runnable ends , thread returned scheduler pool. each "session" consists of following: generate http put #1 server wait x seconds (randomized within logical limit) generate http put #2 server generate http put #3 server wait y seconds (randomized within logical limit) generate http put #4 server generate http put #5 server approximately 2 minutes taken per session each thread created concurrent pool maintains connection (an httpclient) reused subsequent sessions. after each request call httprequest.releaseconnection() made, recommended. it works pretty well. perhaps well. while keeping connections open , releasing them gives optimum performance, since building simulator don't want optimal performance.

git - How to protect directory against getting committed changes when merging? -

i have 2 directories in our git repo, huge number (about 400) of commits divided between file updates in 2 directories, although no commits known include changes both directories within same commit. we need merge commits our feature branch master branch only one of directories, leaving files in other directory untouched. means don't want half commits applied master. what recommended way of doing that? you can't merge individual commits, can git cherry-pick individual commits onto master branch. use git log figure out sha1s of commits want on master, , use git cherry-pick apply them. it's not ideal solution, since cherry-pick introduces new commit that's different original commit, , therefore you'll have duplicate commits on master , feature branches. try avoid using cherry-pick. seems solve problem, proceed caution.

r - How do you sample groups in a data.table with a caveat -

this question similar how sample random rows within each group in data.table? . the difference in minor subtlety did not have enough reputation discuss question itself. let's change christopher manning's initial data little bit: > dt = data.table(a=c(1,1,1,1:15,1,1), b=sample(1:1000,20)) > dt b 1: 1 102 2: 1 5 3: 1 658 4: 1 499 5: 2 632 6: 3 186 7: 4 761 8: 5 150 9: 6 423 10: 7 832 11: 8 883 12: 9 247 13: 10 894 14: 11 141 15: 12 891 16: 13 488 17: 14 101 18: 15 677 19: 1 400 20: 1 467 if tried question's solution: > dt[,.sd[sample(.n,3)],by = a] error in sample.int(x, size, replace, prob) : cannot take sample larger population when 'replace = false' this because there values in column occur once. cannot sample 3 times values occur less 3 times without using replacement (which not want do). i struggling deal scenario. want sample 3 times when number of occurrences >= 3, pull number of occurrences if &

parsing - Parse CSV pull data and compare but not working. Java -

i have csv file created. trying pull data , run check data. csv file contents. "12/05/14","hay square","10.00","10","","","" "12/05/14","hay round","75","1","","","" "12/05/14","feed","12.50","10","","","" "12/05/14","feet","10","","trusty","","" "12/05/14","feed","4","5","","","" "12/05/14","wormer","12.75","","trusty","","" "12/05/14","feed","12","10","","","" "","feed","","","","","" "12/05/14","medicine",

vba - How to get the version number of an Excel workbook? -

i have excel book that's versioned in sharepoint document library, can go file tab , see versions like: 19.0: 11/10/2014 1:15 pm xyz\tkl2 17.0: 10/12/2014 3:54 pm xyz\tkl2 14.0: 10/11/2014 2:23 pm xyz\92jf i want retrieve recent version number, in case 19.0 . i've tried using following code: sub getversions() dim docversions documentlibraryversions dim dversion documentlibraryversion set docversions = thisworkbook.documentlibraryversions each dversion in docversions debug.print dversion.index debug.print dversion.comments debug.print dversion.creator debug.print dversion.modified debug.print dversion.modifiedby debug.print dversion.application next end sub this every property seems possible regarding particular document version. none of these properties retrieve actual version number; e.g., .index retrieve 1 , 2 , , 3 these versions. there way actual version number? you can information opening historical version of file, , f

html - Bootstrap 3: text on the left and right in the page header -

i'm trying make simple page header bootstrap 3. here's code: <div class="page-header"> <h1>text on left</h1> <h3 class="text-right">this right on same line</h3> </div> here's jsfiddle try: http://jsfiddle.net/dtchh/2450/ basically want have text on left , right inside page-header , on same line . the usual tricks of using float:left , float:right normal html "break" page-header , meaning text aligned displayed outside (under) page-header, remains empty. any clues? you can use "pull-right" , "pull-left" classes, "clearfix" class after. <div class="page-header"> <div class="pull-left"> <h1>text on left</h1> </div> <div class="pull-right"> <h3 class="text-right">this right on same line</h3> </div> <div class="clearfix"></di

c++ - How to write strings and integers in a ring buffer? -

how write strings , integers in ring buffer? write multiple strings , integers ring buffer c++ knowledge limited. if need more info, please let me know. appreciate can provide. here integer , string variables want write , write function of ring buffer: string payload; int byte_pos; size_t ringbuffer::write(u_char *data, size_t bytes) { if (bytes == 0) return 0; size_t capacity = capacity_; size_t bytes_to_write = std::min(bytes, capacity - size_); // write in single step if (bytes_to_write <= capacity - end_index_) { memcpy(data_ + end_index_, data, bytes_to_write); end_index_ += bytes_to_write; if (end_index_ == capacity) end_index_ = 0; } // write in 2 steps else { size_t size_1 = capacity - end_index_; memcpy(data_ + end_index_, data, size_1); size_t size_2 = bytes_to_write - size_1; memcpy(data_, data + size_1, size_2); end_index_ = size_2; } size_ += bytes_to_write; return bytes_to_write; } you have

xcode - How do I drag a UIView subclass into Interface Builder? -

Image
i'm following apple's tutorial on adding custom uiview sublcass interface builder. tell me first label uiview subclass. have done that: #import <uikit/uikit.h> ib_designable @interface loggedoutview : uiview @end then tell me drag uiview subclass object library in interface builder. don't know object library. guessing box in lower right of screen shows standard uiviews. search class in 4 sections of box , cannot find it. keep in mind first time i've ever used interface builder. code uiview subclasses. however, forced create xib ios 8's dynamic launch screens. (at least think xib's required flexibly layout launch screens on ios 8). quick answer: don't. the launch screen not load code @ all. merely nib file allows use auto layout layout views on screen. can use text in labels, images, etc... it's there can create launch screens different sizes of device , laid out correctly autolayout. you can't run code though. use pl

networking - scp not able to resolve dns name -

question first: know why scp won't resolve dns name wheezy ip address 192.168.164.144 while ping does? explanation & details second : while on os mavericks scp files terminal vmware fusion debian instance fine. had make sure ip address , machine name (wheezy) in both debian /etc/hosts file , in /etc/hosts file of mac. however after upgrading yosemite can't scp files virtual host using domain name . can scp files virtual machine if specify ip address. works: scp test_file.txt dan@192.168.165.144:~/ but not: scp test_file.txt dan@wheezy:~/ this boggles mind because host "wheezy" pings fine: bashdan@danrauxa ~ >>ping wheezy ping wheezy (192.168.165.144): 56 data bytes 64 bytes 192.168.165.144: icmp_seq=0 ttl=64 time=0.335 ms 64 bytes 192.168.165.144: icmp_seq=1 ttl=64 time=0.337 ms 64 bytes 192.168.165.144: icmp_seq=2 ttl=64 time=0.290 ms ^c --- wheezy ping statistics --- 3 packets transmitted, 3 packets received, 0.0% packet loss rou

ios - Exporting large audio files -

i created audio recorder app saves audio files in m4a format. decided add export feature allow users email , text audio recordings. works nicely when audio files no bigger 20mb. however, audio file above 20mb fail export. best way export files out of app? thinking google drive or dropbox, user have have registered account. there services can upload file , receive link can emailed user? there plenty of services that. dropbox example. here overview: http://alternativeto.net/software/dropbox/

javascript - AttributeError: 'unicode' object has no attribute 'get' - In Django Forms -

i'm trying use django forms ajax calls. previously used html form information through request.post['item']. i've been thinking validators, , benefit if switched normal html forms django forms. in html code (the page user clicks, , ajax calls view javascript): if not request.user.is_authenticated(): #tells user login if not authenticated return redirect('/webapp/login.html') else: #get logger logger = logging.getlogger('views.logger.chartconfigure') logger_uuid = uuid.uuid4() logger_time = datetime.datetime.now() #log user logger.info("request in editchart, user:" + str(request.user.username) + ", uuid:" + str(logger_uuid) + ", time:" + str(logger_time)) #forms use chartname = changechartnameform(auto_id=false) #put forms context context = {'chartnameform': chartname} #return context return render(request, 'webapp/editchart.html', context)

c - Passing structures in pthread -

i trying pass structure when creating thread not seem work correctly! here structure: struct analyse_data { int verbose; //should 1 or 0 }; note verbose can 1 or 0 , nothing else. here method being called (note can called multiple times method): void dispatch(struct pcap_pkthdr *header, const unsigned char *packet, int verbose) { static bool thread_settings_initialised = false; printf("verbose: %d\n", verbose); //prints 1 or 0 //only run first time dispatch method runs if (thread_settings_initialised == false){ thread_settings_initialised = true; //... //set mutex appropriate variables remain thread safe //... //set attr threads "detached" pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, pthread_create_detached); //set pthread_cond_init //... } //put parameters struct can sent in thread struct analyse_data data

javascript - Replicating a chropleth in D3.js using d3.tsv -

Image
i'm trying replicate mike bostock's chropleth using topojson file of mexican municipalties , coloring using .tsv matching id values polygons. so far i've been able show map , polygons can't color based on values .tsv file. i suspect problem in function i'm not entirely sure calling .tsv inside function queue() .defer(d3.json, "mx5.topojson") .defer(d3.tsv, "cosecha.tsv", function(d) { ratebyid.set(d.id, +d.rate); }) .await(ready); function ready(error, mx5) { svg.append("g") .attr("class", "mx4") .selectall("path") .data(topojson.feature(mx5, mx5.objects.mx4).features) .enter().append("path") .attr("class", function(d) { return quantize(ratebyid.get(d.id)); }) .attr("d", path); svg.append("path") .datum(topojson.mesh(mx5, mx5.objects.estados, function(a, b) { return !== b; })) .attr("cl

python - How to use len() to create an equal-length string full of asterisks? -

my assignment create game of hangman. i'm trying turn "someword" "********" display player, code returns 1 asterisk many given input. the following text file i'm reading words from: python different (it continues many lines) here's code: import random def diction(random): lives = 5 dictionary = {"secretword" : random, "lives" : lives} guess = len(dictionary["secretword"]) * "*" print (dictionary["secretword"]) print (guess) file = input("please insert file name: ") f = open(file) content = f.readlines() f.close() random = (random.choice(content)) random = random.replace(" ", "") diction(random) i'm expecting output of (for example) python ****** and instead getting output of python ******* the problem here file.readlines leaves trailing newline character, file like foo bar spam eggs becomes ['foo\n

Visual studio c++ adding copy of file to solution -

when using c# add existing item , put copy of in project. want project in c++ whenever default seems add link, giving errors if move original files. add link option not appear in drop down on add normally. how can add copies of these files (header files , source files) new copies made in project. the easiest answer copy file(s) manually desired solution folder, use add existing item.

recursion - Issue with returning value in recursive function PHP -

have issue returning value in recursive function. can echo it. wrong this? function calculate($i,$count=1) { $str_i = (string)$i; $rslt = 1; ($k=0; $k<strlen($str_i); $k++) { $rslt = $str_i[$k]*$rslt; } if ( strlen((string)$rslt) > 1 ) { $this->calculate($rslt,++$count); } elseif ( strlen((string)$rslt) == 1 ) { return $count; } } in if in code value returned in recursive call not used. don't set value or return it. every call except base case doesn't return value. try this: function calculate($i,$count=1) { $str_i = (string)$i; $rslt = 1; ($k=0; $k<strlen($str_i); $k++) { $rslt = $str_i[$k]*$rslt; } if ( strlen((string)$rslt) > 1 ) { return $this->calculate($rslt,$count+1); // changed line } elseif ( strlen((string)$rslt) == 1 ) { return $count; } } now return value returned recursive call. note changed ++$count $count+1 sin

Does OpenCL support array initializers, including default initialization with 0? -

inside kernel, need array of accumulators. __kernel mykernel(...) { float accum[size] = {}; for(i=0; i<iter; ++i) { accum[...] += ... } ... } in c, = {} initialize array me filled 0, i'm not sure if that's case in opencl? need following, or waste of cycles? float accum[size]; for(int i=0; i<size; ++i) accum[i] = 0; opencl c derivative of iso/iec 9899:1999 c language specification, aka c99. in both specifications, yes, = { 0 } zero-initialize array (note 0 , empty initializer lists not allowed in c ). in practice, implementations may clear device private's and/or local memory zeroes before launch kernel, not behavior can rely on.

c++ function pointers giving runtime error when passed to push_heap -

i'm implementing djikstra's shortest path algorithm , using priority queue determine node visit next, can't use std::priority_queue because application requires heap rebuilt in place. wrote own wrapper functions std::make_heap() , std::push_heap() , , std::pop_heap() , i'm passing own comparator them, returns null pointer error during runtime. have feeling i'm either not passing function pointer correctly or function pointer isnt being initialized correctly. here's code initializing function pointer bool shortestdisttohere(const node& lhs, const node& rhs){ return distances[lhs.xpos][lhs.ypos] < distances[rhs.xpos][rhs.ypos]; } bool (*shortestdist)(const node& lhs, const node& rhs) = &shortestdisttohere; and here's function call using it push_heap(queuevector.begin(), queuevector.end(), shortestdist); edit: in comments metioned there error when tried call or other on predicate. well, turns out visual studio 11 doe

asp.net web api - Using Azure Mobile Services client SDK with non azure hosted custom API -

i'm new azure mobile services may stupid question, of working client sdk offline sync framework. (i haven't seen other offline client sync frameworks in c# work xamarin) but unfortunately not building api , instead i'm working against existing web api cannot changed or moved azure hosting. is scenario possible , has got working? if so, there standards api need conform (above standard asp.net web api correct http verbs) right now, client sdk hard coded make calls <mobile service url>/table/, etc. team looking @ options of letting client sdk consume other endpoints, awhile yet. you possibly using httphandler, , changing outgoing http request url. (ie. /table/tablename , redirect custom path) pretty messy @ point. its possible wrap call api within mobile services sdk well. cleaner above, drawback of adding middle man. if shape incompatible required offline, easier tweak expected format.

javascript - jVectorMap height:% does not work -

Image
i using library: http://jvectormap.com/ create map website. attempting set width , height of map 100% through style attribute make map display @ full-screen size. when specify following: <div id="map1" style="width: 100%; height: 100%"></div> the map displays follows: the width attribute appears work correctly, height attribute not. when resize window, width scales correctly, whereas height appears scale regardless of whether scale image or down. how can make map appear specified scale using percentage? try in css: head { height:100%; } #map1 { position:absolute; height:100%; } setting height of head element 100% sets definition map height be.

java - Dynamic Webservices project -- can only connect over localhost -

i'm running restful webservice created in eclipse java ee using tomcat 7.0. test using web browser. connect on localhost, not remote ip. used work ip, , moved project git repository upload github. it's not working ip. not sure what's up. any ideas? firewalls off too. bonus: have small red x error icon on project. can't find errors , compiles fine , works fine long it's localhost. how heck rid of x icon? edit: works local ip. testing on college network earlier. i'm on home network. comments? hope following article helps : www.sitepoint.com/accessing-localhost-from-anywhere incase have trouble accessing via localhost refer answers post: stackoverflow.com/questions/2280064/tomcat-started-in-eclipse-but-unable-to-connect-to-http-localhost8085 the question missing many details logs.. url , configuration tomcat give specific answer

Looping through character data and items from MySQL DB in PHP -

i have following code: include "config.php"; error_reporting(0); $idsuccess = 0; if(isset($_post['username'])) { $usr = $_post['username']; $pwd = $_post['userpwd']; $sqlq = "select * dr_users dr_user_name='$usr' , dr_user_pwd='$pwd' limit 1"; $q = mysql_query($sqlq); if(mysql_num_rows($q) > 0) { $usero = mysql_fetch_assoc($q); $userdata = array('userid' => $usero['dr_user_id'], 'username' => $usero['dr_user_name'], 'userpwd' => $usero['dr_user_pwd'], 'usereml' => $usero['dr_user_email'], 'privlvl' => $usero['dr_user_priv_level']); $idsuccess = 1; $uid = $usero['dr_user_id']; $charq = mysql_query("select * dr_chars dr_user_id='$uid'"); while($char = mysql_fetch_array($charq)) { $chars[] = $char;

Trying to play sound from a URL Java -

i having troubles playing sound url. here current code, public static void aplay(string url) throws malformedurlexception, unsupportedaudiofileexception, ioexception, lineunavailableexception { clip c = audiosystem.getclip(); audioinputstream = audiosystem.getaudioinputstream(new url(url)); clip c = audiosystem.getclip(); c.open(a); c.start(); } also, have method in 'main' method. put https://translate.google.com/translate_tts?ie=utf-8&tl=en&q=hi%20there 'url' , not work, , respond 403 (server returned http response code: 403). wondering if fix this. thanks, dan the url sound file google translate. in order prevent misuse of google services, server performs few heuristic checks tries tell whether it's human or automated service accessing url. that's why replies 403, means "forbidden". disclaimer: consider why forbid , check terms of usage. opening url directly in browser ch

jquery - Javascript stops working on entering multiple class name -

i simple problem here javascript. have js code use highlight rows in price table. issue if used multiple class names @ time stops working. example: <div class="el1 someclass">hover not work in this</div> <div class="el1">hover work in this</div> the js: var classes = ["el1", "el2", "el3", "el4", "el5", "el6", "el7", "el8", "el9","el10","el11","el12", "el13","el14","el15","el16","el17","el18","el19","el20","el21","el22", "el23", "el24","el25" ]; //list of classes var elms = {}; var n = {}, nclasses = classes.length; function changecolor(classname, color) { var curn = n[classname]; for(var = 0; < curn; ++) { elms[classname][i].style.backgroundcolor = color; } } for

javascript - How to rewrite table using ajax response -

i'm trying re-write table using javascript , ajax. here request has been sent , response arrived innerhtml cannot re-write table content response text. here code. <table> <tbody id='product1'> <tr> <td> product name:</td> <td>p1</td> </tr> </tbody> </table> javascript function compareprod(prodid,tid){ browse(); var url = 'process.jsp'; url += '?compareprod='+prodid; xmlhttp.onreadystatechange = changeprod(tid); xmlhttp.open('post', url, true); xmlhttp.send(null); } function changeprod(tid) { if (xmlhttp.readystate == 4 || xmlhttp.readystate == 'complete') { document.getelementbyid('product1').innerhtml = xmlhttp.responsetext; } } process.jsp <tr> <td> product name:</td> <td>p2</td>

jquery. $.post shows content of php file. Click on button in the php content start function defined in main file -

for example file main.php here on document ready function includes content of php file (named include.php ). this content of main.php (function(){ $.post("include.php", function(show_some_content) { $('#id_show_some_conent').html(show_some_content); }); })(); also jquery function $(".click_to_test").click(function(){ alert('.click_to_test clicked.'); }); and html <div id="id_show_some_conent"></div> as result in id_show_some_conent contains content of include.php include.php contains echo '<button id="some_id" class="click_to_test"> click</button>'; so on document ready see button click. expect, if click on button, alert('.click_to_test clicked.'); . no, not work. if in include.php paste $(".click_to_test").click(function(){ works. how work if $(".click_to_test").click(function(){ in main.php ? you can try binding

.PHP specific Laravel route and NGINX issue -

i deploying laravel application on nginx i have route specified in routes.php handling non-blade php files , of blade php files route::any('/{pagephp}.php',function($pagephp) { return view::make($pagephp); //this handle .php blades }); but no input file specified error whenever try access files such terms.blade.php note not error when access specified routes. e.g. have signin.blade.php have route::get('/signin',function() { return view::make('signin'); }); when looked in error log see [error] 969#0: *91 fastcgi sent in stderr: "unable open primary script: /var/www/xxxx/public/terms.php (no such file or directory)" while reading response header upstream, client: xxxxxxxx, server: xxxx, request: "get /terms.php http/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: as per error, nginx trying terms.php in public directory , not sending route.php there way fix this? my nginx config file follow

How to set a model value from child controller to a model in parent controller in angularjs -

i stuck in application have table containing input fields entering expense_id value , amount. amount element bound custom directive hitting ctrl+enter add new tr containing empty fields.now while submitting unable calculate total amount of amount fields. here markup <table class="table table-bordered table-hover table-condensed"> <tr class="info" style="font-weight: bold"> <td>expence type</td> <td>amt</td> </tr> <tr ng-repeat="expense in expenceentry"> <td> <!-- editable username (text validation) --> <span editable-text="expense.expensetype_id" ng-model="expense.expensetype_id"

sql - select email, count(*) from emp group by email -

i have table columns name , email . table has 10 records. want send email records. query that? try this: select distinct email emp

javascript - HTML5 Drawing on multiple canvases images don't show up on one of them -

working on sort of proof-of-concept object-oriented javascript project emulates chessboard. i've got 4 canvases set up, each set 2 different boards , 2 "sidebar" canvases display current turn , list of pieces taken associated game. here's screenshot of looks currently: http://i.imgur.com/gpovkk2.png the problem is, elements within second sidebar whatever reason drawing in first sidebar, , haven't been able figure out why. here's code files project broken out , explained best of ability: index.html <!doctype html> <html> <head> <script type="text/javascript" src="scripts/marker.js"></script> <script type="text/javascript" src="scripts/turnmarker.js"></script> <script type="text/javascript" src="scripts/gametoken.js"></script> <script type="text/javascript" src="scripts/gameboard.js"></script