Posts

Showing posts from May, 2011

haskell - Preventing "getCurrentDirectory: resource exhausted (Too many open files)" error -

i trying run parsec parser on whole bunch of small files, , getting error saying have many open files. understand need use strict io, i'm not sure how that. problematic code: files = getdirectorycontents historyfolder hands :: io [either parseerror [hand]] hands = join $ sequence <$> parsefromfile (many hand) <<$>> files note: <<$>> function this: (<<$>>) :: (functor f1, functor f2) => (a -> b) -> f1 (f2 a) -> f1 (f2 b) <<$>> b = (a <$>) <$> b i don't know parsefromfile function looks right (probably idea include in question), i'm guessing you're using prelude.readfile , @markus1189 points out includes lazy i/o. strict i/o, need strict readfile , such data.text.io.readfile . a streaming data library pipes or conduit allow avoid reading entire file memory @ once, though- knowledge- parsec doesn't provide streaming interface allow happen. attoparsec, on other hand,

c++ - How much memory does a stack take? -

i'm writing sort algorithm can use stacks. increasing amount of stacks, can sort less operations. anyway, have dataset of 10 integers. difference in memory following (with std::stack ): an array of stacks of size 2 (5 integers per stack) an array of size 10 (1 integer per stack) an array of size 20 (1 integer each in 10 stacks, 10 stacks empty) also, how memory empty stack of int take? int pointer? please treat question academic one. know there better ways of solving problem, can use stacks. the obvious answer is: depends. in reality, there things can said. all of containers incur modest amount of overhead, of order of (perhaps) couple of pointers , couple of integers, @ most. can find out how if want know, constant , quite small, depending on implementation. where c++ standard helps places requirements on storage part of container. because iterators (more or less) equivalent pointers, stack elements placed @ consecutive memory locations same alignment

arm - Illegal instruction in Raspberry Pi -

today, compiled opencv-master downloaded github . these instructions in webpage http://ariandy1.wordpress.com/2013/02/13/raspberry-pi-rasbian-opencv/ , , opencv compiled successfully. when wrote simple c++ program, link -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_video , run in terminal. error occured, says illegal instruction . when remove opencv -dependent code, , recompile, can run successfully. doubt packages installed apt-get have bugs. can't find them. face problem? the /etc/apt/sources.list is: deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi deb http://www.deb-multimedia.org/ wheezy main non-free deb http://archive.raspbian.org/raspbian wheezy main contrib non-free deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free update the output of dmesg is: http://pastebin.com/dsr8mgvy update 2 the output of ldd command : http://pastebin.com/s7suqabk update 3 the output of &

java - How do I use OAuth 2.0 to access Google Calendar (Service Model)? -

Image
i'm trying groovy/grails application speak google calendar api java, using service model. i'll happy simple calendar list. no matter though, end with: uri: /test class: com.google.api.client.auth.oauth2.tokenresponseexception message: 400 bad request { "error" : "invalid_grant" } the same user "googleaccounts@quirk.biz" owns both calendar , api console app. code follows: package quirkplanner import com.google.api.client.googleapis.auth.oauth2.googlecredential; import com.google.api.client.googleapis.javanet.googlenethttptransport import com.google.api.client.http.httptransport import com.google.api.client.json.jsonfactory import com.google.api.client.json.jackson2.jacksonfactory; import com.google.api.services.calendar.calendar import com.google.api.services.calendar.model.*; class testcontroller { def servletcontext private static final httptransport http_transport = googlenethttptransport.newtrustedtransport(); private s

c - Replace floating point math with integer in sigmoid transfer function -

i replace floating point math in these function without losing precision, because have no fpu. possible? think 3 numbers after comma enough. inline float smaller_f(float value, float bias) { return value < bias ? value : bias; } inline float pow2_f(float fval) { return fval * fval; } float sigm_f(float fx, float fslope) { float fval = (180.f - smaller_f(fabs(fslope * fx), 179.9f) ) / 180.f; return fval / sqrt(1.f + pow2_f(fval) ); } a fixed-point math library need. preferred solution anthony williams' fixed-point math c++ library . because in c++ , defines fixed class extensive function , operator overloading, can largely used replacing float or double in existing code fixed . uses int64_t underlying integer data type, 34 integer bits , 28 fractional bits (34q28), 8 decimal places , wider range int32_t . if compiler supports c++, can still write code using c subset if prefer, using c++ support library. on 32bit arm library performs 5 times fas

javascript - HTML - An editable paragraph -

this code : (html) <html> <head> <title>editable paragraph</title> </head> <body> <label onclick="changetext(0);" class="edit-button"></label> <h1 id="h1">editable paragraph</h1> <br> <label onclick="changetext(1);" class="edit-button"></label> <p id="p1">hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! hello world! </p> <br> <label onclick="changetext(2);" class="edit-button"></label> <p id="p2">hello world! hello world! hello

javascript - Transitioning to state with query parameter -

i'm using angular ui-router manage client side routing. i'm trying use $state.go() method switch states, want include query parameter in new url, , i'm not sure how to. i've defined target state in app module: $stateprovider.state('login', { url: '/login?returnurl', //more properties } and want navigate http://localhost:3000/login?returnurl=%2fhome . how format $state.go() call correctly? this should work: $state.go('login', { 'returnurl': '/home' }); or if want call login page http response interceptor on 401: $state.go('login', { 'returnurl': $state.current.url });

qt - Items in a QGraphicsScene near the mouse -

i trying find items under mouse in scene. code using follows: qpainterpath mousepath; mousepath.addellipse(mouseevent -> pos(),5,5); qlist<qgraphicsitem *> itemscandidate = this->items(mousepath); if (!(itemscandidate.contains(lastselecteditem))) lastselecteditem =itemscandidate.first(); ps: refers scene. the code should find items intersected small circle around mouse position , keep item pointer unchanged if previous intersected 1 still intersected, or take first in qlist otherwise. unfortunately, code not work items inside each other. example, if have rect side rect, outer rect intersecting mouse position when 1 near inner rect. how can solve this? update: seems not problem polygons, rect, ellipses, etc. update: code in redefined scene::mousemoveevent you can reimplement ‍ mousemoveevent in ‍ qgraphicsview‍ capture mouse move events in view , track items near mouse like: void myview::mousemoveevent(qmouseevent *event) { qp

javascript - Align decimal points to right in input type text -

Image
i want format numbers 2 decimal places , want aligned the, i.e. don't want numbers centered, left aligned, etc. don't know how easy do, want alignment on decimal point.kind of this: 123.44 1465.23 12.24 right align ok long numbers have 2 dp. don't want numbers this: 1554 23.75 they should this: 1554.00 23.75 html code <table class="table grey-table"> <thead> <tr> <th style="padding:1px 8px;">description</th> <th style="padding:1px 8px;">total</th> </tr> </thead> <tr> <td style="padding:1px 8px;">countertops</td> <td style="width:150px;"><input type="text" id="txt_cm_countertops" readonly="true" style="width:150px;"/></td> </tr> <tr> <td style="padding:1px 8px;">li in.</td&

python - Django auth system - how to hand over post request from template to view -

seems having basic understanding problem: i try call function view: template : <form class="navbar" role="form" action="/test/" method="post"> {% csrf_token %} {{ form.as_p }} <div class="form-group"> <input type="text" placeholder="username" class="form-control" id="username"> </div> <div class="form-group"> <input type="password" placeholder="password" class="form-control" id="password"> </div> <button type="submit" class="btn btn-success">sign in</button> </form> my urls file, place completly don't understand whats going on , docs not specific :-/ urlpatterns = patterns('', url(r'^test/$', createsession()), url(r'^$', loginview.as_view(), name='home'), ) throws cre

html - Icons not visible till you interact with the page (mouseover) -

i have following problem have social icons on webpage. first time load page icons aren't visible. when go on icon becomes visible , stays visible. .social-icons-float .social-icon { display: block; padding-bottom: 5px; font-size: 13px; } .social-icons-float .social-icon .social-count { display: block; border: 1px solid #e3e3e3; text-align: center; padding: 12px 0px; font-size: 24px; font-family: 'titillium web', sans-serif; font-weight: bold; color: #a0a0a0; position: relative; margin-bottom: 8px; } .social-icons-float .social-icon .social-count .social-arrow { display: block; overflow: hidden; height: 10px; position: absolute; bottom: -10px; width: 100%; } could 1 please me that happens , more seen in google chrome. of images on sites blocks of border 1px. once mouseover them visible. i know that, bug nothing code here! :-)

javascript - Philips hue, convert xy from api to HEX or RGB -

i making web interface manage hue lamps, struggling when comes color handling.. the api of lamps provides me x , y coordinates http://en.wikipedia.org/wiki/cie_1931_color_space but not z value. i think must calculate z brightness value or saturation value (0 255). but terrible @ colors, , math :p. i tried use thoses functions https://github.com/eikeon/hue-color-converter/blob/master/colorconverter.ts but saw in comments, thoses functions not provide correct values... could me here please ? ☺ ps : need javascript function. okay manage make working of : how convert rgb value xy value phillips hue bulb function xybritorgb(x, y, bri){ z = 1.0 - x - y; y = bri / 255.0; // brightness of lamp x = (y / y) * x; z = (y / y) * z; r = x * 1.612 - y * 0.203 - z * 0.302; g = -x * 0.509 + y * 1.412 + z * 0.066; b = x * 0.026 - y * 0.072 + z * 0.962; r = r <= 0.0031308 ? 1

debugging - Plotting hypotrochoids using Python -

Image
i have been trying use computer plot hypotrochoids , i've run issues. unfamiliar, parametric equations of hypotrochoid are: x(theta) = (r - r)cos(theta) + d*cos((r-r)/r*theta) and y(theta) = (r - r)sin(theta) - d*sin((r-r)/r*theta) the definition on wikipedia of hypotrochoid can further explain: a hypotrochoid roulette traced point attached circle of radius r rolling around inside of fixed circle of radius r, point distance d center of interior circle. so hypotrochoid values r = d = 1 , r = 3 , should this: but not ending using computing method. hypotrochoid (with same values) looks this: since x , y values determined function of x , y @ angle theta assumed loop through values of theta 0 2pi , calculate x , y values separately @ intervals, plot coordinate in polar form (where r**2 = x**2 + y**2 ), suppose thought wrong. maybe formulae wrong checked on few guys on @ math stackexchange , couldn't figure out what's wrong. methods should us

jquery - $('.block').height($(this).width()); causing block height extend -

i trying set block's height equal width $('.block').height($(this).width()); it's not working reason. please see example: http://jsfiddle.net/uy3yb/ . need correct? fiddle demo $('.block').height(function () { return $(this).width(); }); .height( function(index, height) ) a function returning height set. receives index position of element in set , old height arguments. within function, refers current element in set problem code this below window object not $('.block') $('.block').height($(this).width());

ios - Remove Core Data from iCloud fails -

i'm trying remove core data icloud using [nspersistentstorecoordinator removeubiquitouscontentandpersistentstoreaturl:options:error:] . strange output: __93+[nspersistentstorecoordinator removeubiquitouscontentandpersistentstoreaturl:options:error:]_block_invoke(1982): coredata: ubiquity: unable move content directory new location: file:///private/var/mobile/library/mobile%20documents/<ubiquity_id>/ new: file:///private/var/mobile/library/mobile%20documents/oldubiquitouscontent-mobile~c9439ad0-1e87-4977-9c68-0674f5e2e93b error domain=nscocoaerrordomain code=513 "the operation couldn’t completed. (cocoa error 513.)" userinfo=0x181ab790 {nssourcefilepatherrorkey=/private/var/mobile/library/mobile documents/<ubiquity_id>, nsuserstringvariant=( move ), nsfilepath=/private/var/mobile/library/mobile documents/<ubiquity_id>, nsdestinationfilepath=/private/var/mobile/library/mobile documents/oldubiquitouscontent-mobile~c9439ad0-1e87-4977-9c68

python - How to check if there exists a row with a certain column value in pandas dataframe -

very new pandas. is there way check given pandas dataframe, if there exists row column value. have column 'name' , need check name if exists. and once this, need make similar query, bunch of values @ time. read there 'isin', i'm not sure how use it. need make query such rows have 'name' column matching of values in big array of names. import numpy np import pandas pd df = pd.dataframe(data = np.arange(8).reshape(4,2), columns=['name', 'value']) result: >>> df name value 0 0 1 1 2 3 2 4 5 3 6 7 >>> any(df.name == 4) true >>> any(df.name == 5) false second part: my_data = np.arange(8).reshape(4,2) my_data[0,0] = 4 df = pd.dataframe(data = my_data, columns=['name', 'value']) result: >>> df.loc[df.name == 4] name value 0 4 1 2 4 5 update: my_data = np.arange(8).reshape(4,2) my_data[0,0] = 4 df = pd.d

c# - Cookies not working using WebClient on Windows Phone -

my problem when use new webclient send url webservice asks me login, , after searched issue found need save cookies not working me. and upon request full code namespace phoneapp8 { public partial class mainpage : phoneapplicationpage { // constructor public mainpage() { initializecomponent(); // sample code localize applicationbar //buildlocalizedapplicationbar(); } public class outerrootobject { public string d { get; set; } } public class globals { public bool multisessionsallowed { get; set; } public int commcalctype { get; set; } public int pricechangedtimer { get; set; } public int validlotslocation { get; set; } public bool custumizetrademsg { get; set; } public object firstwhitelabeledoffice { get; set; } public int dealertreepriv { get; set; } pub

javascript - Making a simple timetable work using an array and nested loops? -

i have problem want make timestable output console.log, having problems array beginner. here code, been staring while @ this. sincerely. <script> // simple array store , output times’ tables var timestable = new array(12); var multiplier =6; timestable[0] = 0 * multiplier; timestable[1] = 1 * multiplier; timestable[2] = 2 * multiplier; timestable[3] = 3 * multiplier; timestable[4] = 4 * multiplier; timestable[5] = 5 * multiplier; timestable[5] = 5 * multiplier; (multiplier=0; multiplier<13; multiplier++){ console.log("0 x " + multiplier + " = " + timestable[12]) (timestable=0; timestable<12; timestable++){ }} </script> // create array var = []; var multi = 6; // fill array values (var = 0; < 12; i++) { a.push(i); } // multiply every array-element 6 , create new array var b = a.map(function (j) { return j * multi; }) // log (i = 0; < b.length; += 1) { console.log(i + ' x ' + multi + &#

php - SilverStripe : How to get all records using get() -

a simple question. in code a customer has many partners. if want customer details , customer have how many partners. trying is, $customer = customer::get(); return partners::get()->filter('customerid', $customer->id); unfortunately above code not working me, there easy way get.? @mifas you're still getting error because $customer = customer::get() still returning datalist rather single customer object, @zauberfisch described. before call relationship method need sure you're calling on individual customer. $customer = customer::get()->first(); // or, if you're looking specific customer $customer = customer::get()->filter('id', <custid>)->first(); // if you're looking id only, there shortcut still returns 1 dataobject only: $customer = customer::get()->byid( <custid> ); in case, either of following lines work (but relationship 'magic' method @zauberfisch pointed out preferred method) $partners

java - A* algorithm not looking every where -

my problem right a* algorithm in java can find path if goes top down , left right. want code able check top bottom left right before deciding move not bottom , right. can guys me? code public class pathfinder extends astar<pathfinder.node>{ private int[][] map; public static class node{ public int x; public int y; node(int x, int y){ this.x = x; this.y = y; } public string tostring(){ return "(" + x + ", " + y + ") "; } } public pathfinder(int[][] map){ this.map = map; } protected boolean isgoal(node node){ return (node.

html5 - How do I get my embedded YouTube iframes to scale? -

my website looks great... until change resolutions or browsers, , youtube videos comically out of proportion. else scales , can't them scale @ all. tried setting them percentage scale nearest container (video), refuses scale in height percentage. <aside id="video"> <iframe src="https://www.youtube.com/embed/-i3mx0yrrjm" width="320" height="190"></iframe> </aside> #video { margin: auto; width:320px; height:190px; box-shadow: 15px 15px 10px rgba(0,0,0,0.8); } <div id="container"> <aside id="video"> <iframe src="https://www.youtube.com/embed/-i3mx0yrrjm" width="320" height="190"></iframe> </aside> </div> #container { margin:auto; width:50%; } #video { margin:auto; position: relative; padding-bottom: 56.25%; padding-top: 25px; box-shadow: 15px 15px 10px rgba(0,0,0,0.8); } #video iframe { position: absolute; top: 0; left:

Database logic for conversation (like Forum) PHP, MySql -

Image
i want create page possible create topics , users able comment. i create table discussion recursive relation. don't if idea good. how can find id of parent when user comment? don't if clear... below find 3 screenshots explain better situation. i not have parentid point comment precedes it, that's bad practice around. parentid should point topic , when selecting comments database, make query orders them time or id see order posted in. for example... select * `discussion` `parentid` = 1 order `time` desc; the parentid should null topics , not null (integer) replies (the integer should point id of topic). hope understood asking correctly.

write from an html to another using JavaScript -

i have form written in html contains form. must write html page using javascript , contain information user writes in form. <!doctype html> <html> <head> <script> function validateform() { var x=document.forms["myform"]["fname"].value; if (x==null || x=="") { alert("first name must filled out"); return false; } } </script> </head> <body> <form name="myform" action="demo_form.asp" onsubmit="return validateform()" method="post"> first name: <input type="text" name="fname"> <input type="submit" value="submit"> </form> </body> have used appendchild doesn't accept name of button. if mean value form , show in popup why don't u try this.. check fiddle <html> <script> function f() { var name = document.getelementbyid("name").value; var my

excel - Change value of cell based on its on value -

i wondering how make if put 1 in cell a1 value of cell a1 change. i want make value of a1 10 if 1 inputed. sorry if confusing. thanks. enter following event macro in worksheet code area: private sub worksheet_change(byval target range) dim range set = range("a1") if intersect(a, target) nothing exit sub if target.count > 1 exit sub if target.value <> 1 exit sub application.enableevents = false a.value = 10 application.enableevents = true end sub because worksheet code, easy install , automatic use: right-click tab name near bottom of excel window select view code - brings vbe window paste stuff in , close vbe window if have concerns, first try on trial worksheet. if save workbook, macro saved it. if using version of excel later 2003, must save file .xlsm rather .xlsx to remove macro: bring vbe windows above clear code out close vbe window to learn more macros in general, see: http://www.

javascript - How to append in table in JQuery? -

can please tell me how how append contend table? want append content after first row. here fiddle: in appending in div $('#test ').html(buildnav(testdata.testcaselist)).trigger('create'); i don't want this. remove div , uncomment table. what should write in line appends after row of table? $('#test ').html(buildnav(testdata.testcaselist)).trigger('create'); try that html <table> <tr> <td>one</td> </tr> <table> appending $('table').append('<tr><td>two</td></tr>'); //and on...

python - Is there a cleaner way to use a 2 dimensional array? -

i'm trying make 2d array class, , ran problem. best way figure out pass get/setitem tuple of indices, , have unpacked in function. unfortunately though, implementation looks messy: class ddarray: data = [9,8,7,6,5,4,3,2,1,0] def __getitem__ (self, index): return (self.data [index [0]], self.data [index [1]]) def __setitem__ (self, index, value): self.data [index [0]] = value self.data [index [1]] = value test = ddarray () print (test [(1,2)]) test [(1, 2)] = 120 print (test [1, 2]) i tried having accept more parameters: class ddarray: data = [9,8,7,6,5,4,3,2,1,0] def __getitem__ (self, index1, index2): return (self.data [index1], self.data [index2]) def __setitem__ (self, index1, index2, value): self.data [index1] = value self.data [index2] = value test = ddarray () print (test [1, 2]) test [1, 2] = 120 print (test [1, 2]) but results in weird type error telling me i'm not passing en

php - Symfony/Less @icon-font-path is undefined in glyphicons.less -

i use symfony 2.4 , installed bundle mopabootstrap. less say: nameerror: variable @icon-font-path undefined in glyphicons.less on line 13, column 8. it's mopabootstrap file. i extend 'mopabootstrapbundle::base_initializr.html.twig'. have no particular code, it's new project. less work great code, except bootstrap glyphicons file. any idea ? edit: there open issue there if have ideas: https://github.com/phiamo/mopabootstrapbundle/issues/839#issuecomment-39893655 i removed 'apply_to: ".less$"' in config.yml , added less filter twig tags. assetic:dump --watch seems work fine. config.yml assetic: debug: %kernel.debug% use_controller: false filters: less: node: /usr/local/bin/node node_paths: [/usr/local/lib/node, /usr/local/lib/node_modules] apply_to: "\.less$" <<<<< remove line base.html.twig {% stylesheets '@mopabootstrapbundle/resources/public/

javascript - Jquery slideDown menu when hover -

okay i've been trying make navigation have box sliding down when hovered, , found this: keep jquery slidedown menu open when hovering on menu? the third answer worked me, problem is, when hover main menu, submenu slide down, , when hover submenu, nothing happen. i'm not sure if possible, i'd make navigation slide down 1 hover on. this code far. suck @ this, don't know jquery, if me, please do. thank much! jquery $(document).ready(function () { var menu = $('.menu') menu.hide(); $('#mainbutton').mouseover( function () { menu.stop(true, true).slidedown(400); } ); $(".menu").mouseleave( function () { menu.stop(true, true).slideup(400) }) }); css #navigation { border: solid 1px black; height: 300px; } .mainbutton { margin-top: 10px; -webkit-order: 2; margin-right: 0%; background-color: #f1f1f1; } .dropdown {

c# - How to get file folder names in windows phone 8? -

i have folders , inside folders there files.i want names of folder(by iterating) , want iterate through them read files.how can achieve in windows phone? this give installed folder on wp8, storagefolder installationfolder = windows.applicationmodel.package.current.installedlocation; to access files can read more here accessing files in wp8

Reading multiple lines from an external text file in Python -

this program works fine when use code for character in infile.readline(): problem readline reads 1 line of text. when add "s" readline command for character in infile.readlines(): i end getting 0's output. os.chdir(r'm:\project\count') def main(): infile = open("module3.txt","r") uppercasecount = 0 lowercasecount = 0 digitcount = 0 spacecount = 0 character in infile.readlines(): if character.isupper() == true: uppercasecount += 1 if character.islower() == true: lowercasecount += 1 if character.isdigit() == true: digitcount += 1 if character.isspace() == true: spacecount += 1 print ("total count %d upper case, %d lower case, %d digit(s) , %d spaces." %(uppercasecount, lowercasecount, digitcount, spacecount)) main() also if give me advice, can take directory , make default location can take , use on else'

How to Calculate Center pixels(x,y) of each small square drwan within a rectangle in HTML5 canvas -

i have written code create rectangle , providing values generate rows , columns in rectangle,basically creating small squares within rectangle. code can seen here http://jsfiddle.net/simerpreet/ndge5/1/ <h1>example</h1> <canvas id="t_canvas" style="border:1px solid #000000;" width="300" height="225"></canvas> <br/> <button id="draw">draw</button> <script> var x=50; var y=50; var w = 150; //width var h = 100; //height var columns=3; var rows =3; var vnp =w/columns; //vertical next point var hnp=h/rows; //horizontal next point var canvas = document.getelementbyid("t_canvas"); var ctx = canvas.getcontext("2d"); $(document).ready(function() { $('#draw').click(function() { drawverticallines(parsefloat(vnp)); drawhorizontallines(parsefloat(hnp)); ctx.fillstyle = "#ff0000"; ctx.st

php - $_GET shows also another page -

i've discoverd bug script. try explain it. i've made 2 pages category.php this 1 here below shows content related category: /category.php?nameid=test when go first content related category example: /category.php?nameid=test&id=2 receive information mysql post id 2, posts related category named 'test' below. don't want get. post id <?php // begin of showing content page if (isset($_get['id'])){ $naamid = mysql_real_escape_string($_get['nameid']); $id = mysql_real_escape_string($_get['id']); $idnext = $id + 1; $gn = (" select * category name='".$naamid."'") or die(mysql_error()); $go = (" select * post id='".$id."'") or die(mysql_error()); $gnn = mysql_query($gn) or die(mysql_error()); $goo = mysql_query($go) or die(mysql_er

Char matrix in C++? -

i have been trying hard c++ exercise no avail.. how create char matrix holding 4 words, each letter of word on char space? attempt. want use null know string ends. , due instructions of excercise have use char matrix. can see tried different aproaches vector[0] , rest. neither of them works. int largo = 3; char ** vector = new char* [largo+1]; (int = 0; < largo; i++){ vector[i] = new char[10]; } vector[0] = "f","u","t","b","o","l"; vector[1] = "automata"; vector[2] = "fut"; vector[3] = "auto"; vector[largo+1] = null; i have been trying hard c++ exercise no avail.. how create char matrix holding 4 words, each letter of word on char space? no problem. can use std::vector , std::string task. in fact std::string can c-string (null terminated since them) data() . std::vector<std::string> vector { "futbol", "automata", "fut&quo

Algorithm suggestion -

i'm looking best way accomplish following tasks: given 4 non-repeatable numbers between 1 , 9. given 2 numbers between 1 , 6. adding 2 numbers (1 6), check see if there way make same number using 4 non-repeatable numbers (1 9), plus may not have use 4 numbers. example: 4 non-repeatable (1 9) numbers are: 2, 4, 6, , 7 2 numbers between 1 , 6 are: 3 , 3 the total 2 numbers 3 + 3 = 6. looking @ 4 non-repeatable (1 9) numbers, can make 6 in 2 different ways: 2 + 4 = 6 6 = 6 so, example returns "yes, there possible solution". how accomplish task in efficient, cleanest way possible, algorithmic-ally. enter code heresince number of elements here 4 should not worry efficiency. loop on 0 15 , use bit mask check valid results can generated. here code in python give idea. a = [2,4,6,7] in range(16): x = ans = 0 j in range(4): if(x%2): ans += a[j] x /= 2 print ans, 0 2 4 6 6 8 10 12 7 9 11 13 13

python 2.7 - ImportError: No module named cosmolopy.distance and using pip error: unable to find vcvarsall.bat -

i need cosmolopy finish running program shows error ( importerror: no module named cosmolopy.distance). tried installing cosmolopy using pip , error comes up. how solve this? using python version 2.7.3. creating build\lib.win32-2.7\cosmolopy\eh copying cosmolopy\eh\power.py -> build\lib.win32-2.7\cosmolopy\eh copying cosmolopy\eh_init_.py -> build\lib.win32-2.7\cosmolopy\eh running build_ext building 'cosmolopy.eh._power' extension error: unable find vcvarsall.bat

c# - App.xaml.cs UnhandledException when Binding Image URL in Image Source -

Image
i have xaml (...) <listbox height="auto" margin="0,0,-20,0" x:name="post_images_grid_list" verticalalignment="top" horizontalcontentalignment="stretch" scrollviewer.verticalscrollbarvisibility="disabled" scrollviewer.horizontalscrollbarvisibility="disabled"> <listbox.itemspanel> <itemspaneltemplate> <toolkit:wrappanel /> </itemspaneltemplate> </listbox.itemspanel> <listbox.itemtemplate> <datatemplate> <grid width="auto" height="auto" background="#ff#247722" margin="0,0,10,20"> <grid.columndefinitions>

matlab - How to make face image scramble? -

i want scramble face image. don't know command in matlab programming make face scramble. please indicate me? and want scramble shuffling pixels. you combine randperm , reshape , this: img = reshape(img(randperm(numel(img))), size(img)); alternative solution: "scramble pixel blocks" you this: img = imread('http://www.ricbit.com/uploaded_images/lena-713374.jpg'); blocksize = 64; nrows = size(img, 1) / blocksize; ncols = size(img, 2) / blocksize; scramble = mat2cell(img, ones(1, nrows) * blocksize, ones(1, ncols) * blocksize, size(img, 3)); scramble = cell2mat(reshape(scramble(randperm(nrows * ncols)), nrows, ncols)); subplot(1,2,1), imshow(img); title('source image'); subplot(1,2,2), imshow(scramble); title('scrambled image'); where blocksize width , height of block, in pixels (ex.: 64 x 64) note: blocksize must common factor of original image width , height values.

sql - PostgreSQL text range scan -

i have written query aim 10 results including current one, padding 9 entries on either side alphabetical list can sorted reciever. query using, issue not result, but because neither of queries using index . ( select uid, title books lower(title) < lower('frankenstein') order title desc limit 9 ) union ( select uid, title books lower(title) >= lower('frankenstein') order title limit 10 ) order title; the index trying utilize simple btree, no text_pattern_ops etc below: create index books_title_idx on books using btree (lower(title)); if run explain on first part of unioin, in spite of limit , order, performs full table scan explain analyze select uid, title books lower(title) < lower('frankenstein') order title desc limit 9 limit (cost=69.04..69.06 rows=9 width=152) (actual time=6.276..6.292 rows=9 loops=1) -> sort (cost=69.04..69.67 rows=251 width=152) (actual time=6.273..6.2