Posts

Showing posts from May, 2010

matrix - compute pitch, roll and yaw movement of an object in Matlab -

i working, matlab, on 3d simulator aim move object (currently it's simple circle) in space (using plot3). although it's easy compute trajectory without rotation of object, not manage rotate object around own axis. indeed, have computed 3 well-known rotation matrix (of course) rotate object (represented set of points) around axis of figure (in "world" system). for example, center of inertia of object (currently center of circle) coordinates (xi,yi,zi). thus, suppose need define additional system object able rotate object these 3 new axis composing such system... i like: [x2,y2,z2]=mat*[x1,y1,z1] [x1,y1,z1] coordinates of point of object before rotation, [x2,y2,z2] coordinates after rotation , mat matrix looking for. of course, center of inertia must unchanged whichever rotation (yaw and/or pitch or/and roll) however have no idea way compute such matrix. link below summarizes wish. drawing of problem

use a void pointer to point at an fstream object in c++ -

i new c++ , object oriented programming in general. objective use void pointer point fstream object. have structure contains void pointer. want use pointer reference fstream object can use in other functions write file using protocol buffer apis (serializetocodedstream).i want able write same file through repeated function calls (and read it). way i'm using protocol buffers serialize data , write file. my structure is: typedef struct store { void *obj; } st; my code create fstream object , use pointer point object st *entry1; fstream output; output.open("file1.txt", ios::out | ios::trunc | ios::binary); entry1->obj=&output; this i'm using pointer int addtofile( st *entry) { ostreamoutputstream *_ostreamoutputstream; codedoutputstream *_codedoutputstream; _ostreamoutputstream = new ostreamoutputstream(entry->obj); _codedoutputstream = new codedoutputstream(_ostreamoutputstream);

ios - Changing the color of a label every x seconds -

is there way implement this? http://i.imgur.com/jbhambk.gif have tried using ttattributedlabel no success (no flashing , time doesn't change anymore). does know of way make happen? any appreciated thanks everyone matt you can use timer. - (nstimer*)createtimer { // create timer on run loop return [nstimer scheduledtimerwithtimeinterval:1.0 target:self selector:@selector(timerticked:) userinfo:nil repeats:yes]; } - (void)timerticked:(nstimer*)timer { [yourlabel settext:@""] … } - (void)actionstop:(id)sender { // stop timer [mytimer invalidate]; }

c# - MongoDB - How to model recursive relation (categories) -

i'm working on application have categories it's entries. each entry have 1 category. concern how model categories in order achieve cleanest code , design. this how thinking implement category entity - approach 1 : public class category : entity { public string name { get; set; } public string desc { get; set; } public int guiorder { get; set; } public list<category> categories { get; set; } } in order achieve nested categories , instantiate them in way: var cat1 = new category() { name = "bikes", desc = "mountain, city, you-name-it have bikes.", guiorder = 1, categories = new list<category>() { new category() { name = "sub 1", desc = "sub 1 description.", guiorder = 1, //id = } } }; this how document in mongodb. can see in "sub 1&qu

android - Playing short sounds in separate thread -

in android game, there 36 falling balls. when ball touches ground sound played. sound small, 0.3 sec. using soundpool class play it. may happen in game 36 balls fall in quick succession. playing sound many times may block ui thread. advisable play sound on separate thread ? yes! should play sound on a separate thread. check solution provided similar question here

write regex for everything except a particular pattern for password in javascript -

i'm using following regex pattern validating password. var expression = /^[^\!\@\#\$\%\^\&\*\(\)\-\s\=\+\[\{\]\}\;\:\'\"\<\>\?\/\,\.\`\~\'][^\s]+$/ and it's working fine. now need change in such way can give characters allowed or blocked on top of this. i tried following code not working. var blockchar = "t"; var allowchar = "b"; var expression = '^' + blockchar + '[^\!\@\#\$\%\^\&\*\(\)\-\s\=\+\[\{\]\}\;\:\'\"\<\>\?\/\,\.\`\~\'' + allowchar + '][^\s]+$' var regexp = new regexp(expression); var elmval = document.getelementbyid("txt1").value; if (!elmval.match(regexp)) { return "validation failed"; } can guide me on how incorporate 2 variables ( blockchar , allowchar ) in this? values in blockchar should blocked , value in allowchar should allowed. you have different ways allow or forbid characters in string. lets see 3 basic examples

curl - PHP Strange code behaviour -

here goo.gl url shortener class. using googl::shorten(" http://google.com "). can't understand why returns null. doing wrong? <?php define('google_api_key', 'aizasybs7wpedisz91p-sjonwokkxqveb1sfpf4'); define('google_endpoint', 'https://www.googleapis.com/urlshortener/v1'); class googl { static function shorten($longurl) { // initialize curl connection $ch = curl_init( sprintf('%s/url?key=%s', google_endpoint, google_api_key) ); // tell curl return data rather outputting curl_setopt($ch, curlopt_returntransfer, true); // create data encoded json $requestdata = array( 'longurl' => $longurl ); // change request type post curl_setopt($ch, curlopt_post, true); // set form content type json data curl_setopt($ch, curlopt_httpheader, array('content-type: application/json'));

c# - Alternative Intellisense Tooltip? -

is there alternative visual studio's intellisense tooltip when typing parameter info? if not, easy implement own? the reason being @ work use framework long namespaces, when working function, parameters listened next each other in parameter info tooltip, , becomes long across screen. have tooltip displays each parameter on own line in tooltip.

java - Need to explain with Fibonacci -

i have seen many examples of fibonacci here on stack overflow have found no answer question. so, have code: public class fib { public static int fib(int n) { if (n < 2) { return n; } else { return fib(n-1)+fib(n-2); } } public static void main(string[] args) { (int i=0; i<8; i++) system.out.print(fib(i)+", "); } } after run 0, 1, 1, 2, 3, 5, 8, 13, i have question: how 8 ? fib(6)=............ can write in detail? fib(6) = fib(5)+fib(4) = fib(4)+fib(3)+fib(3)+fib(2) = fib(3)+fib(2)+fib(2)+fib(1)+fib(2)+fib(1)+fib(1)+fib(0) = fib(2)+fib(1)+fib(1)+fib(0)+fib(1)+fib(0)+1+fib(1)+fib(0)+1+1+0 = fib(1)+fib(0)+1+1+0+1+0+1+1+0+1+1+0 = 1+0+1+1+0+1+0+1+1+0+1+1+0=8 hope helped..

How to test custom types using Rspec-puppet? -

Image
i trying test custom_type using rspec-puppet. puppet code class vim::ubuntu::config { custom_multiple_files { 'line_numbers': ensure => 'present', parent_dir => '/home', file_name => '.vimrc', line => 'set number'; } } rspec-puppet code require 'spec_helper' describe "vim::ubuntu::config" should contain_custom_multiple_files('line_numbers').with({ 'ensure' => 'present', 'parent_dir' => '/home', 'file_name' => '.vimrc', 'line' => 'set number', }) end end result 2) vim::ubuntu::config failure/error: }) puppet::error: puppet::parser::ast::resource failed error argumenterror: invalid resource type custom_multiple_files @ /etc/puppet/modules/vim/spec/fixtures/modules /vim/manifests/ubuntu/config.pp:7 on node ... # ./spec/classes/ubuntu_config_spe

xcode5 - ios 7 simulator is just a screen, no phone -

Image
i trying create screenshots of app walkthrough , app store. instead of having plain screenshots of screen, want screen in actual iphone 5s. going use grab, simulator screen now, no bezel or anything. remember in previous versions of xcode, simulator actual iphone , wondering if there way can (with iphone 5s preferably iphone 5 work). know possible because have seen in app store can't figure out how. help. software photoshop job. use iphone psd , add app's screen shot layer on it. there no other way. e.g iphone psd: http://www.teehanlax.com/tools/iphone/ screen shots app store tutorial: http://www.bluecloudsolutions.com/blog/awesome-screen-shots-app-store/

javascript - Can new line be added to http header in node js -

can add "\n" in example in line 5? in case can, hahaha appear in http response body? var http = require('http'); http.createserver(function (req, res) { res.writehead(200, { 'content-length': body.length, 'location' : 'http://www.aaa.com\nhahaha', 'content-type': 'text/plain' }); res.end('hello world\n'); }).listen(1337, "127.0.0.1"); thanks help node filter \n so, result there no injection using code ..

c# - For loop pattern -

i have assignment college, anyway need make pattern output: * ** *** **** ***** ****** ******* ******** ********* ********** here's code: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace problem_11 { class program { static void main(string[] args) { int i; (i = 1; <= 10; i++) { (string o = "*";); //nested loop { console.write(o); } console.write("\n"); } console.readline(); } } } error 1 assignment, call, increment, decrement, await, , new object expressions can used statement error 2 invalid expression term ')' error 3 invalid expression term '{' error 4 ) expected error 5 { expected try code for (int = 0; < 10; i++) {

javascript - Echo alert in php using jquery -

i'm new programming world, take easy.. i'm running tests , realise when use jquery libraries outside of php create form, echo inside php doesn't work. want alert message found out can done echo "<script>alert ('message')</script>"; but anyway echo responsible not seeing anything.. problem jquery libraies (which don't think so..) or i'm not knowing i'm doing..? what code use..? thank in advance..!! your code should be: echo '<script type="text/javascript">alert("message")</script>';

Using libssh C++ wrapper -

anyone here have experienced libssh c++ wrapper yet? can here i'm using 0.6.3 version . follow install instruction in downloaded file build libraries. then try compile example in examples directory libsshpp.cpp #include <iostream> #include <string> #include <libssh/libsshpp.hpp> int main(int argc, const char **argv){ ssh::session session; try { if(argc>1) session.setoption(ssh_options_host,argv[1]); else session.setoption(ssh_options_host,"localhost"); session.connect(); session.userauthautopubkey(); session.disconnect(); } catch (ssh::sshexception e){ std::cout << "error during connection : "; std::cout << e.geterror() << std::endl; } return 0; } by command g++ -o sh libsshpp.cpp -lssh successed when execute take error : ./sh: symbol lookup error: ./sh: undefined symbol: ssh_userauth_publickey_auto . hope worked libssh can help!

How does python function return objects? -

Image
in below diagram, have query on name temp returned function f in local frame f , temp reference variable pointing object 6 of class int , when return temp in f reference variable output part of checkpassingmech frame point same object 6 temp pointing to. my question: q1) understanding correct? q2) if q1 yes, diagram giving illusion temp not reference type , showing value in box rather arrow pointing 6, correct? q3) if q2 yes, then, can 6 stored in heap , temp , output pointing heap space frame(local stack) >>> def f(): temp = 6 print(id(temp)) return temp >>> output = f() 507107408 >>> id(output) 507107408 from doc : cpython implementation detail: cpython, id(x) memory address x stored. so strictly speaking, if value 6 , output , temp pointing same object, int object cached when python started. you may refer identifying objects, why returned value id(...) change? more information.

How to append object name with variable string in php? -

i have array of objects this $names=array ( [0] => stdclass object ( [id] => 1 [heading_de] => title_deutch [heading_en] => title_english ); and have var $lang="_en"; when want try this foreach ($names $title) { $title = $title->heading.$lang; } i got $title="_en" but when try this foreach ($names $title) { $title = $title->heading_en; } i got ok, mistake, hot combine string , object ? you want use variable variables in php, try following $lang = "_en"; foreach ($names $title) { echo $title->{'heading' . $lang}; }

git - How to back out from back out? -

i have backed out commit (commit#1), after realized needed commit. have checked out commit#1. now, how can put version end of branch? if haven't done other work, can reset current branch on commit. git checkout yourbranch git reset --hard <sha1> the op barnabas szabolcs advices in comments: git reset --soft @^ (with recent git, @ alias head) that allow keep working tree , index (of checked out old commit) intact, while resetting head previous commit in order make new 1 (with content of checked out commit). if have done other commits, need cherry-pick commit current branch: git checkout yourbranch git cherry-pick <sha1> in case, checkout of old commit dangerous, leads detached head situation (except when followed git reset ---soft head^ ).

c++ - auto in c++11 is static typing or dynamic typing -

is auto command in c++11 static binding(typing) or dynamic binding? i.e. if have code auto x = 5; will compiler decide "x" int, or descovered on runtime? also, type of x in following code? auto x = 5, y = 4.5 this called type inference . typing still static , leave compiler figure out type of expression is. specifically auto x = 5; , @ compiler time, is translated int x = 5; . reason have provide unambiguous expression @ initialization. example auto x; wouldn't work .

javascript - Crossdomain in python flask won't work -

i trying start communication between flask server , html page. included crossdomain code explained here http://flask.pocoo.org/snippets/56/ , still won't work. here python code: from flask import * crossdomain import * app = flask(__name__) @app.route('/') @crossdomain(origin='*') def pocetna(): return '1' if __name__ == '__main__': app.run(host='0.0.0.0',port=8081,debug=true) and here javascript: function prebaci(){ var xmlhttp; xmlhttp=new xmlhttprequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { if (xmlhttp.responsetext==1) document.getelementbyid("kuca").innerhtml="radi"; else document.getelementbyid("kuca").innerhtml="ne radi"; } } xmlhttp.open("get","127.0.0.1:8081",true); xmlhttp.send(); } in google chrome err

asp.net - Can't debug web applications in visual studio 2013 -

i created sample web application in visual studio 2013 , put break point, when running solution break point disabled. set "debug=true" in web.config issues web applications, can able debug console application. edit: after clearing both windows , user temp file break point hit, can't able evaluate expression in quick watch. says variable out of scope make sure have debug set in toolbar drop down on top. right-click home page in solution explorer , set starting page, , try again. set break point on code in page load event handler of starting page.

asp.net - vb program to see the result of the Javascript program without a button click event -

i trying take localhour function , find hour in local computer , send hidden1. i uncertain how run function "localhour" onblur. i need vb program see result of javascript program without button click event. default.aspx <script type="text/javascript"> function localhour() { var localtime = new date(); var hours = localtime.gethours(); document.getelementbyid("<%=hidden1.clientid%>").value = hours; } </script> <input id="hidden1" type="hidden" onblur="localhour" runat="server" /> default.aspx.vb utchour = datetime.utcnow.tostring("hh") localtimezone = cdbl(hidden1.value) - cdbl(utchour)

How to replace certain items in a char array with an integer in C++? -

below example code not working way want. #include <iostream> using namespace std; int main() { char testarray[] = "1 test"; int numreplace = 2; testarray[0] = (int)numreplace; cout<< testarray<<endl; //output "? test" wanted 2, not '?' there //i trying different things , hoping (int) helped testarray[0] = '2'; cout<<testarray<<endl;//"2 test" want, hardcoded in //is there way based on variable? return 0; } in string characters , integers, how go replacing numbers? , when implementing this, different between doing in c , c++? if numreplace in range [0,9] can :- testarray[0] = numreplace + '0'; if numreplace outside [0,9] need a) convert numreplace string equivalent b) code function replace part of string evaluated in (a) ref: best way replace part of string in c , other relevant post on so also, since c++ code, might c

numbers - php how to detect whole thousands -

i trying detect if number in database whole thousands number. i.e 25 = false 1000 = true 1578 = false 5000 = true 100000 = true 100005 = false there ain't way tell if number whole thousand, @ least not php function know of. i've tried creating array thousands 1billion, can imagine how big array is, if (in_array()) . when cleaning code, array 100k lines long, ain't optimal if ask me. i've searched google way of doing this, can't find useful information. the modulo (%) operator this. if ($num > 0 && $num % 1000 === 0) { echo "divisible 1000"; } note need check if $num 0 because test true because 0 % 1000 = 0

javascript - MarkerClusterer xml markers -

what trying add markerclusterer actual code map integrated in webpage. markers created via xml file generated somewhere else. map working fine , loaded without markerclusterer. i cannot figure out wrong code. maybe didn't how markerclusterer works correctly. hope can me. what added initial (working) code 3 lines: var markersclust = []; markersclust.push(point); var markercluster = new markerclusterer(map, markersclust); all inside "script tags" in php file. echo' function load() { var map = new google.maps.map(document.getelementbyid("map"), { center: new google.maps.latlng(40.8333,14.25), zoom: 5, maptypeid: \'roadmap\' }); var infowindow = new google.maps.infowindow; downloadurl("xml_map_public.php", function(data) { var xml = data.responsexml; var markersclust = []; var markers = xml.documentelement.getelementsbytagname("marker"); (var = 0; < markers.length; i++) { var name = markers[i].getattribute(&quo

c# - Linq select records that match a list of IDs -

is possible change query below, uses types list within contains type query. so instead of having: var cust = db.customers.where(x => x.type_id==9 || x.type_id==15 || x.type_id==16).tolist(); ...i have like: list<int> types = new list<int> { 9, 15, 16 }; var cust = db.customers.where(x => types.contains(x.type_id).tolist(); (type_id not primary key). thank you, mark yes, method list<t>.contains translated sql in operator: var cust = db.customers.where(x => types.contains(x.type_id)).tolist(); generated query like: select * customers type_id in (@p0, @p1, @p2)

node.js - node-webkit tail a file output in application console -

pardon me if totally wrong in concepts novice of - node js, node-webkit, javascript. trying learn of them :) i developing simple desktop app using node-webkit want read system log , write in application console. using tailfd node module , there no error in console. here html <!doctype html> <html> <head> <title>tailing system log</title> </head> <body> <script> var tail = require('tailfd').tail, watcher = tail('/var/log/system.log',function(line,tailinfo) { //default line listener. optional. console.log('line of data> ',line); }); </script> <h1>tailing sys log!</h1> </body> </html> the tail output not showing in app console. can point me if missing basic stuff? appreciated.

ios7 - IBM Worklight 6.0 - How to display properly sized splash image in iPhone 5? -

Image
in our app, splash screen size showing same both iphone 4 , iphone 5. result of this, there 2 gaps (one on top , 1 on bottom) when app launched. how go fixing issue? in ios 7 know apple changed how status bar "operates". status bar is part of app layout default. means overlaps splash image @ top. that's fine. also, can see when launching new , unmodified worklight-based app ios environment in ios simulator or idevice, splash image not produce "cut lines" @ top , bottom. displays properly: what need create sized image of own and name correctly . way name file essential - how ios knows how handle it. see apple human interface guidelines: app launch (default) images ios 7 design resources see bit more here: http://www.idev101.com/code/user_interface/launchimages.html for example, iphone 5 , above launch image needs 640 x 1136 pixels , can titled: default-568h@2x~iphone.png , place in your-app\iphone\native\resources:

android - Trouble with CyanogenMod local_manifest -

when using commands breakfast (in case, hlte (samsung galaxy note 3)), or brunch hlte, searches dependencies build os. i trying list different repos sync doesn't overwrite changes when comes doing repo sync. can view local manifest here: https://github.com/dxc0/local_manifests/blob/master/roomservice.xml basically, point replace default ones custom ones of same nature. when try build, loops while looking dependencies (seen here: http://pastebin.com/4utesjjr ) tl;dr it looks dependencies , never exits loop. i've seen others without removing dependencies cm.dependencies , baffles me least. edit: going try ubuntu version 12.04 fresh repo. others aren't experiencing must on side :/ please feel free tell me i'm wrong don't use roomservice.xml custom repositories. local manifest amended breakfast/brunch. can remove repositories there, it's best create separate manifest additional repositories. can have multiple local manifests in directory, n

c - PWM output is not working on STM32F10x OPEN107V Development board -

hello have got "stm32f10x open107v development board" ,i have modified code pwm given manufacturer ,but not getting pwm output on leds given on development board please following code. gpio_pins 0,1,14,15 on portb(gpiob) led pins given on development board.the code error free , has no errors while linking.as begginer don't understand problem. /** -----------------------------------------------------------------*/ #include "stm32f10x_gpio.h" #include "stm32f10x_rcc.h" #include "stm32f10x_tim.h" tim_timebaseinittypedef tim_timebasestructure; tim_ocinittypedef tim_ocinitstructure; uint16_t ccr1_val = 333; uint16_t ccr2_val = 249; uint16_t ccr3_val = 166; uint16_t ccr4_val = 83; uint16_t prescalervalue ; /* private function prototypes -----------------------------------------------*/ void rcc_configuration(void); void gpio_configuration(void);

windows - Wolfram Alpha Error -

<?xml version="1.0" encoding="utf-16"?> <speechmacros> <command> <listenfor>what [...]</listenfor> <speak>ok sir 1 moment, databases possible answer.</speak> <waitfor seconds="3" /> <run command="http://www.wolframalpha.com/input/?i={[...]}" /> <script language="jscript"> <![cdata[ try { var wolframtext = ("{[...]}"); var xml_doc = new activexobject("microsoft.xmldom"); xml_doc.async = false; xml_doc.load("http://www.wolframalpha.com/input/?i="+wolframtext+"&format=xml&limit=1"); var tmp = xml_doc.getelementsbytagname("description").item(0).text; } catch(err) { { tmp = "sadly don't know that"; } } application.speak(tmp); ]]> </script> </command> <signature> miidtqyjkozihvcnaqccoiidpjcca6icaqexczajbgurdgmcgguamgcgcisgaqqbgjccaqsgwtbx mdigcisgaqqbgjccar4wjaibaqqqqf9

javascript - I cannot scale my font-size with D3 domain and range...? -

i looking scale book 'titles' in below dataset depending on number of 'weeks' have been on best-sellers list...so if book's 1st week on list, title appear in 18pt, , if book's 20th week on list (or maximum number week) title appear in 72pt. e.g. of dataset: var hardcover_fiction = [ { title: "missing you", author: "harlan coben", rank: 1, last: 0, weeks: 1 }, { title: "raising steam", author: "terry pratchett", rank: 2, last: 0, weeks: 20 } ]; e.g. of d3 code: .style("font-size", function(d) { return textscale(d.weeks) + "px"; }) var textscale = d3.scale.linear() .domain([1, d3.max(hardcover_fict

google chrome extension - Referer security when requesting a Simple API Access Key -

i'm working inside of google chrome extension. extensions not send out "referer" header when issuing requests, possible (potentially) modify behavior using chrome.webrequest.onbeforesendheaders. i attempting communicate google's youtube v3 api. so, must provide api key. successful request server looks like: $.ajax({ url: 'https://www.googleapis.com/youtube/v3/playlists?part=snippet&id=alyl4ky05133rtmhtulsaxkj_y6el9q0jh&key=aizasybwegndkdnwkgr2bckrzqxnww00ka7t2lk', success: function (response) { console.log("success", response); }, error: function (error) { console.log("error:", error); } }); now, request works because have gone google api console , created simple api access browser key allowed referers set to: referers: referer allowed this seems security flaw me because ensure program allowed query api. however, google has been pretty clear don't care flaw because can req

csv - mysql update table if record not in temp table -

alright, have multiple mysql statements lead issue i'm having updating particular table. first let me show code, i'll explain i'm trying do: /*step 1 - create temporary table temporarily store loaded csv*/ create temporary table if not exists `temptable1` `first60dayactivity`; /*step 2. load csv created temporary table*/ load data local infile '/users/me/downloads/some.csv' ignore table `{temptable}` fields terminated ',' optionally enclosed '\"' lines terminated '\r\n' ignore 1 lines set custid = 1030, created = now(), isactive = 1; /*step 3. update first60dayactivity table changing isactive records not in temptable*/ update `first60dayactivity` fa inner join `temptable1` temp on temp.`mid` = fa.`mid` , temp.`primarypartnername` = fa.`primarypartnername` , temp.`market` = fa.`market` , temp.`agedays` = fa.`agedays` , temp.`opendate` = fa.`opendate` , temp.`custid

autohotkey - Temporarily Pause Autofire loop on holding button -

i wrote script sends autofire left clicks , can triggered on , off. script works. however, problem holding right mouse button not work anymore because left click keeps getting sent. want change script gets temporarily paused while hold down right mouse button. how go doing this? here current code: #maxthreadsperhotkey 3 #z:: #maxthreadsperhotkey 1 if keep_winz_running = y { keep_winz_running = n return } ; otherwise: keep_winz_running = y loop { getkeystate, rbut, rbutton if rbut, = u { loop, { mouseclick, left sleep, 50 ;this means script wait 1.5 secs if keep_winz_running = n ; user signaled loop stop. break ; break out of loop } timers best! sendtoggle := false #z:: if(!sendtoggle) { sendtoggle := true settimer, sendclick, 100 } else { sendtoggle := false settimer, sendclick, off } return #if sendtoggle rbutton:: settimer, sendclick, off keywait, rbutton

Activating/using GL_TEXTURE1 at OpenGL ES 2.0 for Android -

i'm trying use gl_texture1 texture unit draw simple shape. know how draw using standard gl_texture0, when changing not working. i thought code below, had change following: glactivetexture(gl_texture1); gluniform1i(utexturelocation, 1); what i'm missing? code: public class rendererclass implements renderer { context context; floatbuffer verticesinbuffer; int apositionlocation; int atexturelocation; int utexturelocation; int program; public rendererclass(context context){ this.context = context; } @override public void onsurfacecreated(gl10 arg0, eglconfig config) { gles20.glclearcolor(1.0f, 0.0f, 0.0f, 0.0f); float[] vertices = { -0.5f, 0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 0.0f }; verticesinbuffer = bytebuffer.allocatedirect(vertices.length*4).order(byteorder.nati

System() no suitable conversion C++ -

i have 2 lists file names. std::list<std::string> userfontlist; std::list<std::string>::iterator it; std::list<std::string> caatfontlist; std::list<std::string>::iterator it2; std::list<std::string> doesnthavelist; and want compare 2 lists, , delete value matches. every seems fine until add "del /f /q /a" y.c_string(). for (it = userfontlist.begin(); !=userfontlist.end(); ++it){ for(it2 = caatfontlist.begin();it2 !=caatfontlist.end();++it2){ if(*it==*it2){ string y = *it; string k = y.c_str(); string = "del /f /q /a " + k; system(a); } } } system(a) says have "no suitable conversion function std string const char * exists". if put whole thing 1 string works, not when concatenate string , y.c_str(). have had no luck trying convert std::string const *char, not sure if helps. exactly says, there's no version of system() understands

All in One Unarchive Bash Script Linux -

i found following script online. instructions add ~/.bashrc. worked fine until installed 64 bit version of linux distro. (kali linux - debian wheezy ). i'm not sure what's going on. why isn't working, , how can fix it? i'm relatively new linux, , new bash scripting. script: #!/bin/bash # function extract common file formats function extract { if [ -z "$1" ]; # display usage if no parameters given echo "usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>" else if [ -f $1 ] ; # name=${1%.*} # mkdir $name && cd $name case $1 in *.tar.bz2) tar xvjf ../$1 ;; *.tar.gz) tar xvzf ../$1 ;; *.tar.xz) tar xvjf ../$1 ;; *.lzma) unlzma ../$1 ;; *.bz2) bunzip2 ../$1 ;; *.rar) unrar x -ad ../$1 ;; *.gz) gunzip ../$1 ;; *.tar)

javascript - Form submit is not seeing my custom checkboxes as :checked -

i've been building custom form component set on codepen, these checkboxes aren't working correctly. i'm setting both prop true , checked attribute "checked" . can inspect elements developer tools check these. if click on checkbox, works. clicking on label next results in check not being detected in form submit though both handled same far can tell. here's codepen any ideas? me 1 of it should working situations. i think problem toggling checkbox checked property via javascript label toggles that, toggling twice , end same value before. try this, remove "for=..." attribute labels , click on label work. that's ugly solution. better solution, change click callbacks to: when click fake checkbox: change fake checkbox status , toggle value of real checkbox when click label: change fake checkbox status only, don't toggle value of checkbox since has been toggled i'm not sure think there's better solution, n

java - Pascal's Triangle Format -

Image
the assignment create pascal's triangle without using arrays. have method produces values triangle below. method accepts integer maximum number of rows user wants printed. public static void triangle(int maxrows) { int r, num; (int = 0; <= maxrows; i++) { num = 1; r = + 1; (int col = 0; col <= i; col++) { if (col > 0) { num = num * (r - col) / col; } system.out.print(num + " "); } system.out.println(); } } i need format values of triangle such looks triangle: i can't life of me figure out how that. please answer keeping in mind i'm beginner in java programming. thank you! public static long pascaltriangle(int r, int k) { if(r == 1 || k <= 1 || k >= r) return 1l; return pascaltriangle(r-1, k-1) + pascaltriangle(r-1, k); } this method allows find kth value of rth row.

javascript - My image is not uploading after click "upload" button into database -

i'm uploading image database after clicking uploading button, it's not uploaded database, it's refresh , when add pic manually database it's website, here pic click here here source code upload image: <?php include('lock.php'); mysqli_connect("localhost", "root", "bhawanku", "members"); if(isset($_post['emp_name'])){ $content=file_get_contents($_files['pic']['tmp_name']); @list(, , $imtype, ) = getimagesize($_files['pic']['tmp_name']); if ($imtype == 3){ $ext="png"; }elseif ($imtype == 2){ $ext="jpeg"; }elseif ($imtype == 1){ $ext="gif"; } $q="insert employees set empname='".$_post['emp_name']."',profile_pic='".$content."',ext='".$ext."'"; mysql_query($q); header("location: getting_started.php&quo

php - Magento Shipping Method Loading speed -

in e-commerce site, have configured fedex shipping shipping api. in methods, i've choose 1 allow method "international economy". though have 1 method allow, checking logs of fedex, seems api query methods , return result. because of this, took @ least minute return shipping rates. is normal magento? or there anyway speed query speed or there modification or hack can make query allow method? kindly advise. thank you. i have seen few questions fedex magento , speed recently. i not convinced fedex request causing delay, figure out (and answer questions):- the code sends out requests is: //file: app/code/core/mage/usa/modell/shipping/carrier/fedex.php //class: mage_usa_model_shipping_carrier_fedex //function: _getquotes() protected function _getquotes() { $this->_result = mage::getmodel('shipping/rate_result'); // make separate request smart post method $allowedmethods = explode(',', $this->getconf

json - System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0., Culture=nuetral failed CRM 2011 -

i trying deserialize json string in crm 2011. json string arbitrary , not same fields (keys) returned. trying use system.runtime.serialization.json datacontractjsonserialzer method. found following code in post have modified need: namespace test { [serializable] public class stringobjectdictionary : isafeserializationdata { public static dictonary<string, object> dict; public stringobjectdictionary() { dict = new dictionary<string, object>(); } protected stringobjectdictionary(serializationinfo info, streamingcontext context) { dict = new dictionary<string, object>(); foreach (serialization entry in info) { dict.add(key, dict[key]); } } void isafeserializationdata.completedeserialization(object obj) { dictionary<string, object> _dict = obj dictionary<string, object>; foreach (string key in dict.keys) { _dict.add(key, dict[key] } } i calling above here: test.stringobjectdictionary[] dummyarray = { new test.stringobjectdictionary() }; datacon

arrays - Receiving a null error "Unhandled Exception: System.NullException: Value cannot be null" C# -

hello new in programming world , im having little problem simple program. created array , passed through constructor class named "temperature." im trying find max number of array , return method seems has no value, therefore causing error. namespace tempapp { class program { static void main(string[] args) { temperature atemperatureobject = new temperature(); double[] temp = new double [7]; string invalue; (int = 0; < temp.length; i++) { console.write("enter temperature day {0}: ", + 1); invalue = console.readline(); temp[i] = double.parse(invalue); } double highesttemp = atemperatureobject.gethighesttemp(); double lowesttemp = atemperatureobject.getlowesttemp(); double averagetemp = atemperatureobject.getaveragetemp(); displayresults(highesttemp, lowesttemp, averag

z3 - Converting different widths of floating-point numbers -

i want compare 2 different widths of floating-point numbers giving assert z3. example, want compare between ieee 32-bit , ieee 64-bit floating-point number. my try shown follows: (set-logic qf_fpa) (set-option :produce-models true) (declare-fun x_64 () (_ fp 11 53)) (declare-fun x_32 () (_ fp 8 24)) (assert (== ((_ asfloat 11 53) roundnearesttiestoeven x_64 ) x_64)) (check-sat) but got error message: (error "line 5 column 59: sort mismatch") what correct way compare 32-bit , 64-bit number? the z3 version using 4.3.1 (linux version). in general, these conversions non-trivial, e.g., when converting 64-bit down 32-bit precision may lost. why conversion functions take rounding mode. smt standard floating-point numbers contain conversion functions of following type: ; floating point sort ((_ to_fp eb sb) roundingmode (_ floatingpoint m n) (_ floatingpoint eb sb)) so, correct way convert between floating-point numbers use to_fp function. [previously, a

Fortran 95 Nesting of loops (beginner) -

i new fortran 95 , trying grip on nested loops. below small code nested loop. inner loop secant method calculates root of function "z+x1**2-612" , saves x0 via iteration. istep howmany iterations took. loop on own works. want repeat loop various "z". example 300 360 increments of 10. if run code, z vary 300 360 should, keep getting x0 300 (i.e. square root of 312). is there has experience nested loops (not secant method, since inner loop works), can tell me why print out 300 360 well, x0 if z never changes 300? browsed through forum, , found similar issues had variable declarations placed wrongly, doesn't seem problem in case. hereunder code, hope can me. bit old start learn programming, never late guess! program doloop2 implicit none integer :: istep,z real :: a,b,dl,dx,x0,x1,d,x2 dl = 1.0e-06 = 10 !lower guess b = 20 !upper guess dx = (b-a)/10.0 !stepsize x0 = (a+b)/2.0 istep = 0 !first iteration x1 = x0+dx z=300,360,10 wh

How do I calculate the space in between two glyphs in a TTF font? -

Image
this graph definition of few terms horizontal glyph metrics fonts . let's have sentence, foo bar baz. how spacing size, in pixels, between words "foo" , "bar"? suppose sum, the whitespace right-padding in grapheme 'o' in "foo": subtract advance bearingx + width the advance of space character. the whitespace left-padding of letter 'b' in "bar": bearingx . is correct? table has bearingx? how spacing size, in pixels, between words "foo" , "bar"? you need know horizontal advance of space character , kerning between "o" , " ", , between " " , b". don't think need bearingx spacing. result in font "units", defined unitsperem of head tag. convert result * font size / unitsperem, , spacing in "points". need known, how many pixels there in 1 point: depends on application, monitor dpi or postscript's 72 dpi.

rest - Soup UI - save JSON request and response -

i'm using rest request in soapui. want save json request , response file. how can it? request payload (json) not included in report. request http headers captured in report. please let me know if able log request json. using soapui 5.0.0

ruby on rails - Rspec expect keeps throwing a TypeError: nil is not a symbol -

so have test in app: expect{ post :create, :name=> 'abc' }.to change(event.count).from(0).to(1) and keeps throwing error: typeerror: nil not symbol would know why? found out issue. should using {} instead of (). should instead: expect{ post :create, :name=> 'abc' }.to change{event.count}.from(0).to(1)

java - In SpringMVC, how can I give LiteDeviceDelegatingViewResolver an order value? -

in our springmvc based website, want use litedevicedelegatingviewresolver . we have couple of other viewresolvers configured , want litedevicedelegatingviewresolver take precedence on those. however litedevicedelegatingviewresolver not implement ordered interface, hence cannot set order value on it. seems spring uses these values chain viewresolvers. there way make litedevicedelegatingviewresolver take precedence on other viewresolvers have configured? thanks.

java - Filter two strings in a listView -

i have sqlite database contains table has 3 columns, i'm using in layout edittext , listview. i've done applying search using edittext , displaying filtered results in listview. the following code applied edittext called myfilter, words simplecursoradapter : myfilter.addtextchangedlistener(new textwatcher() { public void aftertextchanged(editable s) { } public void beforetextchanged(charsequence s, int start, int count, int after) { } public void ontextchanged(charsequence s, int start, int before, int count) { words.getfilter().filter(s.tostring()); } }); what want filter 2 charsequences, example want display in listview words starts , b, can (for example words.getfilter().filter("a","b"); ?

java - javax.mail.AuthenticationFailedException: Error authenticating with server -

i trying send mail through exchange server (office 365) using java mail api. following code: package com.package; import java.util.locale; import java.util.properties; import java.util.resourcebundle; import javax.mail.message; import javax.mail.messagingexception; import javax.mail.passwordauthentication; import javax.mail.session; import javax.mail.transport; import javax.mail.internet.internetaddress; import javax.mail.internet.mimemessage; import javax.mail.internet.mimemessage.recipienttype; public class mail { resourcebundle rb = resourcebundle.getbundle("settings", locale.english); public void sendmail(string body, string subject, string receipients) throws messagingexception ////this used send emails { message message = new mimemessage(getsession()); message.addrecipient(recipienttype.to, new internetaddress(receipients)); message.addfrom(new internetaddress[] { new internetaddress(rb.getstring("from")) });