Posts

Showing posts from August, 2011

php - Move Wordpress sidebar from top to left -

i have blog section on website , while sidebar displayed on left side in blog category list or latest posts page, on single post sidebar on top . i've had problems single.php page i've started again scratch. latest posts page http://www.crossfitawac.com/blog/ , when click on post title sidebar calendar widget display single post same in latest posts page . i've tried copy lines "latest posts" page template didn't work out. here single.php http://pastebin.com/wm08wjri there errors code added. changed below in way should work , not divs tangled up: <?php get_header(); ?> <div id="page-content" class="page-content"> <section class="page-header" id="page-header"> <div class="row"> <!-- begin sidebar --> <div class="three columns"> <div class="sidebar"> <

Insert PHP inside HTML -

i trying out php mail service getting variable db , insert value html test trying out this: <?php include("db/dbvalue.php"); include("emailfun/email.php"); $response = array(); $emailaddress = "probh@pro.com"; $dt = new datetime(); echo $dt->format('m-d'); $m = $dt->format('m'); $d = $dt->format('d'); $result = mysql_query("select * namevalue type = 'boys' , month = '$m' , date = '$d'"); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result)) { $name = $row["name"]; $to= $emailaddress; $subject ="congratulations"; $message=" <html> <head> <title>html email</title> </head> <body> <p>name goes here: <?php echo $name; ?> </p> </body> </html> "; $from = "mailsender@pro

java - Sharing the audio file located on an url with other apps in android -

my android application has mp3 files sitting on amazon s3 bucket. have url access audio clip. able play audio clip using mediaplayer passing url data source of media player. i creating application lets user share audio clips app other im apps whatsapp. so, provide share widget on activity , upon cliking on widget whatsapp should opened , user should able select contact wants share audio clip. for need download audio clip local storage system , share file other app using contenturi. unable figure out best way it. as per android documentation below code canbe used send binary files: intent shareintent = new intent(); shareintent.setaction(intent.action_send); shareintent.putextra(intent.extra_stream, uritoimage); shareintent.settype("image/jpeg"); startactivity(intent.createchooser(shareintent, getresources().gettext(r.string.send_to))); i assuming audio files binary files. so, using below code send audio clip. intent intent = new intent(android.content.inten

c++ - Print Vector elements using Boost.Bind -

i need print values inserted in vector using boost.bind. please find code snippet below: please let me know missing here? class test { int i; public: test() {} test(int _i) { = _i; } void print() { cout << << ","; } }; int main() { std::vector<test> vtest; test w1(5); test w2(6); test w3(7); vtest.push_back(w1); vtest.push_back(w2); vtest.push_back(w3); std::for_each(vtest.begin(), vtest.end(),boost::bind(boost::mem_fn(&test::print), _1, ?)); // how print vector elements here? } you can without boost this #include <iostream> #include <vector> #include <algorithm> #include <functional> class test { int i; public: test() { } test(int _i) { = _i; } void print() const { std::cout <<

How to install/compile SDL2 C code on Linux/Ubuntu -

i'm doing c programming , want use sdl library. want build small 2d game in c on linux sharp skills bit. my issue i'm not super makefile user nor library on linux super user, configure things once when on project , that's it. so have trouble compiling sdl2 programs on ubuntu 14.04. i downloaded latest sdl library : http://www.libsdl.org/download-2.0.php then installed default step: ./configure make sudo make install after can see there in /usr/include/sdl2 guess installed. #include <stdlib.h> #include <stdio.h> #include <sdl2/sdl.h> int main(int argc, char *argv[]) { printf(“sdl test\n”); return 0; } because i'm still learning makefiles , sdl didn't figure out make it. but found makefile compile old sdl not sdl2 cpp=gcc cflags=-o3 ldflags=-lsdl -lsdl_mixer #linker exec=test all: ${exec} ${exec}: ${exec}.o ${cpp} $(cflags) -o ${exec} ${exec}.o ${ldflags} ${exec}.o: ${exec}.c ${cpp} $(cflags) -o ${exec}

apache - Unable to create a file on Ubuntu server using Flask and Python -

i using f = open('name.json','w+') create new file , write it. unable create file. apache server logs show "no such file exists." solved giving absolute path. trying combinations of paths , gave absolute path /var/www/arxiv/static/data/name.json , worked.

android - General regarding service class and multithreading -

i running code, user selects date , time. user can select date , time in future. these dates , time stored in sqlite database. after user selects dates , time, activity calls service class, running new thread in following way public int onstartcommand(intent intent, int flags, int startid) { final alarmmanager alarmmanager = (alarmmanager) getsystemservice(context.alarm_service); final sqlitecontroller db = new sqlitecontroller(getapplicationcontext()); new thread(new runnable() { @override public void run() { list<greetings> greetings = db.getallgreetings(); if (db.getgreetingscount() >= 0) { { (greetings g : greetings) { calendar cal = calendar.getinstance(); ......... .........//other codes this thread access data database , matches time , date system time , date. 1 date , time matches, using alarm manager broa

c++ - Wierd Raytracing Artifacts -

Image
i trying create ray tracer using qt, have weird artifacts going on. before implemented shading, had 4 spheres, 3 triangles , 2 bounded planes in scene. showed expected , color expected however, planes, see dots same color background. these dots stay static view position, if moved camera around dots move around well. affected planes , triangles , never appear on spheres. 1 implemented shading issue got worse. dots appear on spheres in light source, part affected diffuse. also, 1 plane of pure blue (rgb 0,0,255) has gone straight black. since have 2 planes switched colors , again blue 1 went black, it's color issue , not plane issue. if has suggestions problem or wants see particular code let me know. #include "plane.h" #include "intersection.h" #include <math.h> #include <iostream> plane::plane(qvector3d bottomleftvertex, qvector3d toprightvertex, qvector3d normal, qvector3d point, material *material) { mincoords_.setx

Toggle text in JavaScript -

is there easier way toggle 2 or more text visibility? when i've used .toggle() method, text jumps , down, because toggled @ same time. .fadein() , .fadeout() working correctly, code messy. var triggertitle = function() { var hasclasshide = $(".hero-title.1").hasclass("hide"); if (hasclasshide) { $(".hero-title.1").removeclass("hide"); $(".hero-title.1").fadein(1000); $(".hero-title.2").addclass("hide"); $(".hero-title.2").fadeout(1000); $(".hero-title.2").css("display", "none"); } else { $(".hero-title.2").removeclass("hide"); $(".hero-title.2").fadein(1000); $(".hero-title.1").addclass("hide"); $(".hero-title.1").fadeout(1000); $(".hero-title.1").css("display", "none"); } }; setinterval(triggertitle, 3000

&& operators issue in MATLAB -

here code: friendly_output = num2str(std(counts_channel),'%.4f'); if friendly_output > 0 && friendly_output <= 1000 variable = 100 elseif friendly_output > 1000 && friendly_output <= 1500 variable = 500 the variable friendly_output here decimal number. however, while executing code, prompts me error: operands || , && operators must convertible logical scalar values i tried solve issue replacing && & , program works, variable friendly_output failed catch correct if statement. i tried output value of friendly_output , value correct statement goes wrong. thank you. if guess correct, friendly_output of type char to check that, try this: class(friendly_output) if need compare integer, need convert number. to add code after first line friendly_output = str2double(friendly_output); %// changed `eval` `str2double` suggested @horchler %// using `str2double` on `eval` or `str2num` best p

how to use the result of impute.mean function in R? -

i have dataset of 1302 sample in create mcar nas deleting 5 percent of training part. try impute 5 percent mean of other 95%. don't know how access result produced impute.mean function of hotdeckimputation package . in package manual guide, says result in form of matrix, can tell me how define matrix record result? according package, matrix should have same size input of function(data). you can see code below: navalues = imptrainfolds[sample(nrow(trainfolds), 5),i] imptrainfolds[navalues,i] = na if(imptype == "mean"){ #calculate mean remaining samples ? = impute.mean(data = as.matrix(imptrainfolds[[i]])) } broadly speaking, if intention replace missing values in data using means, can use code below: # simulate data n <- 10000 x1 <- rbinom(n,1,prob=.4) x2 <- rnorm(n,0,1) dta <- data.frame(x1, x2) dta$x2[dta$x1 == 1] <- na # replace missing data (i in which(sapply(dta, is.numeric))) { dta[is.na(dta[, i]), i] <- mean(dta[, i]

phpstorm - Intellij - Hide file paths from Favorites window -

Image
i organized project files in favourites window according programming language e.g. python, javascript etc. however, path each file takes lot of space , requires horizontaly scroll window. is there way hide path favourites, file names visible? if not, there way organize files in same way without changing project structure? it's not possible hide paths. https://youtrack.jetbrains.com/issue/ideabkl-4374 -- watch ticket (star/vote/comment) notified on progress. please note aforementioned ticket in "backlog" section -- such tickets unlikely implemented in nearest future (especially if have virtually no votes).

multithreading - Implementing MVC paradigm in Swing (Java) using Threads -

i trying implement mvc paradigm in java (swing) using multithreading. currently, extending view class observer class , and model class observable class , working fine (my code bulit along example: http://austintek.com/mvc/ ). controller class calls corresponding model , view functions , there main "glue" program sets everything. however, approach not utilize threads. is there way implement using threads and observer/observable class @ same time? (my aim implement each of m, v , c separate thread) the following part of view code: public class view implements observer { /*************************************** view ************************************* ** ** function constructor of view class. ** ** pre: <nothing> ** post: gui created , directory displayed on screen. ** return: <n/a> ** **/ view(string name) { threadname = name; //frame in constructor , not attribute doesn

java - How to create hover on JLabel to show Menubar? -

how make show menu bar upon user hovered cursor on jlabel? i'm little bit confused mouseevent, etc. here code: public class menupage extends jframe implements actionlistener { private jlabel fshirts, tshirts, sweater, jeans, shoes, hats, bags; private jbutton btncart, btnexit; private jpanel leftpane, rightpane; private container cont; public menupage() { super ("menu"); cont = getcontentpane(); cont.setlayout (new borderlayout()); fshirts = new jlabel ("formal shirts", swingconstants.center); tshirts = new jlabel ("t - shirts", swingconstants.center); sweater = new jlabel ("sweater", swingconstants.center); jeans = new jlabel ("jeans", swingconstants.center); shoes = new jlabel ("shoes", swingconstants.center); hats = new jlabel ("hats", swingconstants.center); bags = new jlabel ("bags", swin

grails - How to reuse custom validation logic in multiple fields from the same Domain -

i intend use custom validator check not null values in specific conditions in domain class. same check should run in more 1 field. "factored" validation closure , tried pass parameter each validator key in constraints clause. string type string description string size static constraints = { description(nullable:true, validator: notnullifcustom) size(nullable:true, validator: notnullifcustom) } def notnullifcustom = { val, object -> if (object.type == 'custom' && ! val) return "must provide value field ${0} when type custom" } nevertheless, grails throws missingpropertyexception message 'no such property: notnullifcustom class... possible solutions: notnullifcustom'. if copy , paste closure body each validator entry inside constraints clause, runs expected. ps: don't want use shared validator because i'm not sharing validator between domain classes, between fields within same domain.

sockets - Does listen() backlog affect established TCP connections? -

would naive create tcp socket listen backlog set minimum way of rate limiting new incoming connections? server workload in question doesn't expect many new connections @ time spends lot of time servicing long open persistent connections. appears new incoming connections shouldn't affect established connections, though i've been unable find definitive answer in text. possible failed new incoming connections create kind of tcp traffic congestion on server packets it's receiving or dropped fast enough has no effect on buffers or other part of network stack? specifically platform in use linux, , although may handled differently in different oss, expect them behave same. edit mean "same" backlog doesn't affect established connections, though understand linux discards them while windows sends reset. does listen() backlog affect established tcp connections? it affects established connections server hasn't accepted yet via accept(), in

symfony - Updated entity adds new row to database -

i trying update entities using ajax adds new row instead update existing one. my entities: category product subcategory relations : category manytomany product category onetomany subcategory category entity /** * @orm\manytomany(targetentity="test\corebundle\entity\product", inversedby="categories", cascade={"persist"}) * @groups({"public", "admin"}) */ protected $products; public function setproducts( $products) { $this->products= new arraycollection($products->toarray()); return $this; } product entity /** * @orm\manytomany(targetentity="test\corebundle\entity\category", mappedby="products" ) * @exclude() */ protected $categories; controller $tosave = $this->get('request')->getcontent(); $s = $serializer->deserialize($tosave, test\corebundle\entity\category, 'json');

c# - No value given for required parameters, with value -

i'm working in c#/asp.net on web app. part of app, want connect ms-access database, , values dataset . for reason, error in title when filling dataset dataadaptor - despite this, when use breakpoints, can see command follows: select ..... itemid = @value0 (if need parameters, ask them , i`ll copy whole thing). i can see @value0 has value 2 breakpoints, , assured it's value in query. my question is, how happen? if value in query filled, missing? edit : full query: select itemname name,itempicture picture,itemheromodif assistance,itemtroopmodif charisma, herbcost herbs, gemcost gems item itemid = @value0" full building code (generating query each user requires different amount of items, 1 has single item, i've used test): static public dataset getusershopitemds(string username,list<shopitem> items) { string madeforcommand = "select itemname name,itempicture picture,itemheromodif assistance,itemtroopmodif charisma, herbcost herbs, gemcost gem

winforms - Image property not found in runtime PictureBox control c# -

image property not found item variable. code - foreach (control item in this.controls) //iterating controls on form { if (item picturebox) { if (item.tag.tostring() == ipaddress + "onoff") { methodinvoker action = delegate { item.image= }; //.image property not shown item.begininvoke(action); break; } } } any please? your item variable still of type control . checking instance referencing picturebox not change that. change code to: foreach (control item in this.controls) //iterating controls on form { var pb = item picturebox; // can access picturebox, if 1 if (pb != null) { if (item.tag.tostring() == ipaddress + "onoff") { methodinvoker action = delegate { pb.image = ... // works }; bp.begininvoke(action); break; } } }

Trouble printing out values from an array in C -

i'm writing program calculate area , perimeter of polygon when given set of input values. far has worked , i'm happy output stage 3, problem encountering seems quite trivial can't seem locate it. in stage 3 attempting calculate largest polygon area need print out (x,y) coordinates assigned polygon. have method of determining largest polygon, works , outputs correct polygon, when try , read (x,y) coordinates polygon array , print values nothing in return, though compiles fine. i'm concerned printing out values in array on else. this output require: stage 3 ======= largest polygon 15643 x_val y_val 1.0 2.0 4.0 5.0 7.8 3.5 5.0 0.4 1.0 0.4 this output receiving: stage 3 ======= largest polygon 15643 x_val y_val here written code: #include <stdio.h> #include <stdlib.h> #include <math.h> #define max_polys 100 #define max_pts 100 #define end_input 0 #define pi 3.141592653589793 #define per_row

xamarin.android - RestRequest in Xamarin over Android -

i'm having same problem reported here: http://forums.xamarin.com/discussion/18907/system-net-webexception-error-connectfailure-network-is-unreachable i upgraded xamarin v3, , working app no longer able access network, not localhost. can see full network access enabled in deployed app on android 4.3 galaxy siii, while emulator works. i've tried both restclient shown below, , httpwebrequest same results. using new project using recipe http://developer.xamarin.com/recipes/android/web_services/consuming_services/call_a_rest_web_service/ gives same result. updated current far can tell. var client = new restclient("http://192.168.0.111"); var request = new restrequest("api/item/getitems", method.get); var response = _client.execute(request); if (response.responsestatus == responsestatus.completed && response.statuscode != httpstatuscode.internalservererror) { results = jsonconvert.deserializeobject<ienumerable<item>>(response.conte

jquery - Change CSS based on scroll position -- Refactoring bad code -

i have written jquery function changes css value of nav menu item based on if reference section viewable in window. $(window).scroll(function() { var scroll = $(window).scrolltop(); if (scroll <= 590) { $("#menu-item-25 a").addclass('blue'); $("#menu-item-26 a").removeclass('blue'); $("#menu-item-22 a").removeclass('blue'); $("#menu-item-23 a").removeclass('blue'); $("#menu-item-24 a").removeclass('blue'); } else if (scroll >= 591 && scroll <= 1380) { $("#menu-item-26 a").addclass('blue'); $("#menu-item-25 a").removeclass('blue'); $("#menu-item-22 a").removeclass('blue'); $("#menu-item-23 a").removeclass('blue'); $("#menu-item-24 a").removeclass('blue'); } else if (scroll >= 1381

c++ - Trouble with strcpy function -

i have user defined class, 1 of members char* type. when try initialize in constructor error saying error c4996: 'strcpy': function or variable may unsafe. consider using strcpy_s instead. however, when changed strcpy strcpy_s, still give following error intellisense: no instance of overloaded function "strcpy_s" matches argument list argument types are: (char *, char *) let's student class , char* name; 1 of data members.so, constructor like: student (char* s = null) { if (s != null) { name = new char[strlen(s) + 1]; //strcpy(name,s); strcpy_s(name,s); } } it's because strcpy_s requires additional parameter specify how many bytes copy. see here: http://www.cplusplus.com/forum/beginner/118771/

Add Key and Value into an Priority Queue and Sort by Key in Java -

i trying take in list of strings , add them priority queue key , value. key being word , value being string value of word. need sort queue highest string value first. priority queue not letting me add 2 values. public static list<string> pqsortstrings(list<string> strings) { priorityqueue<string, integer> q = new priorityqueue<>(); (int x = 0; x < strings.size(); x++) { q.add(strings.get(x),calculatestringvalue(strings.get(x))); } return strings; } problem priorityqueue can store single object in it's each node. trying can not done is. but can compose both objects in single class , use priorityqueue . you either need supply comparator or rely on natural ordering implementing comparable interface. solution create class has string , int it's members. public class entry { private string key; private int value; // constructors, getters etc. } implement comparable interface , deleg

R multinomial logistic regresion, Error in eval(expr, envir, enclos) : object not found -

i have csv file on want fit multinomial regression model. dependent variable 'topic' (the first column in csv) , have 200 factors (named x0 ... x199). tried: require(nnet) mydata <- read.csv('data/data.csv') mydata$topic <- factor(mydata$topic) colnames(mydata) which results in [1] "topic" "x0" "x1" "x2" "x3" "x4" "x5" .... now want multinomial logistic regression model: x = paste('x0', paste('+',paste('x', 1:199, sep=''), sep='', collapse=" ")) vars = paste('topic ~ ', x ,sep='', collapse=" ") print(vars) output: topic ~ x0 +x1 +x2 +x3 +x4 +x5 +x6 +x7 +x8 +x9 +.... fitting multinomial model: test <- multinom(vars, data=mydata, maxnwts=2000) output: .... iter 80 value 23059.928035 iter 90 value 23055.453099 iter 100 value 23051.468665 final value 23051.468665 stopped after

javascript - Looping through array and removing items, without breaking for loop -

i have following loop, , when use splice() remove item, 'seconds' undefined. check if it's undefined, feel there's more elegant way this. desire delete item , keep on going. for (i = 0, len = auction.auctions.length; < len; i++) { auction = auction.auctions[i]; auction.auctions[i]['seconds'] --; if (auction.seconds < 0) { auction.auctions.splice(i, 1); } } the array being re-indexed when .splice() , means you'll skip on index when 1 removed, , cached .length obsolete. to fix it, you'd either need decrement i after .splice() , or iterate in reverse... var = auction.auctions.length while (i--) { .... } this way re-indexing doesn't affect next item in iteration, since indexing affects items current point end of array, , next item in iteration lower current point.

Swift IOS - Using UIPickerView AND Keyboard -

in app when user clicks on uitextfield should able pick value uipickerview or enter own value using keyboard. what's best way of doing in terms of user experience , ease of implementation? uipickerview toolbar implemented. i'd appreciate both advice on best way of doing , example code of switching keyboard <-> pickerview. i've tried adding button "show keyboard" on pickerview's toolbar , adding following code: func showkeyboard() { selectedtextfield.inputview = nil } but clicking button doesn't anything. i'm not sure it's way in terms of ux. here's solution: var usekeyboard:bool = true func showkeyboard() { if usekeyboard { usekeyboard = false selectedtextfield.inputview = nil selectedtextfield.reloadinputviews() selectedtextfield.keyboardappearance = uikeyboardappearance.default selectedtextfield.keyboardtype = uikeyboardtype.default } else { usekeyboa

java - Extracting even digits from int -

here problem solving. write method evendigits accepts integer parameter n , returns integer formed removing odd digits n. following table shows several calls , expected return values: call valued returned evendigits(8342116); 8426 evendigits(4109); 40 evendigits(8); 8 evendigits(-34512); -42 evendigits(-163505); -60 evendigits(3052); 2 evendigits(7010496); 46 evendigits(35179); 0 evendigits(5307); 0 evendigits(7); 0 if negative number digits other 0 passed method, result should negative, shown above when -34512 passed. leading zeros in result should ignored , if there no digits other 0 in number, method should return 0, shown in last 3 outputs. i have far - public static int evendigits(int n) {     if (n != 0) {          int new_x = 0; int temp = 0; string subs = "";     string x_str = integer.tostring(n); if (x_str.substring(0, 1).equals("-")) {  temp = integer.parseint(x_str.substrin

Fail deploy from jenkins to Tomcat 7 -

i have jenkins running on openshift , need build , deploy application tomcat. can´t deploy application tomcat 7. obs: tomcat 7 running on computer. following error: started user jenkins admin building in workspace /var/lib/openshift/553bb7984382ecc5ce00009f/app-root/data/jobs/teste1/workspace checkout:workspace / /var/lib/openshift/553bb7984382ecc5ce00009f/app-root/data/jobs/teste1/workspace - hudson.remoting.localchannel@1ef62e0 using strategy: default last built revision: revision c8de886c2a824bdb4db4a70f757a891155ad9611 (origin/head, origin/master) checkout:workspace / /var/lib/openshift/553bb7984382ecc5ce00009f/app-root/data/jobs/teste1/workspace - hudson.remoting.localchannel@1ef62e0 fetching changes 1 remote git repository fetching upstream changes https://github.com/bergmpe/mysite.git seen branch in repository origin/head seen branch in repository origin/master commencing build of revision c8de886c2a824bdb4db4a70f757a891155ad9611

css - HTML navigation bar with unordered list vs other methods -

from w3 schools , shows , explains how make navigation bar using unordered lists . not use method, have used pictures support each button of navigation list. know lots of other people use many different ways. which method best , easiest? unordered list method links using pictures links making plain anchor elements links etc... from youtube video outdated, said internet explorer did not update html5, therefore best use unordered lists because not read nav element. i have tried of these ways, , best me if making custom, more entertaining buttons, use picture method. me unordered list method more complicated , looks more classic. which of these ways easiest , efficiency way, giving best results ? personally, i've used 3 @ same time! depends on you're goal, when use ul make type of drop down menu pure in css. <a href="#">menu1</a> <ul> <li><a href="#"><img alt="duck1" src=&quo

How does Windows 8 map the USB HID multitouch device to a specific display? -

[this 1 hard choose right se site for. i'm picking stackoverflow answer useless regular user, , interesting developer under free os.] i've got multitouch acer t232hl display, , plain-old asus display. first got acer display, later added additional asus one. windows correctly mapping "windows 8 compatible" t232hl's usb hid device (identified under linux "advanced silicon s.a cooltouch(tm) system" device, vid:pid being 2149:2306) onto display itself. it's not mistakenly extending touch surface onto asus display, , it's not accidentally moving surface asus display. xorg on ubuntu, however, default maps touch events across entire surface (both displays). what documentation exists of sorcery windows uses correctly map hid device's touch events display device? protocol or microsoft use whql process opportunity hardcode mappings devices? (i not see custom drivers being installed.) of course, if accident, i'll accept answer. (if you

sql - ambiguous error in mysql recordset in Dreamweaver -

the following recordset in dreamweaver throws 1052 ambiguous error every time attempt test it. know has dateadded, don't know how fix it. select commentid, commenttitle, commentcontent, topictable.topictitle, dayname(dateadded) day, monthname(dateadded) month, day(dateadded) date, year(dateadded) year commenttable, topictable commentid = colname , topictable.topidid = commenttable.topicid here layout of tables, create table usertable ( userid varchar(15) not null, screenname varchar(15) not null unique, userpasswd char(40) not null, firstname varchar(15) not null, lastname varchar(25) not null, datejoined timestamp not null default current_timestamp, lastlogin datetime, primary key(userid) ) ; create table categorytable ( categoryid mediumint auto_increment not null, categoryname varchar(30) not null, categorydescription varchar(200) not null,

SQL SERVER 2008 - Returning a portion of text using SUBSTRING AND CHARINDEX. Need to return all text UNTIL a specific char -

i have column called 'response' contains lots of data person. i'd return info after specific string but, using method below (when people have <100 iq) | comes directly after required number.. i'd characters after the'personiq=' before pipe. i'm not sure of best way achieve this. query speed concern , idea of nested case not best solution. any advice appreciated. thanks substring(response,(charindex('personiq=',response)+9),3) this suggestion: declare @s varchar(200) = 'aaa=bbb|cc=d|personiq=99|e=f|1=2' declare @iq varchar(10) = 'personiq=' declare @pipe varchar(1) = '|' select substring(@s, charindex(@iq, @s) + len(@iq), charindex(@pipe, @s, charindex(@iq, @s)) - (charindex(@iq, @s) + len(@iq)) ) instead of 3 in formula should calculate space between @iq , @pipe last part of formula charindex(@pipe, @s, charindex(@iq, @s)) - (charindex(@iq, @s) + len(@iq)) , gets f

google app engine - How can I modify the property of ndb model through a webapp2 handler in python -

i have python file , html file interact each other through jinja2 environment in manner similar 1 in this tutorial . the following code controls interaction between html file , python file: class mainpage(webapp2.requesthandler): def get(self): submission_query = submission.query().order(-submission.score) submissions = submission_query.fetch(10) template_values = { 'submission' : submission, 'submissions' : submissions, } template = jinja_environment.get_template('index.html') self.response.write(template.render(template_values)) app = webapp2.wsgiapplication([ ('/', mainpage), ('/create', createsubmmission), ('/voteup', voteup), ], debug=true) i have ndb model follows: class submission(ndb.model): username = ndb.stringproperty() placename = ndb.stringproperty() link = ndb.stringproperty() score = ndb.integerproperty()

javascript - Submit form from JS code -

i have form: @model project.models.channelandlocationviewmodel @{ const string formid = "parentform"; } @using (html.beginform("editchannel", "channel", formmethod.post, new { id = formid })) { html.renderpartial("editchannelform", model); <br /><br /> <!--<input type="submit" value="save"/>--> <input type="button" value="save" onclick="editchannel('@model.channelviewmodel.id', @formid)" /> } i trying submit form in js code looks this: function editchannel(channelid, parentform) { $(parentform).submit(); $.ajax({ url: '/channel/editchannel/', type: "post", cache: false, data: { id: channelid }, success: function (msg) { alert("msg: " + msg); if (msg === "changeofsensitivedata") { showalertonchangeofs

Sum of sine functions in Matlab -

i have create function following definition: function [ s1,s2,sums ] = sines( pts,amp,f1,f2 ) the output argument s1 row vector length (number of elements) equals pts. elements of s1 values of sine function when given equally spaced arguments start @ 0 , extend through f1 periods of sine. amplitude of sine wave equals amp. vector s2 same s1 except s2 contains f2 periods. vector sums sum of s1 , s2. if f2 omitted, should set value 5% greater f1. if f1 omitted also, should set 100. if amp not provided, should default 1. finally, if pts omitted well, should set 1000. have done following: function [ s1,s2,sums ] = sines( pts,amp,f1,f2 ) if nargin == 3 f2 = f1 + (f1*0.05); elseif nargin == 2 f1 = 100; f2 = f1 + (f1*0.05); elseif nargin == 1 amp = 1; f1 = 100; f2 = f1 + (f1*0.05); elseif nargin == 0 pts = 1000; amp = 1; f1 = 100; f2 = f1 + (f1*0.05); end t = 0:pts-1; s1 = amp * sin( 2*pi*f1.*t ); s2 = amp * sin( 2*pi*f2.*

c++ - OpenAL ALUT sound error -

Image
after looking on internet, not find answer issue. creating game university assignment , marks , have decided implement sound game. i using openal alut .dll's. here errors get. above error list me declaring sound , things need sound. it looks you've forgot link against libraries. error don't seem have openal though. try , find out definition of tle::new3dengine , add library additional dependencies ( project -> linker -> input ). should add %(additionaldependencies) rid of getsystemmetrics linking error.

Efficient one-liner in Julia to calculate "running" sums? -

is there efficient way following in julia in 1 line of code? foldl((prev, x)-> [prev; prev[end] + x] , 0, block_lengths) for example, block_lengths = [2, 2, 2, 2, 3] the desired output is [0, 2, 4, 6, 8, 11] (i presume way used foldl above inefficient, because i'm concatenating vector , integer @ each iteration.) iiuc, can use cumsum : julia> block_lengths = [2, 2, 2, 2, 3]; julia> cumsum(block_lengths) 5-element array{int32,1}: 2 4 6 8 11 julia> [0; cumsum(block_lengths)] 6-element array{int32,1}: 0 2 4 6 8 11 which should o(n).

class - __init__ Constructor in Python -

i trying write constructor class "block" stores coordinates of center of block (either separate x- , y-coordinates or pair of numbers) , width , height of block. problem having writing init can either take tuple of coordinates x,y or individual numbers x , y. here have far: def __init__(self,(x,y),height,width): use keyword arguments: class blocks(object): def __init__(self, center=none, x=none, y=none, height=0, width=0): if center none: # x , y must set if x none or y none: raise typeerror('you must either specify center or both x , y') else: # center set, x , y must not if x not none or y not none: raise typeerror('you must either specify center or both x , y') x, y = center # here have x , y set now can use blocks(center=(10, 20)) or can use blocks(x=10, y=20) . height , width have defaults, can overridden. the a