Posts

Showing posts from March, 2011

networking - How to find Subnets and Hosts from given IP -

Image
i have been learning subnetting exam , came through question. but why this? first thought: 172.20.0.0 can have 254 subnets , 254 hosts per each subnet. wrong. can please explain me how this? thanks guys the netmask 255.255.252.0 has 10 0 bits @ end. 2 ^ 10 = 1024, minus broadcast , network address = 1022. if you're using classful way of dividing network, 172.20.* b network, 16 bit size of network part. gives 16-10 = 6 bits spare, can split 2 ^ 6 = 64 networks.

c++ - Iterate Vertex Buffer -

i'm trying emulate opengl's gl_point debugging , reverse-engineering opengl. i'm trying iterate vertex-buffer given pointer, index-buffer pointer , stride. so did: i hooked application uses opengl. i monitored calls using gdebugger (application created amd debugging) to render single model, calls are: glpushmatrix() glviewport(4, 165, 512, 334) glmultmatrixf({1, 0, 0, 0} {0, 1, 0, 0} {0, 0, 1, 0} {26880, -741, 26368, 1}) glgenbuffersarb(1, 0x0a2b79d4) glbindbufferarb(gl_array_buffer, 15) glbufferdataarb(gl_array_buffer, 17460, 0x0c85de1c, gl_static_draw) glgenbuffersarb(1, 0x0a2b79d4) glbindbufferarb(gl_element_array_buffer, 16) glbufferdataarb(gl_element_array_buffer, 8946, 0x0c85de1c, gl_static_draw) glbindbufferarb(gl_array_buffer, 0) glvertexpointer(3, gl_float, 12, 0x31cb24c9) glenableclientstate(gl_vertex_array) gldisableclientstate(gl_normal_array) glbindbufferarb(gl_array_buffer, 15) glcolorpointer(4, gl_unsigned_byte, 12, 0x00000000) glenableclients

extjs4 - Extjs 4: Panel Toggle Add animation -

the scope animate toggling of panel. in click of button collapse expand after while (certain process , reconstruct content). want add animation because right snaps when expand back. i more smoother or slower. want emphasize did, expanding , collapsing. have searched on no avail. can share line of codes? thanks.

android - The <activity> element must be a direct child of the <application> element -

i wanted launch application, fails , gives me error. before, install .apk file, fails start @ all. began , following android developing tutorial. <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myfirstapp" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="17" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.example.myfirstapp.mainactivity" android:label="@string/app_name" >

ruby on rails 3.2 - RoR - Spree - Paypal Express Gem -

i attempting install paypal express checkout, added information in gemfile , ran bundle install ended here. gem 'spree', '1.3.2' gem 'spree_gateway', :github => 'spree/spree_gateway', :branch => '1-3-stable' gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-3-stable' gem 'spree_static_content', :github => 'spree/spree_static_content', :branch => '1-3-stable' this error: bundler not find compatible versions gem "spree_core": in gemfile: spree_paypal_express (>= 0) ruby depends on spree_core (~> 2.0.0.beta) ruby spree_static_content (>= 0) ruby depends on spree_core (1.3.2) i new ruby/rails, believe should support v2 of spree_core, should support 1.3.2. not? the gemfile asks 1.3.2, removing resolve issue? what else information should provide more information? if not bug, how possible fix this. in time managed

c++ - Threads and template member functions -

i got template member function call using .template : myobject.template memberfunction<somearguments...>(); //not variadic (but template of template) i wanted thread call std::thread. tried : std::thread mythread(&myclass::memberfunction<somearguments...>, &myobject); but doesn't compile. seems parsing problem since 'expected primary-expression before' parenthesis , comma. ps : french , new c++ hope understandable. just add template keyword after :: , same after . . yes, same parser issue applies. quick demo here.

ubuntu - Copy a certain file from a CPIO file to a different directory -

i trying copy single file .cpio file, different directory rather tree inside it. trully sure possible, teacher did it. i have tried this: # cpio -i -f backup.cpio sub1/sub2/example.php but doesn't extract file example want extracted. tried adding third parameter doesn't work. suggestions? oh, , i'm running ubuntu. one way extract single file stdout , redirect file of choice: cpio -i --to-stdout sub1/sub2/example.php < backup.cpio > new_filename.php

scala - Pass function argument as code block -

i new scala. have been searching there no easy "search string" seemingly easy question have. def foo( f: (string) => string ){println(f("123"))} foo{_+"abc"} //works def bar( f :() => string ){println(f())} bar{"xyz"} // why not work? def baz( f: => string ){println(f)} baz{"xyz"} //works why second ( bar ) not work? second baz works because it's not function literal, call-by-name parameter. delaying moment of argument computation until it's needed in program. can read in this question. bar need pass function bar{() => "xyz"}

java - Directional Weighted Median Filter (Image processing) -

i need implement directional weighted median filter in java remove random impulse noise. have no idea how/where start. algorithm per below: create 5x5 window consider 4 directions (vertical, horizontal, diagonal left, diagonal right) center pixel (5 pixels in each direction) calculate weighted difference , take minimum value minimum value compared threshold value: if value > threshold: noise pixel else: not noise pixel calculate standard deviation of 5 pixels in each direction giving weight direction in standard deviation smallest, weighted median computed the noisy pixel replaced median value move window throughout image iterate steps 8 10 times can point me in right direction how should go implementing this? examples or implemented codes highly appreciated. using imagej, plugin has implemented filter (or variation of it) helpful. thanks. apparently, filter hasn't been implemented imagej plugin yet. unfortunately, couldn't find source in p

javascript - how to make a double hover effect with css -

i have double hover effect not it. avoid transition leaving appeared icon. maybe here. suggestion welcome. here html: http://jsfiddle.net/cb5lr/ <div class="block image addmore" style="position: absolute; top: 100px; left: 50px; height: 350px;width:200px;background-color:red;"> <span data-action="fullview" class="shopicons full_screen_icon"></span> <figure class="with-hidden-caption"> please hover here. after second icon apear in right corner. <br><br> if hover icon change. until here ok.<br><br> but, if leave icon, shout show old 1 without rolling effekt. </figure> </div> and css: .shopicons { background: url("http://www.dasunddas.de/img/base/shop_icons.png?v=63") no-repeat scroll 0 0 transparent; } span.full_screen_icon { background-position: 0px 0px; cursor: pointer; opacity: 0; heig

Reading unicode file in c -

i want read read unicode text file in normal c. following code not working same, #include<stdio.h> int main() { file *ptr_file; char buf[1000]; ptr_file =fopen("input.txt","r"); if (!ptr_file) return 1; while (fgets(buf,1000, ptr_file)!=null) printf("%s",buf); fclose(ptr_file); return 0; } try this: #include <locale.h> #include <stdio.h> #include <wchar.h> int main() { file *input; wchar_t buf[1000]; setlocale(lc_ctype,"it_it.utf-8"); // put locale here if ((input = fopen("input.txt","r")) == null) return 1; while (fgetws(buf,1000,input)!=null) wprintf(l"%s",buf); fclose(input); }

google app engine - Disable datastore writes programatically when running scheduled backups? -

i running daily scheduled backup of datastore.. is possible programtically disable datastore writes when this scheduled backup being executed? , enable once it's done? no, can't (13 jun 2013) disable datastore writes programmatically. if app checking capabilities api wrap described in google app engine datastore writes: how enable/disable read-only mode remotely? approach unavoidably prone race condition (you might check capability before gets disabled). although parts of documentation suggest should set application read-only mode during backups , restores, in practise should fine backup while app still running, long app making appropriate use of transactions ensure consistency. other parts of docs such the article on scheduled backups don't suggest necessary.

c# - Sending Email from my application cause an exception -

i have application send email issues. use smtpclient class work. works fine 1 of mail servers use exchange server sending mail. sendemail method throw exception message: 550 requested action not taken: mailbox unavailable / 5.7.1 unable relay is problem application or mail server configuration? solution? well smtp error 550 generically (based on little searching) define like: 550 requested actions not taken mail box unavailable. this error @ destination. eg. disk drive has filled up. in case: 550 requested action not taken: mailbox unavailable / 5.7.1 unable relay the suffix indicates: the email not hosted on smtp server you're communicating with. that smtp server refusing forward final destination (or relay). there many possible reasons #2 (eg. isp's smtp server relay when sending inside isp's network) finding out need specifics (and temporary situation loss of connectivity). best talk administrator/support server.

websocket - Remote Control for Website -

i want start create website opened on mobile phone (any kind of smartphone). website have feature control website have opened on computer. (the volkswagen new century beetle 2011 had feature, scroll via smartphone on website opened on desktop computer) we have streaming website horsevideos, , awesome feature our customers, if watch streams on smart tv , control via iphone/android/wp. also wilmaa.com switzerland provides remote control smartphone navigate on website on smart tv/webbrowser. because need starting point learn how works checking google, maybe there remote controls outside, unfortunately couldn't find anything. maybe stack overflow can me giving starting points on how realize this. to need kind of 'pushing' service able overcome inherent drawback of http has been 'pull only' system - client initiates request, server answers. in case want push event server client. for past years has been done called 'long polling' . means 

iphone - Need to restrict my app to only run on devices with an L.E.D -

i've built flashlight app, how can put restriction in place install on devices l.e.d? presume uidevicerequiredcapabilities , not sure key/value use. you can set camera-flash key of uidevicerequiredcapabilities properties yes make sure install on devices contain "camera flash" (usually torch)

sdk - Corona storyboard.gotoScene options not working -

i'm using simple line of code in corona transition between scenes - transition happens effect doesn't. storyboard.gotoscene( "splash", "fade", 2000 ) i've compiled build xcode simulator see if fade effect work there , doesn't. complete code - local storyboard = require "storyboard" local scene = storyboard.newscene() local splashgroup = display.newgroup() local function onbackgroundtouch() storyboard.gotoscene("mainmenu", "fade", 2000) end --called if scene hasn't been seen function scene:createscene (event) local logoimage = display.newimage("roxislogo.png") logoimage.x = display.contentwidth/2 logoimage.x = display.contentheight/2 splashgroup:insert(logoimage) logoimage:addeventlistener("tap", onbackgroundtouch) end function scene:enterscene(event) splashgroup.alpha=1 end function scene:exitscene(event) splashgroup.alpha

c++ cli - Error on !String.IsNullOrEmpty(s)) -

this code in c++ list<string^> ^getcodecs() { list<string^> ^l = gcnew list<string^>; string ^s = gcnew string(encoder_getfirstcodecname()); while (!string.isnullorempty(s)) { l->add(s); s = gcnew string(encoder_getnextcodecname()); } return l; } the error on line: while (!string.isnullorempty(s)) on string the error/s string: this warning: warning 1 warning c4832: token '.' illegal after udt 'system::string' the errors: error 2 error c2275: 'system::string' : illegal use of type expression error 3 error c2228: left of '.isnullorempty' must have class/struct/union error 4 error c1903: unable recover previous error(s); stopping compilation error 5 intellisense: type name not allowed how can fix them ? since isnullorempty static function, you'd have call using :: operator: while (!string::isnullorempty(s))

java - My return is not stopping execution -

Image
i have return, can see line "this not print" shouldn't reached after return happens gets called. what's going on? here's entire procedure, it's rough copy @ moment...: private void greedysearch (string lookfornode) { // note: available vars // reqstartnode // reqendnode // search through entire tree looking for... system.out.println("searching through entire tree looking "+lookfornode); (int = 0; < treelist.size(); i++) { data currentnode = treelist.get(i); // ... reqstartnode if (currentnode.getnodename().equals(lookfornode)) { system.out.println("found matching node. currentnode.getnodename=" + currentnode.getnodename()+" lookfornode="+lookfornode); // check see if there's children? if (currentnode.childrenlist.size() > 0) { // find smallest child node double small

Error while instantiating MATLAB Engine Interface through COM (Matlab C# Integration) -

i have called matlab functions c# using com objects. runs on multiple calls gives exception while instantiating matlab engine interface through com. //for instantiating matlab engine interface through com mlapp.mlappclass matlab = new mlapp.mlappclass(); exception gives: unable cast com object of type 'mlapp.mlappclass' interface type 'mlapp.dimlapp'. operation failed because queryinterface call on com component interface iid '{669cec93-6e22-11cf-a4d6-00a024583c19}' failed due following error: rpc server unavailable. (exception hresult: 0x800706ba). i'm unable figure out. appreciated. i had same problem. using 2 private functions, creating 2 different matlab objects inside functions. made matlab object global problem solved(as below). problem might not same. public partial class form1 : form { #region ----> global variables // create matlab instance mlapp.mlapp matlab = new mlapp.mlapp();

asp.net - C# GridView Design -

Image
at moment programming social media website in aspx.net. i using mysql (phpmyadmin) database store data, en read data from. for example: when user posts on wall, posted text saved in database, , post shown @ profile page reading database. to show posts using gridview. this example how looks @ moment (gridview-style): after doing research still can't find how design gridview. have this: http://www.y451n.nl/publicuploads/gridviewdesign.png http://www.y451n.nl/publicuploads/gridviewdesign.png i appreciate guys! thanks in advance. well, design hard achieve (limited) gridview. recommend use flexibility of repeater. http://msdn.microsoft.com/nl-nl/library/system.web.ui.webcontrols.repeater(v=vs.110).aspx it has same databinding principles, can use itemtemplates give more control on html. or, if have started, switch mvc pattern optimum flexibility.

optimization - MATLAB Genetic Algorithm "Subscripted assignment dimension mismatch" Error -

when trying use genetic algorithm solver in matlab, i'm getting following "subscripted assignment dimension mismatch" error: error message pastebin now, says error has fitness function @ end, when test fitness function separately, works without errors. can link code fitness , constraint functions if help. thank much! i think see happening... because 1 of appendages cdraft inside if, don't return same length vector - i.e., return constraint vector first time, preallocates matrix constraint output, next time round give doesn't fit in matrix, error. the clue in error stack: @ top of stack have subscripted assignment dimension mismatch. error in c:\program files\matlab\r2012b\toolbox\globaloptim\globaloptim\private\gaminlppenaltyfcn.p>i_convectorizer (line 135) clearly not function you've written, , inspecting function there's nothing should cause error. end of error gives clue caused by: failure in initial us

ios - Adding new language to existing localized app -

i have app uses localization, need add 1 more language, want display 2 different language images of same name in 1 xib file, xib file not localized localizing images. can done using interface builder, without writing code? add images localized subdirectories in project (en.lproj, es.lproj, etc.) , ios pick correct image when unarchives localized xib file. xcode can automatically: select resource want localize (an image, xib file, etc.), display file inspector pane, , click localize button. (as side note, it's bad practice localize high number of images. should remove text images , choose them "neutral" , "understandable" in every region of world. app size thank it.)

java - servlets: get the null parameters by ajax in servlets -

string isno1=request.getparameter("isbn"); string bktitle2=request.getparameter("booktitle"); string authr3=(string) request.getparameter("author"); system.out.println(isno1+bktitle2+authr3); enumeration paramaternames = request.getparameternames(); when taking parameters in servlet gettin values 'null' what wrong doing. this way setting parameters... from jsp page using script tag <script type="text/javascript"> function gethttpobject() { var httpobject; if(!httpobject && typeof(xmlhttprequest) != 'undefined') { try{ httpobject=new xmlhttprequest(); } catch(e){ xmlhttp=false; } } return httpobject; } var h

Resizing images without PHP GD Library -

is there other method resizing images (pixels , kb/mb) , simple tasks without gd library? can't images resized css/jquery ? i'm starting new project , told me use gd this, i'm wondering if there others alternative client/side because don't know gd library , time short project, i'll lose time learn it. the imagine php library sf easiest i've worked - can use gd, imagick, or gmagick resize/crop images. <?php $imagine = new imagine\gd\imagine(); $size = new imagine\image\box(40, 40); $imagine->open('/path/to/large_image.jpg') ->thumbnail($size, imagine\image\imageinterface::thumbnail_inset) ->save('/path/to/thumbnail.png');

ruby on rails - Bootstrap datepicker default value simple_form_for -

i using bootstrap date picker enable selection of dates in form using simple_form_for. example <%= f.input :payment_date, as: :string, input_html: { class: "datepicker" } %> my date picker uses format of dd-mm-yyyy i set today's date default value in form using simple_form_for, ideas on how can that? <%= f.input :payment_date, as: :string, input_html: { class: "datepicker", value: time.now.strftime('%d-%m-%y') } %> another format is: (working active admin gem) f.input :date, as: :date_picker, :input_html => { :value => date.today}

java - Jtable inserting in JTextpane using null layout -

how create jtable in jtextpane using null layout? there multiple approaches. e.g. insert table http://java-sl.com/jeditorpanetables.html you can add jtable usual component using add() method , setting bounds jtable . the third way call insertcomponent() passing jtable

php - CodeIgniter core changes -

ci looks segment[1] controller (in controller dir) , segment[2] method. now, have specific requirement business application needs not want ci or force go controller dir load have "domainurl/module_identifier_id/controller/method/" . here, every request coming along associated module's identifier id have complete module's configuration , other data ( controller files, module location uploaded, menus , urls have same url mechanism want design developers develop modules , upload ) stored in db. we need id , play fetch relevent records , point ci load controller want , indeed rest methods etc every thing needs working is. i hope understand looking have our own main controller type file of requests coming customizing protocol described above , developers following means, there must module identifier first , controller, method etc... let me know if have query cleared on? i think use routes this: $route[(:any)/(:any)/(:any)] = '$2/$3/$1';

javascript - vba excel internet explorer disable warning https message -

when loading website , following security warning : do want view webpage content delivered securely. this popup cause code go error , there way disable vba ? thanks. here code sub start() dim ie new internetexplorer dim doc htmldocument ie.visible = true ie.navigate ("https://mywebsite.com") ie.fullscreen = true doevents loop until ie.readystate = readystate_complete set doc = ie.document doc.getelementbyid("navmenu2").click the reason warning you’re on ssl-secured (https protocol) page attempting load non-ssl (http protocol) content. the best ways fix either: visit website http instead of https - ie.navigate ("http://mywebsite.com") fix security issues in website (do not load unsecure content when visiting https) if want fix testing purposes, can change settings in test browser : go tools -> internet options -> security select "security" tab -> click "custom level" button

http - Convert path queries to url variables with .htaccess? -

i want convert entity query ' http://www.mysite.com/users ' ' http://www.mysite.com/entities.php?entityname=users '. how make such rewrite rule? or should put .htaccess? would great preserve original url variables, convert ' http://www.mysite.com/users?fields=id,uuid ' ' http://www.mysite.com/entities.php?entityname=users&fields=id,uuid '. if want rewrite (and not redirect) / $users /entities.php?entityname= $users while preserving original query string, rewrite / $users ?fields=id,uuid /entities.php?entityname= $users &fields=id,uuid try this: rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([a-za-z0-9_-]+)/?$ /entities.php?entityname=$1 [qsa]

javascript - Making JS request to my Rails API -

i new rails. creating basic rails-api. trying add user model using js request ... here html file: (add-user.html) <script type="text/javascript" charset="utf-8"> $(function () { $('#adduser').submit(function(e){ $.post('http://localhost:3000/users', {user: {username: $("#usr").value}, user: {password:$("#psw").value}}); }); }); </script> <form id="adduser" data-ajax="false"> <input type="text" id="usr" placeholder="username"/> <input type="password" id="psw" placeholder="password"/> <input type="submit" value="add user" id="usradd" name="login"/> </form> when click on submit, $.post() adds data url ... data not added model ... my users_controller code: def new @user = user.new render json: @user end def create @user

sql - INSERT INTO only if not exists MYSQL -

this question has answer here: how update if exists, insert if not (aka “upsert” or “merge”) in mysql? 2 answers i'm insert data way of using select , not values default. problem can't find way insert data if it's not in database. this current query: insert collectives_users(id_user,id_artistname,id_collective,users_type,status) select (select id_user artistnames artistname = 'yoannis'), (select id artistnames artistname = 'yoannis'), ('1'),(2),(0) union select (select id_user artistnames artistname = 'paul'), (select id artistnames artistname = 'paul'), ('1'),(4),(0) i tried with insert ignore doesn't work , not appropriate (not returning error) i tried with and not exist doesn't work. if have idea don't hesitate. have tried replace syntax? wo

csv - Javascript: set filename to be downloaded -

i'm using plugin generate csv file table, file being downloaded "download" filename, how can change filename e.g. dowload.csv var csv = $("#table").table2csv({delivery:'download'}); window.location.href = 'data:text/csv;charset=utf-8,'+ encodeuricomponent(csv); i wrote tool can use save file downloads folder of local machine custom filename, if that's possible on client's machine. as of writing, need chrome, firefox, or ie10 specific capability, tool falls-back un-named download if that's that's available, since better nothing... for use: download(csv, "dowload.csv", "text/csv"); and magic code: function download(strdata, strfilename, strmimetype) { var d = document, = d.createelement("a"); strmimetype= strmimetype || "application/octet-stream"; if (navigator.mssaveblob) { // ie10 return navigator.mssaveblob(new blob([strdata], {type

java - image is snapping back to old location, translate, android, xml -

what trying animate image current position new 1 following xml <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate xmlns:android ="http://schemas.android.com/apk/res/android" android:fromxdelta ="0" android:toxdelta ="0" android:fromydelta ="0" android:toydelta ="-100" android:duration ="2000" android:fillafter ="true" /> </set> java code imageview logo01 = (imageview) findviewbyid(r.id.logo01); animation animation01 = animationutils.loadanimation(this, r.anim.translate); animation01.reset(); logo01.clearanimation(); logo01.startanimation(animation01); however, @ end of animation, image snapping old postion. how can avoid situation @ end, image @ new position.

c# - Removing XML node -

i have got yet task not able accomplish: supposed parse xml this site , remove nodes don't have "video" in name , save xml file. have no problems reading , writing, removing makes me difficulties. have tried node -> parent node -> child node work-aroud, did not seem useful: static void main(string[] args) { using (webclient wc = new webclient()) { string s = wc.downloadstring("http://feeds.bbci.co.uk/news/health/rss.xml"); xmlelement tbr = null; xmldocument xml = new xmldocument(); xml.loadxml(s); foreach (xmlnode node in xml["rss"]["channel"].childnodes) { if (node.name.equals("item") && node["title"].innertext.startswith("video")) { console.writeline(node["title"].innertext); } else {

java - Check if a String is a number -

i know can check if string integer doing integer.parseint("1234"); want link textual number integer. i.e. "one" == 1 "two" == 2 "three" == 3 "twenty" == 20 is there library can use this, or have program hand? the reason want this, have android application speech recognition. user can count. number shown on screen. edit after experimenting, figured out speechrecognizer class use automatically parses numbers actual numbers... i not sure if there library here example.

Rails 3 session & cookie how to persist session id cookie -

i developing simple shopping cart based on session_id i.e. determination of user cart items used session_id. but when user closes browser , opens again session id been changed. , loses items in cart. i suspect such feature can provide saving session id in cookie. am right? any way question how provide functionality allows users cart items after closing browser? i recommend reading rails guide: action controller overview ( http://guides.rubyonrails.org/action_controller_overview.html ). sections 4 , 5 cover sessions , cookies , give deeper understanding on how use them , make easy tackle feature challenges. i check out ruby on rails actiondispatch::cookies < object documentation ( http://api.rubyonrails.org/classes/actiondispatch/cookies.html ) an example of controller code looking listed on resource. here example: # sets cookie expires in 1 hour. cookies[:login] = { :value => "xj-122", :expires => 1.hour.from_now }

Matlab irregular shape surf-like plot -

Image
i intend use matlab plot probability distribution stochastic process on state space. state space can represented lower triangle of 150x150 matrix. please see figure (a surf plot without mesh) probability distribution @ time point. as can see, there high degree of symmetry in graph, because plotted square matrix, looks kind of weird. transform rectangle plot perfect. question is, how can use matlab plot/transform lower triangle portion as/to equal-lateral triangle? this function should job you. if not, please let me know. function matrix_lower_tri_to_surf(a) %displays lower triangle portion of matrix equilateral triangle %martin stĂ¥lberg, uppsala university, 2013-07-12 %mast4461 @ gmail siz = size(a); n = siz(1); if ~(ndims(a)==2) || ~(n == siz(2)) error('matrix must square'); end zeds = @(n) zeros(n*(n+1)/2,1); %for initializing coordinate vectors x = zeds(n); %x coordinates y = zeds(n); %y coordinates z = zeds(n); %z coordinates, remain 0 r = zeds(n)

c++ - Why would the compiler use a virtual call for `datum::rotate()` below? -

on page 26 of "inside c++ object module" s. lippman, you'll find following snippet: void rotate( x datum, const x *pointer, const x &reference ) { // cannot determine until run-time // actual instance of rotate() invoked (*pointer).rotate(); reference.rotate(); // invokes x::rotate() datum.rotate(); } main() { z z; // subtype of x rotate( z, &z, z ); return 0; } and paragraph: the 2 invocations through pointer , reference resolved dynamically. in example, both invoke z::rotate(). invocation through datum may or may not invoked through virtual mechanism; however, invoke x::rotate(). afaik, datum.rotate() invoked static call. why compiler use virtual call here? the compiler may choose use virtual call though doing not necessary. standard not compiler "must" convert static call. long "right" function called, compiler has done it's job. edit: appear standard (at least n3337) doesn'

objective c - how to customize More Tabbar TableView Cell for storyboard ios 6? -

i have add 6 or more tabbar on storyboard. automatically generate more tab. when click more button. can see other view controller on tableview row cell. couldn't change cell view. how customize cell view more tabbar table view ? best regards. create custom table view cell reference go through http://www.appcoda.com/customize-table-view-cells-for-uitableview/

c++ - std::make_signed that accepts floating point types -

i have templated class can instantiated scalar types (integers, floats, etc.) , want member typedef signed variant of type. is: unsigned int -> signed int signed long long -> signed long long (already signed) unsigned char -> signed char float -> float long double -> long double etc... unfortunately, std::make_signed works integral types, not floating point types. simplest way this? i'm looking of form using signedt = ...; , part of templated class template parameter t guaranteed scalar. a simple template alias do: #include <type_traits> template<typename t> struct identity { using type = t; }; template<typename t> using try_make_signed = typename std::conditional< std::is_integral<t>::value, std::make_signed<t>, identity<t> >::type; and how test it: int main() { static_assert(::is_same< try_make_signed<unsigned int>::type, int

c# - Why can't I use my data contracts form my IService? -

i have following data contracts defined in iservice: [datacontract] public class pumpclass { [datamember] public int id { get; set; } [datamember] public double litrespumped { get; set; } [datamember] public double price { get; set; } [datamember] public string fueltype { get; set; } [datamember] public datetime date { get; set; } [datamember] public bool requestuse { get; set; } [datamember] public bool requestaccepted { get; set; } [datamember] public bool finished { get; set; } } [datacontract] public class dieseltank { [datamember] public double maximumlevel { get; set; } [datamember] public double warninglevel { get; set; } [datamember] public double currentlevel { get; set; } [datamember] public bool orderfuel { get; set; } } [datacontract] public class unleadedtank { [datamember] public double maximumlevel { get; set; } [datamember] public double warninglevel {

java - "Literal does not match the format string" error -

when try execute below code gives me java.sql.sqlexception: ora-01861: literal not match format string error. i trying copy of column values customer1_details table customer2_details table. columns datatype trying move timestamp(6) time_registered , date_discharged columns , datatype date_of_birth column date try { connection conn=address.getoracleconnection(); int id = 1; date dob = null; timestamp timereg = null,datedischarged = null; statement stmt=conn.createstatement(); resultset res=stmt.executequery("select time_registered,date_discharged,date_of_birth customer1_details customer_id = '"+id+"' "); if(res.next()) { timereg=res.gettimestamp("time_registered"); datedischarged=res.gettimestamp("date_discharged"); dob=res.getdate("date_of_birth");

c# - nested class used within base and derived classes -

i'm getting stack overflow exceptin in setter of code node nested data class how should nested data class desc handled in base , derived classes, can use data in new nodes created in main window? namespace lib { // nested data class public class desc { public desc(string shape, nullable<bool>[] inpins) { this.inpins = inpins; } string shape { get; set; } nullable<bool>[] inpins { get; set; } } // base class drived shapenode class in vendor's framework public class node : shapenode { public node() { } // make copy of node public node(node copy) : base(copy) { text = copy.text; nodeid = copy.nodeid; } public virtual node clone() { return new node(this); } // base constructor public node(string text, desc nodeid) { this.text = t

Google Chart Link to same page inside a Table (basically do bookmarking within the same page) -

from within google chart table; how create link "inside" same page (basically bookmarking within same page). know how link outside web pages using data.addcolumn('link', 'link'); there way can add link inside table representing bookmarks. <html> <head> <script type='text/javascript' src='https://www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1', {packages:['table']}); google.setonloadcallback(drawtable); function drawtable() { var data = new google.visualization.datatable(); data.addcolumn('string', 'name'); data.addcolumn('number', 'salary'); data.addcolumn('boolean', 'full time employee'); data.addrows([ ['mike', {v: 10000, f: '$10,000'}, true,], ['jim', {v:8000, f: &

mysql - huge data from a file to database using java? -

i able load huge text file data database number of lines 33264591. used normal bufferedreader reading line line , able push data. here taking enormous time loading 3 hrs reading line line , insert database. could 1 suggest me better way quick insertion of data using java? thank in advance well, before going further, suggest using profiler , finding out why takes time. if know problem is, easier fix.

javascript - How do I pad out a string with leading blanks? -

i need test length of string $a in ultraedit script (javascript), , pad out leading blanks if less x (say: 30). there's following suggesting found on stack overflow, doesn't seem work in ultraedit script. $aaa .= (" " x (35 - length($aaa))); suggestions appreciated. ps: ultraedit uses javascript core engine scripts. in javascript core used in ultraedit scripts there no function print formatted string variable. but nevertheless easy create aligned strings leading spaces or zeros. example fixed length output of number: var nnumber = 30; // number output right aligned 4 digits var salignspaces = " "; // string containing spaces (or zeros) aligning // convert integer number decimal string. var snumber = nnumber.tostring(10); // has decimal string less 4 characters defined salignspaces? if (snumber.length < salignspaces.length) { // build decimal string new x spaces (here 2) alignment // spaces string , concatena

java: TrayIcon right click disabled on Mac OsX -

i'm trying develop mac osx app provided system tray icon, after first attempt simplest code achieve noticed every apps tray icon's (both system , user apps) on mac osx (10.8) allows activate relative popup menu both left , right click on project left (mouseevent.botton1) button causes popup menu pulldown. here's code: public class systemtraydemo { private systemtray tray; private trayicon tray_icon; public systemtraydemo() { if (!systemtray.issupported()) { joptionpane.showmessagedialog(null, "system tray not supported!"); return; } else tray = systemtray.getsystemtray(); final popupmenu popup = new popupmenu(); menuitem exit = new menuitem("exit"); exit.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { if (tray != null) {

Building a packet to send to a minecraft server - python -

i've been trying hours (literally) send packet minecraft server. http://www.minecraftwiki.net/wiki/classic_server_protocol#packet_protocol (the player identification bit). i'm getting error 'struct.error: argument 's' must bytes object'. here's code: packet = struct.pack('bb8s110sb', 0, 7, username, verification_key, 0) # packet type s.send(packet) how can send player identification packet server? any appreciated , not able reply answers @ least 12 hours when posted. +rep help, :) the struct's pack function requires username , verification_key byte objects. in python 3 when define string so, 'asdf', encoded using unicode. in order support many encodings python has byte object. convert strings byte objects have call encode method desired encoding argument. in case 'ascii' work both of variables so, packet = struct.pack('bb8s110sb', 0, 7, username.encode('ascii'), verification_key.encode('a

c++ - I assign a pointer and it nulls itself out -

so have constructor object, on creation sets few values , places @ end of linked list. the problem i'm having when assigns address of new object head or tail of list, assigns, leaves constructor , reason head , tail both reset 0. object object1("oddjob", 2, 2, 9); calls constructor object::object(string label, float x, float y, float z) { x_ = x; y_ = y; z_ = z; if(label == "") { label = "object"; } label_ = label; if(headobject == 0) { headobject = this; tailobject = this; } else { tailobject->next = this; tailobject = this; } next = 0; } edit: headobject , tailobject globals declared in .h file. declared as: static object * headobject; static object * tailobject; the use of static on global object causes have internal linkage. means each translation unit includes header have own version of headobject , tailobject . instead, should declare them extern in header file: e

php - Counting results filtered by distinct() or group_by() in Codeigniter -

i want count results of active record query ci (using postgresql). using count_all_results() , works fine queries, not when using distinct() or group_by() after join, because count_all_results() ignores these functions. here fix vor this, not yet implemented in newsest (2.1.3) stable version. https://github.com/ellislab/codeigniter/commit/b05f506daba5dc954fc8bcae76b4a5f97a7433c1 when try implement fix in current version myself, there no additional filtering done. row count stays same. any tips on how implement in current version, or other ways count results filtered distinct() or group_by() ? $this->db->select('count(id)'); $this->db->join(); $this->db->distinct(); $this->db->group_by(); //...etc ... $query = $this->db->get('mytable'); return count($query->result()); or $this->db->join(); $this->db->distinct(); $this->db->group_by(); //...etc ... $quer

android - Wallpaper App Code Optimazation -

hey friend making wallpaper app using bitmap.. have more 50 images app...the problem facing have add line of code images in java code xml file... so please let me know there way overcome adding loop or something...anything can reduce code , can add more images... the java code repeating is(just few line getting repeated) : display = (imageview) findviewbyid(r.id.ivdisplay); imageview image1 = (imageview) findviewbyid(r.id.viewimage1); imageview image2 = (imageview) findviewbyid(r.id.viewimage2); imageview image3 = (imageview) findviewbyid(r.id.viewimage3); imageview image4 = (imageview) findviewbyid(r.id.viewimage4); imageview image5 = (imageview) findviewbyid(r.id.viewimage5); imageview image6 = (imageview) findviewbyid(r.id.viewimage6); imageview image7 = (imageview) findviewbyid(r.id.viewimage7); imageview image8 = (imageview) findviewbyid(r.id.viewimage8); imageview image9 = (imageview) findviewbyid(r.id.viewimage9); so on then afte

ubuntu - How do I change to su to modify a file in ruby script -

i have existing ruby on rails app work fine, need add line system file app not have access to. there simple way open file su? (ruby 1.9.3, rails 3.2, ubuntu 12.4) it's bad idea security perspective allow general su or sudo privileges application accepts requests world. couple safer approaches: 1) change group ownership of particular system file share group application user belongs , set group-write permission on file. # assuming want manipulate /etc/foobar , app runs user rails in group rails chgrp rails /etc/foobar chmod g+rw /etc/foobar 2) safer yet. write separate program implements limited changes target system file based on arguments passed it. enable rails app user have passwordless sudo privledge execute 1 program. see sudoers documentation info on how enable limited privilege. with either method, careful not use data got outside application source without validating via formal parser and/or whitelist.

bootloader - How to insert x86 opcode data from .data segment bits in to operand instruction in x86 machine code? -

i working on x86 bootloader written entirely in opcodes, no headers, binary. the problem intel's isa manual not include how include data segment bytes .data segment code in secondary operands of machine instructions in opcode format. i have far: 1000 101w 110 that above code should equivalent following: mov si however, need insert data source index register containing "hello world" displayed on screen in monochrome text video mode, this: mov si, hello_world_byte_string any help? the bootloader loaded @ fixed address ( 0000:7c00 ) bios, if put string in point in code, can reference offset start of program. you can see link http://www.vnutz.com/articles/pc_bootsector_programming_tutorial_in_asm

eclipse - Connect to serial port in Java using RXTX -

i'm using eclipse communicate arduino, through arduino platform. can open port using eclipse or arduino, can't connect opened port using eclipse. send integers using eclipse through arduino platform, , received arduino. how can connect eclipse arduino's serial port? this actual code (i found in utilisation des ports com en java avec rxtx [résolu] (is in french)): import gnu.io.unsupportedcommoperationexception; import java.io.ioexception; import java.util.scanner; public class testserialport { public static void main(string[] args) { scanner sc = new scanner(system.in); system.out.println("le port est-il ouvert? "); string str = sc.nextline(); system.out.println("vous avez saisi : " + str); string s1 = "non"; if ( s1.equals(str)) { final rs232 serial = new rs232(); system.out.println("- ouverture du port -"); serial.setport