Posts

Showing posts from July, 2014

Hadoop WebHDFS move file Could not resolve host: sandbox.hortonworks.com -

so, learn hadoop. use hortonworks sandbox. tried move file local pc (test.txt) hadoop using webhdfs. to that, found out apache hadoop documentation says need 2 steps. first sumbit put http request, , datanode information. this do: curl -i -x put "http://127.0.0.1:50070/webhdfs/v1/user/root/learnhadoop/data/test.txt?user.name=root&op=create" this response http/1.1 307 temporary_redirect cache-control: no-cache expires: wed, 01 apr 2015 17:26:10 gmt date: wed, 01 apr 2015 17:26:10 gmt pragma: no-cache expires: wed, 01 apr 2015 17:26:10 gmt date: wed, 01 apr 2015 17:26:10 gmt pragma: no-cache set-cookie: hadoop.auth=u=root&p=root&t=simple&e=1427945170842&s=ey5zvguyx8wryvnr2nbilug14s0=; path=/; expires=thu, 02-apr-2015 03:26:10 gmt; httponly location: http://sandbox.hortonworks.com:50075/webhdfs/v1/user/root/learnhadoop/data/test.txt?op=create&user.name=root&namenoderpcaddress=sandbox.hortonworks.com:8020&overwrite=false content-type...

grep regex: search for any of a set of words -

i want search large set of files set of words in order, or without spaces or punctuation. so, example, if search hello, there, friend , should match hello there friend friend, hello there theretherefriendhello but not hello friend there there friend i can't figure out way this. possible using grep, or variation of grep? is possible using grep, or variation of grep? you can use grep -p ie in perl mode,the following regex. ^(?=.*hello)(?=.*there)(?=.*friend).*$ see demo. https://regex101.com/r/sj9gm7/37

xml - json text or perl structure exceeds maximum nesting level (max_depth set too low?) -

i getting following error json's encode_json : json text or perl structure exceeds maximum nesting level (max_depth set low?) the code in question my $jsonstring = encode_json($dataxml); $dataxml produced xml::simple's xmlin . pointers how remove error? you error json::pp when structure has 512 levels of nesting. it's meant catch unserializable reference loops ( my $data = { }; $data->{foo} = $data; ) , prevent malicious attempts use memory. if aren't problems, if issue need support ginormous structures, can increase threshold using ->max_depth . keep mind that encode_json($data) is short for my $json = json->new->utf8; $json->encode($data) so can use my $json = json->new->utf8->max_depth(...); $json->encode($data) alternatively, json::xs might not have check. if doesn't, installing json::xs avoid error. that's on top of speeding encoding , decoding.

php - Symfony doctrine ManyToMany insert -

i 'm having form on can create new "book". book, can add tags (e.g. describe additional information it). the relation between book , tag manytomany, because each book can have many tags, , each tag can rely different books. (each tag unique field on name). so, when user enters new tag book not exists in database, want create tag when submitting. if exists, want add tag book. i've tried following: $book = $this->form->getdata(); foreach ($tags $tag) { $tag = strtolower($tag); // check if tag exists $tagentity = $this->em->getrepository('bookbundle:tag')->findbyname($tag); // if not, create new tag , add if(null === $tagentity) { $tagentity = new tag(); $tagentity->setname($tag); } // add tag book $book->addtag($tagentity); // add book tag $tagentity->addbook($book); // create relation between tag , book $this->em->persist($book); $this->em->persist($tagentity); $this-...

http - Per-Proxy Authentication in Java -

i trying support authenticated proxies in java application. understanding java.net.proxy class not support authentication, , need handle authentication yourself. i have created subclass of java.net.proxy class, takes 2 additional parameters, username , password. implementing http proxy authentication quite easy, , method gethttpproxyauthenticationheader returns base64 encoded auth info, pass httpurlconnection or similar. i'm having trouble sock proxies though. cannot find documentation on sending authentication socks server. i'm unsure if need implement socks authentication protocol in class using method such authenticatesocksproxy(outputstream stream), , call authedproxy.authenticatesocksproxy(outputstream); before using socket like outputstream.writebytes(mydata.getbytes()); another option return byte[] of authentication data , write data manually, instead of class writing authentication data. i not think java.net.authenticator, or system.setproperty metho...

jsp - Form, input, onMouseOver - onMouseOut and browsers -

Image
i've form (post) input (a line), in jsp file: <input type="submit" value="executar" name="1" id="execute" style="visibility:hidden" onmouseover="window.status='url: http://jlex1x2-uocpfc.rhcloud.com'" onmouseout="window.status=''"> it works with: ie 6 , mozilla firefox 36.0.4: see onmouseover. it doesn't work with: mozilla firefox 9.01 , chrome 41.0: nothing appears. ie 9: appears '*.rhcloud.com/directory/filename.jsp#' edit 2 apr: my form (simplifyed) (without textarea): : <form action="#" method="post"> ... // initial code </form> i improve input (for browsers) '*.rhcloud.com'. working fine me..just remove style="visibility" . here code , output screenshot : <input type="submit" value="executar" name="1" id="execute" onmouseover="win...

ibm mq - Minimum version of IBM websphere MQ supporting XA transactions -

i want use xa complaint ibm websphere mq. minimum version of websphere mq supporting feature of distributed transaction?. additionally using ibm mq classes jms it's not clear if asking xa mq client or queue manager can act xa resource manager. in either case, mq version older v7 no longer supported ibm @ minimum should using mq v7.0.1, preferably 1 more recent because version has end of support september year. all versions of mq can act xa transaction coordinator or use services of external xa transaction coordinator. details of implementations of xa compatible mq, please see detailed system requirements page version of mq , drill down. as of 24 april 2012, versions of ibm mq client licensed xa transactionality , include functionality built in. however, necessary download , use client software posted ibm after date qualify because process includes agreeing new license terms. also, transactional client installation pre-dates new release show on license audit...

Problems with creating large MultiIndex (10 million rows) in Python Pandas used to reindex large DataFrame -

my situation have dataframe multiindex including timestamp , number (wavelength 280-4000 nm) wavelength number spacing changes every 1 nm 5 nm. need 1 nm spacing , plan , plan linearly interpolate after reindexing dataframe. i tried create multiindex using pd.multiindex.from_product() , providing 2 lists of 4000 items in length each resulted in python using computer's ram. code looks like: mindex = pd.multiindex.from_product([times_list, waves_list], names=['tmstamp', 'wvlgth'] ) from_product() simple function don't think i'm messing think able handle larger lists i've passed it. to try around i've used pd.multiindex() , passed unique levels, indentical passed .from_product() constructed labels each using code below: times = series(df.index.get_level_values('tmstamp').values).unique() times_series = series(times) times_label_list = list() counter = 0 in times_serie...

angularjs - How to target ng-show on specific items in ng-repeat? -

Image
http://plnkr.co/edit/aigcpjewtj0rwnuocjsw?p=preview i want remove button show popover that item . how go this? html: <li ng-repeat="acc in accounts"> <div class="well well-sm"> <div class="popover-remove" ng-show="popoverremove">click remove item</div> <h4>{{acc.label}}</h4> <button class="btn btn-default" ng-mouseover="showpopover()" ng-mouseleave="hidepopover()">remove</button> </div> </li> angular controller: var app = angular.module('myapp', []) .controller('accountsctrl', ['$scope', function($scope) { var vs = $scope; vs.accounts = [ { id: '1', label: 'bitage' }, { id: '2', label: 'blockchain.info...

javascript - How to get percent from an binary int, with every bit representing x percent? -

i have binary bitmap 10bits. every bit represents 10%. there simple math function sum of percent bitmap? sample 0000000000 = 0% 0000000001 = 10% 1000000000 = 10% 0000100000 = 10% 1000000001 = 20% 0000000011 = 20% 0000110000 = 20% 0010000010 = 20% 1010000010 = 30% be aware example of how bits activated. number have int such 0,1 1023. you don't have use loop. don't have math. this: var number = 1000100010; alert(number.tostring().split("1").length - 1); //a little more deep: var number2 = 1100100000; alert((number2.tostring().split("1").length - 1) * 10 + "%");

r - dplyr::tbl_df fill whole screen -

Image
dplyr::as.tbl(mtcars) fills 10 rows of screen, in screenshot below: can r configured if tbl_df can fill whole r window without data 'falling off window' (as in case of mtcars ), dplyr force tbl_df fill whole window. so want output of dplyr::as.tbl(mtcars) be: several ways accomplish this: # show 1000 rows , columns *capital v in view* df %>% view() # set option see columns , fewer rows options(dplyr.width = inf, dplyr.print_min = 6) # reset options defaults (or close r) options(dplyr.width = null, dplyr.print_min = 10) # measure, don't forget glimpse()... df %>% glimpse()

c++ - How does a server obtain the ek and iv arguments from the client, in order to RSA decrypt a message? -

i'm trying use evp utilities in openssl rsa encryption. goal implement seal & open method encrypt using public key , decrypt using private key. assuming ssl handshake successful , client has public key of server, want client seal message before sending it. something this: int crypto::rsaencrypt(const unsigned char *msg, size_t msglen, unsigned char **encmsg, unsigned char **ek, size_t *ekl, unsigned char **iv, size_t *ivl) { ... if(!evp_sealinit(rsaencryptctx, evp_aes_256_cbc(), ek, (int*)ekl, *iv, &remotepubkey, 1)) { return failure; } if(!evp_sealupdate(rsaencryptctx, *encmsg + encmsglen, (int*)&blocklen, (const unsigned char*)msg, (int)msglen)) { return failure; } encmsglen += blocklen; if(!evp_sealfinal(rsaencryptctx, *encmsg + encmsglen, (int*)&blocklen)) { return failure; } ... } if understanding correct, evp_sealinit() generate public key encrypted secret key pointed ek , iv correspondi...

javascript - Email Script from server breaks Telerik RadGrid and RadDropDownList -

i using rad grid display information grid checkboxes mark items , using raddropdownlist can pick action , press button it. 1 of items send email emails of checked rows. in button click call enumerate checked rows grid , put emails in string buffer , add script execute email on postback bring email. clientscript.registerstartupscript(this.gettype(), "mailto", "<script type = 'text/javascript'>parent.location='mailto:" + emailtobuffer.tostring() + "'</script>") ; this results in line <script type = 'text/javascript'>parent.location='mailto:dana@here.com; '</script> put in front of telerik rad javascript code in html. somehow innocent little line of javascript causes master checkbox on radgrid header line , raddropdownlist stop functioning completely. dropdown list not drop. value parent.location no else in view source html except inserted email line. i cannot figur...

java - Union By Size Infinite Loop -

i working on implementing union-find data structure scratch , encountering problem infinite loop results in find method if attempting repeat union call. i implementing union size , find using path compression . have created test implementation of 10 elements (0 n-1) example: u 3 1 //union 1 -> 3 u 0 2 //union 2 -> 0 u 0 2 //union 2 -> 0 , infinite loop results u 1 4 //union 4 -> 1 , results in infinite loop when doing second u 0 2 , loop gets caught because value @ index 2 zero, , root zero, repeating loop cyclically. same logic follows when attempt u 1 4 . 2nd loop in find has incorrect logic. my question is : how can handle theses cases don't caught in infinite loop? this find method: /* * search element 'num' , returns key in root of tree * containing 'num'. implements path compression on each find. */ public int find (int num) { totalpathlength++; int k = num; int root = 0; // find root while (sets[k] >...

java - Retrofit: Error deserializing array with one element: "out of START_ARRAY token" -

i writing android app utilizing robospice, retrofit, , jackson 2.4.x, here json trying deserialize coming rest service. elements in "data" array returned notification object want deserialize. { "data": [ { "uuid": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx", "acctno": "xxxxxxxxxx", "title": "test notification", "content": "here content.", "date": "2015-03-24" } ] } i first wrapping response in notificationresponse object: @jsonrootname(value = "data") @jsonignoreproperties(ignoreunknown = true) public class notificationresponse { @jsonunwrapped public notification[] notifications; } notification object looks this: public class notification { @jsonproperty("uuid") public string uuid; @jsonproperty("acctno") public string acctno; @...

php - Get position of text in mPDF to determine vertical height of HTML element -

i generating pdfs mpdf class , wondering if , how possible determine position of last line of text in document generated mpdf? i need html box cover in height remaining space between last line of text , bottom margin of document. setting html element height: 100% pushes element new page , covering whole height of new page. the content of page generated dynamically based on number of factors, can never sure @ vertical position last line at. if knew vertical position of last line, subtract value total page height , set css element have height. is possible or there other solutions? you can use purpose "$mpdf->y" (current position in user unit cell positioning): $mpdf=new mpdf('', 'a4'); $mpdf->writehtml('line1<pagebreak>line2<br>line3'); // $unusedspaceh = $mpdf->h - $mpdf->y - $mpdf->bmargin; $unusedspacew = $mpdf->w - $mpdf->lmargin - $mpdf->rmargin; // $mpdf->rect($mpdf->x, $mpdf->y, ...

sql server - Convert varchar dd-mmm-yyyy to dd/mm/yyyy then order by not working? -

i have situation i need convert varchar value dd-mmm-yyyy dd/mm/yyyy order above converted date using convert(varchar(10), cast([date] datetime), 103) modifieddate i got required format but, when order modifieddate order result set showing 2013, 2014, 2015 years mixed match. think doing order date. doing wrong? can help? since modifieddate varchar, ordering lexical ( 01/01/1900 < 01/01/1901 < 02/01/1900 ). the solution not use varchar sorting. convert varchar-date real date (i.e., cast([date] datetime) without outer convert ) , sort expression.

c++ - How to manage 100 different main files? -

short version of question: is there way set visual studio solution build 100 different main files contained in single code base, , in single visual studio project? long version of question: i work legacy corporate signal processing library. the functions in clean, written, highly optimized, , in ansi c. (yes, know of attributes contradictory) have vs project build library, , publish other projects/groups in company using our corporate code publishing system. each "big" library entry point has it's own source file. each of these "big" entry points has thin main wrapper function defined in file, #ifdef foomain /* main function foo */ main() { } #endif i have learned these "little" apps used many people around company. so, include these apps in our publishing process. (at present published via manual door means.) using vs solutions, , curious if can there?

ColdFusion: ORM Collection with Multiple Foreign Keys -

my database structure consists of multiple primary keys per table, therefore multiple columns required per join. i'm trying use coldfusion (11 specific) orm collection property . seems comma separated list of columns in fkcolumn attribute doesn't work, relationship properties . have filed bug adobe , i'm wondering if else has run , found workarounds. or maybe i'm doing wrong.. table setup years staff staffsites sites =========== ============ ============ =========== yearid (pk) staffid (pk) yearid (pk) siteid (pk) yearname staffname staffid (pk) sitename siteid (pk) staff orm cfc component persistent=true table='staff' { property name='id' column='staffid' fieldtype='id'; property name='year' column='yearid' fieldtype='id'; property name='sites' elementcolumn='siteid' fieldtype='collection'...

how to improve simple prolog login? -

i building first project in swi-prolog.it expert system guess user identification base on input of user. of code produces dialog allows user enter information, verifies information , allows user have access. there way improve code? % user facts enable user log in user(dac,dac11). user(dac101,daa). % login gui. checks database log in logingui :- new(dialog,dialog('login')), send_list(dialog, append, [ new( username, text_item(username)), new(password, text_item(password)), button(enter, and(message(@prolog, checkuser, username?selection, password?selection), message(dialog, destroy) ))]), send(dialog, default_button, enter), send(dialog, open). % verfies user logging checkuser(username,passwo...

javascript - angularJS error: Error: n.replace is not a function -

i using third-party js file interact external api, tokenizes data before sending. in simple test page, function works fine , returns token. however, when try implement actual app uses angularjs, keeps failing error: "error: n.replace not function". here simple test script works: // click event handler $('#form-submit').click(function (e) { e.preventdefault(); $('#response').hide(); var payload = { api_id: 'abcde123', var1: $('#var1').val(), var2: $('#var2').val(), var3: $('#var3').val(), var4: $('#var4').val() }; // tokenize data vendorscript.createtoken(payload) .success(ontokencreated) .error(ontokenfailed); }); and here angular code throws error: app = angular.module 'myapp' myctrl = ($scope, $http, $window, $q) -> myformparams = -> api_id: 'abcde123' var1: $scope.var1 var2: $scope.v...

c# - NamedPipeClientStream AccessViolation -

Image
i came across issue today constructor of namedpipeclientstream threw av. after boiling down try , minimal repeatable example found... create new project in vs2013 update 4 (console do) targeting .net 3.5 change main this.... static void main(string[] args) { var pipe = new namedpipeclientstream(".", "global\\turnips", pipedirection.inout, pipeoptions.asynchronous); } run. anyone have idea what's going on here? i've looked through code in ctor of named pipe using ilspy , can't see reason behaviour.

localhost - No route found using Aura Router for PHP -

the app uses aura router routing. accesing index.php of web app returns "route not found" error message. here's (seemingly) relevant code: $path = parse_url($_server['request_uri'], php_url_path); $route = $router->match($path, $_server); if (empty($route)) { header("http/1.0 404 not found"); echo 'route not found'; exit; } i'm running locally, using wampserver. path have app localhost/websites what missing? the manual may out here: https://github.com/auraphp/aura.router#handling-failure-to-match (i'm lead on aura.)

python - How to switch tasks between queues in Celery -

i've got couple of tasks in tasks.py in celery. # should go 'math' queue @app.task def add(x,y): uuid = uuid.uuid4() result = x + y return {'id': uuid, 'result': result} # should go 'info' queue @app.task def notification(calculation): print repr(calculation) what i'd place each of these tasks in separate celery queue , assign number of workers on each queue. the problem don't know of way place task 1 queue within code. so instance when add task finishes execution need way place resulting python dictionary info queue futher processing. how should that? thanks in advance. edit -clarification- as said in comments question becomes how can worker place data retrieved queue a queue b . you can try this. wherever calling task,you can assign task queue. add.apply_async(queue="queuename1") notification.apply_async(queue="queuename2") by way can put tasks in seperate queue. ...

python - Finding how many of a certain character in each element in a list -

i want find how many ' ' (whitespaces) there in each of these sentences happen elements in list. so, for: ['this sentence', 'this 1 more sentence'] calling element 0 return value of 3, , calling element 1 return value of 4. having trouble doing both of finding whitespaces looping through every element find 1 highest number of whitespaces. have simple list-coprehension using count >>> lst = ['this sentence', 'this 1 more sentence'] >>> [i.count(' ') in lst] [3, 4] other ways include using map >>> map(lambda x:x.count(' '),lst) [3, 4] if want callable (which function iterates through list have mentioned) can implemented >>> def countspace(x): ... return x.count(' ') ... and executed as >>> in lst: ... print countspace(i) ... 3 4 this can solved using regexes using re module mentioned below grijesh >>> import re >>...

git - Managing Github PR across different organizations -

i member of different organizations within our corporate github. each , every organizations have more 10 repos , each 1 have pr. find difficult keep pr across repos , organizations.. there anyway can manage pr more easily. note: not sure if right place ask question. you can bookmark search content want, show results across repos. example, here's a search open issues assigned you . (prs issues, not issues prs.) if need build more advanced queries, see github issues api .

Java Swing UI elements not updating all the time -

i trying make simple gui few tools have cli interface. figured having 1 window multiple tabs best way go this. problem running of ui elements not being updated when filling in information/making selections. in particular combo boxes have been biggest pain. it displays options , can select different options, after selecting gui not update combo box show new selection. example starts off "1" selected change "3", event trigger sees "3" has been selected combo box still shows "1". i have tried adding in repaints , validates frames tabs , combo box no luck of forcing update. appreciated. as note happens text fields have display file paths after selecting file/folder file chooser, not anywhere near often package com.test.javaswing; import java.awt.borderlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.util.arraylist; import java.util.list; import javax.swing.jcombobox...

hover - Select outer elements CSS -

can hover selector in li.options affects .image? know can done in jquery, i'm curious if it's possible pure css. <nav class="menu"> <ul class="list"> <li class="option"><a href="#">option 1</a></li> <li class="option"><a href="#">option 2</a></li> <li class="option"><a href="#">option 3</a></li> <li class="option"><a href="#">option 4</a></li> </ul> </nav> <div id="image_set"> <div class="image image1"></div> <div class="image image2"></div> <div class="image image3"></div> <div class="image image4"></div> </div> yes can css have change structure or use jquery or javascript: $(...

php - jquery - how to create condition in success function -

i want create jquery ajax success function based resp logout.php. if users not sign in,it redirect bring them login page.,but it's not working i'm expected,no event occur when user logged or not.so, wrong ajax function? logout.php <?php if( !$user->is_logged ) { echo 'true'; }else{ echo 'false'; } ?> jquery function in index.html $(function(){ $.ajax({ type: 'get', url: "logout.php", success: function(resp){ if(resp =='true'){ document.location = '../login_test.html'; } if(resp=='false'){ alert('u logged'); } } }); }); change errors , made better view: php: <?php header('content-type: application/json'); if( !$user->is_logged ) { echo json_encode(array('status' => 'ok')); }else{ echo json_encode(array('status' => ...

reporting services - ssrs parameter using lookup -

i'm trying retrive multiple values of same row of dataset. have first parameter uses dataset called "getcyclevie" there retrive row identifier of dataset. have retrive 2 other values of row use parameter in dataset, dtdebut , dtfin works in textbox =lookup( trim(parameters!cyclevie.value) ,trim(fields!cyclevie.value) ,fields!dtdebut.value ,"getcyclevie" ) however when add default value of parameter or if add paramter in dataset following error une expression de la propriété value utilisée pour le paramètre de rapport de l'objet 'dtdebut' fait référence à un champ. les champs ne peuvent pas être utilisés dans les expressions de paramètre de rapport. translates an expression of property value used report parameter object 'dtdebut' referencing field. field cannot used in parameter expressions of report i don't need lookup, need retreive multiple values of same row of dataset. i don't think lookup p...

asp.net xmlhttprequest...Ajax Content -

i'm using asp.net c# xmlhttprequest read external web page content. when i'm getting page content see part of text (content) , not whole content. did search , find out of page content loading ajax (after page loading) , thats why cant it. i'm using httpwebrequest my question is: how can whole page content

javascript - alert showing once instead of several times ScriptManager asp.NET -

i experience issue using alert('mytext'); through scriptmanager.registerstartupscript() . the problem is, when use in loop, example, writting : for(int = 0; < 3; i++) { scriptmanager.registerstartupscript(page, page.gettype(), "alert", "alert('hello world');", true); } the alert displayed once, instead of 3 times. to precise, function takes 5 parameters, : control control : control of page type typeofcontrol : type of control string key : key used identify js script string script : js script itself boolean addscripttags : put script <script></script> or not the essence of problem can't specify key . tryied use milliseconds identify each script seems script faster , have same amount of millisecond (and cannot more precised time...). question : how use possible unique idenifier key parameters ? or there alternative ?

Run TestCase from java and display results on Eclipse JUnit view -

i defined classes with, each one, several public methods @test annotation. methods follow same behavioral pattern (retrieve ressources ids, test if empty, log, call real test each line on resource). so, i've externalized behavior in abstract class instanciate on each method, this: @test public void sometest(){ new basictestpattern("x","y","z"){ // parameters retrieve resources @override protected void testline(){ somecheck1(); somecheck2(); } }.run(); } this solution eliminate 10-30 lines per test method. now, want go further custom annotation, that: @testpattern(param1="x",param2="y",param3="z") public void sometest(){ somecheck1(); somecheck2(); } finally created little framework retrieve methods new annotation in order instanciate basictestpattern , execute it. executed in testcase subclass, that: testcase junit_test = new testcase(){ @override public void runtes...

ios - Scale scatter plot to Y-axis based on Circle radius using core plot -

Image
i have scatter-plot plot circles. draws fine , scale depending on aspect ratio users device. circles can vary in size incredibly, want scale plotspace accordingly. problem when use [graph.defaultplotspace scaletofitplots:graph.allplots]; the scaling done respect y-axis. perfect circles, since work aspect ratio, since portrait orientation, , scaling done respect y-axis, circles cut off in x-axis. since x-axis shorter in regard of aspect ratio i'd scale respect instead. possible? what i'm trying achieve "zoom out" or "scale" plotspace circles fit in plotspace, can't seem figure out without breaking aspect ratio , getting stretches circles. it looks this: and want this: edit: code use scale: [self.mgraph layoutifneeded]; [self.mgraph.defaultplotspace scaletofitplots:self.mgraph.allplots]; float width = self.mgraph.plotareaframe.bounds.size.width; float height = self.mgraph.plotareaframe.bounds.size.height; float aspectratio = width / h...

Java: memory efficient storing of arrays of integers -

premise : problem might known, , might using wrong wording, please refer me elsewhere if case. quick problem overview : have store high number of arrays of integers in order avoid duplication. doing following: linkedlist<int[]> arraysalreadyused; upon using array, add list. before using array see if in list. since need use many high dimensional arrays run memory issues. question : good/the best way of doing in order minimize amount of memory occupied? there way represent such arrays hash string? , better? it may make sense create wrapper implements equals , hashcode can place arrays in set o(1) contains / add . like: public class intarray { private final int[] array; private final int hash; public intarray(int[] array) { this.array = array; this.hash = arrays.hashcode(this.array); //cache hashcode better performance } @override public int hashcode() { return hash; } @override public boolean equals(object obj) { if (ob...

F#: Breaking out of a loop -

i new programming , f# first language. i have list of urls that, when first accessed, either returned http error 404 or experienced gateway timeout. these urls, try accessing them 3 times. @ end of these 3 attempts, if webexception error still thrown, assume url doesn't exist, , add text file containing of invalid urls. here code: let tryaccessingagain (url: string) (numattempts: int) = async { attempt = 1 numattempts try let! html = fetchhtmlasync url let name = getnamefrompage html let id = getidfromurl url let newtextfile = file.create(htmldirectory + "\\" + id.tostring("00000") + " " + name.trimend([|' '|]) + ".html") use file = new streamwriter(newtextfile) file.write(html) file.close() :? system.net.webexception -> file.appendalltext("g:\user\in...

ruby - Alias to sudo gem --proxy <PROXY> or bash function? -

i have script run when behind proxy called proxy.sh auto-sets various proxy settings such as: http_proxy=<proxy> https_proxy=<proxy> once run script love if auto-intercept ruby gem command , add proxy information well: sudo gem install ..... => sudo gem install --http-proxy=<proxy> .... at first wanted write alias understand need make function? correct? how handle this? if run proxy.sh typing: sudo gem install test automatically run sudo gem install --http-proxy=<proxy> test you make alias. in ~/.bash_aliases : alias sudo="sudo " alias gemproxy="gem install --http-proxy=<proxy>" the sudo alias (with space) important if want use alias gemproxy sudo . edit : intercept gem install , can add in .bash_aliases : gem() { if [[ $@ == install* ]]; arg=${@#"install "} command gem install --http-proxy=proxy $arg fi } but this, export proxy if you're not beh...

xcode - WatchKit Upload -

Image
i trying submit watchkit app t itunesconnect. click "archive" , validate , shown message below. have created app id app, extension , watchkit app distribution profiles. going wrong? thanks to sign watch app, need 3 different app ids , each app id needs provision profile. go developer member center add/edit 3 app ids: one main app bundle, may need add entitlements need, app groups , keychain access group . one watchkit extension bundle, may need add entitlements need. one watchkit app bundle. no entitlements needed. delete distribution provision profiles 3 app ids, if exists. add 3 new distribution provision profiles 3 app ids. now go xcode, open preference , go accounts . choose apple id, click view details on bottom right. click refresh button on bottom left, wait list of provision profiles change. in build settings targets, configure code signing part below. try archive again. when submit app, xcode ask confirm provision profile ...

ios - Can not play audio in didReceiveData method of Multipeer Connectivity -

my aim stream voice data multiple devices using multipeer connnectivity. i using avcapturesession access voice data microphone using avcapturedevice type avmediatypeaudio. in custom avcaptureaudiodataoutput class getting audio data , want stream connected peers. //sending data using multipeer connectivity - (void)captureoutput:(avcaptureoutput *)captureoutput didoutputsamplebuffer:(cmsamplebufferref)samplebuffer fromconnection:(avcaptureconnection *)connection { // nslog(@"---a u d o :%@",samplebuffer); audiobufferlist audiobufferlist; nsmutabledata *data= [nsmutabledata data]; cmblockbufferref blockbuffer; cmsamplebuffergetaudiobufferlistwithretainedblockbuffer(samplebuffer, null, &audiobufferlist, sizeof(audiobufferlist), null, null, 0, &blockbuffer); for( int y=0; y< audiobufferlist.mnumberbuffers; y++ ){ audiobuffer audiobuffer = audiobufferlist.mbuffers[y]; float32 *frame = (float32*)audiobuffer.mdata; ...

.net - XML parsing using C# for sibling element with namespace -

i've complex xml , parse in c# using linq: <?xml version="1.0"?> <?mso-application progid="word.document"?> <w:worddocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxhint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:c2f41010-65b3-11d1-a29f-00aa00c14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xml:space="preserve" w:embeddedobjpresent="no"> <w:docpr xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"> <w:displaybackgroundshape/> <w:view w:val="print"/> <w:zoom w:percent=""/> <w:defau...

c# - Is there a more efficient way to define similar public properties -

i've got class 20 public properties. these properties have in common strings , filled data different tables of database. additionally set pretty normal while special need call specific method. done each property @ moment (see below). my question here is: there more efficient way of doing this, way don't have define each public property hand in way? class myclass { private string _firstname; private string _lastname; ..... public string firstname { { return modifystringmethod(this._firstname); } set { this._firstname = value; } } } like mentioned above every public property looks same. calls modifystringmethod private member given parameter while set sets private member. you try automatic code generation using t4 template . perfect when have simple, repeating pattern of code , not expecting cases different others. simply define xml list of property names , have t4 ...

scala - How to transpose an RDD in Spark -

i have rdd this: 1 2 3 4 5 6 7 8 9 it matrix. want transpose rdd this: 1 4 7 2 5 8 3 6 9 how can this? say have n×m matrix. if both n , m small can hold n×m items in memory, doesn't make sense use rdd. transposing easy: val rdd = sc.parallelize(seq(seq(1, 2, 3), seq(4, 5, 6), seq(7, 8, 9))) val transposed = sc.parallelize(rdd.collect.toseq.transpose) if n or m large cannot hold n or m entries in memory, cannot have rdd line of size. either original or transposed matrix impossible represent in case. n , m may of medium size: can hold n or m entries in memory, cannot hold n×m entries. in case have blow matrix , put again: val rdd = sc.parallelize(seq(seq(1, 2, 3), seq(4, 5, 6), seq(7, 8, 9))) // split matrix 1 number per line. val bycolumnandrow = rdd.zipwithindex.flatmap { case (row, rowindex) => row.zipwithindex.map { case (number, columnindex) => columnindex -> (rowindex, number) } } // build transposed matrix. group , s...

nhibernate - 'Bulk insert' for cascaded list -

i have object cascaded list mapped in following way: hasmany(x => x.products).cascade.alldeleteorphan(); //.batchsize(10000); after adding 20000 products list, commit takes more 30 seconds (while should max 3 seconds). what need kind of bulk insert. follow approach: speed bulk insert operations nhibernate . know solution uses statelesssession anyway, hope configure these things in mapping, adding objects directly list in entity , nhibernate takes care of remaining stuff. setting batchsize on mapping of list seems has no effect. is there way accomplish task in acceptable time? i think batch size in mapping related fetching. can try using configuration in nhibernate config: <property name="adonet.batch_size">250</property>

cron - Can i set cronjob for controller action in magento? -

i created module , has config.xml , controller. in need setup cron job action in controller named testaction().anyone pls me fix issue. set observer method redirect observer method $response1 = $observer->getresponse(); $url = 'http://www.website.com/'; $response1->setredirect($url); or can check $observer->getrequest()->setparam('return_url','http://www.google.com/');

javascript - cylon.js and gsm-shield in arduino -

is there way connect , send sms arduino uno (with gsm shield) using cylon.js. have use node gsm.ino library , if how ? (just way use cylon.js control devices(led, motor,etc) connected arduino) thank you is there way connect , send sms arduino uno (with gsm shield) using cylon.js. no. do have use node gsm.ino library , if how ? cylon.js requires standardfirmata.ino on arduino family boards. if want send text messages node.js programs, recommend using twilio http://twilio.github.io/twilio-node/

c# - AJAX request for a loaded partial view -MVC -

the concept behind question whenever value shown in id textbox, value id pulls information corresponding id in partial view right of page via ajax , javascript. i have partial view showing on right there error alert chrome cant populate partial view, shows empty partial view (textbox etc). i've tried researching problem cant find relating html.partial() instead has tutorials on views in page don't want. ideas on going wrong? below code regarding issue. im still getting grips ajax apologies silly mistakes. jobscanner.cshtml <div id="qr"> <div id="first"> <p>hold qr code in front of webcam.</p> <video id="camsource" autoplay="" width="320" height="240">webcam has failed, please try another</video> <canvas id="qr-canvas" width="320" height="240" style="display:none"></canvas> @* <div class=...