Wednesday 15 April 2015

Resize an image along rows only or columns only in matlab -



Resize an image along rows only or columns only in matlab -

i'm writing function in matlab zoom or shrink image using bicubic interpolation. however, function resizes image along both rows , columns. if want enlarge image along rows only, or along columns only? code far

function pic_new = zoom_image(pic, zoom_value) actualsize = size(pic); newsize = max(floor(zoom_value.*actualsize(1:2)),1); newx = ((1:newsize(2))-0.5)./zoom_value+0.5; %# new image pixel x coordinates newy = ((1:newsize(1))-0.5)./zoom_value+0.5; oldclass = class(pic); %# original image type pic = double(pic); %# convert image double precision interpolation if numel(actualsize) == 2 pic_new = interp2(pic,newx,newy(:),'cubic'); end pic_new = cast(pic_new,oldclass); end

updated: able resize image both along rows , columns. however, doesn't work right

this original image: https://imagizer.imageshack.us/v2/895x383q90/r/903/4jm76i.png

this image after beingness enlarge 2.5 along rows , shrunk 1.3 along columns: https://imagizer.imageshack.us/v2/323x465q90/r/673/ehiaob.png

why there such black box in result image?

updated 2: how did: in command window type

>> img = imread('pic.pgm'); >> newimage = zoom_image(img, 2.5, 1/1.3); >> imshow(newimage)

try editing function have separate zoom rows , columns, la

function pic_new = zoomfunc(pic, zoom_valuex, zoom_valuey) actualsize = size(pic); newsize = max(floor([zoom_valuey zoom_valuex].*actualsize(1:2)),1); newx = ((1:newsize(2))-0.5)./zoom_valuex+0.5; %# new image pixel x coordinates newy = ((1:newsize(1))-0.5)./zoom_valuey+0.5; oldclass = class(pic); %# original image type pic = double(pic); %# convert image double precision interpolation if numel(actualsize) == 2 pic_new = interp2(pic,newx,newy(:),'cubic'); end pic_new = cast(pic_new,oldclass); end

image matlab resize

xaml - Button and .resw idea Windows Phone 8.1 -



xaml - Button and .resw idea Windows Phone 8.1 -

i have button , want content loaded name .resw file. know can alter in page class or in class possible in xaml default option?

my button:

<button content="" horizontalalignment="left" margin="84,480,0,0" verticalalignment="top" width="220" height="42" foreground="#ff0e0e0e"/>

thanks in advance!

you can set x:uid attribute string in resw file.

<button x:uid="sendbutton" />

the key entry in resw file should this:

sendbutton.content

you can add together path resource file in case have multiple files

<button x:uid="/forms/sendbutton"/>

the i18n scheme introduced winrt totally flexible. suggest reading next article more details:

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh965323.aspx

xaml windows-phone-8 windows-phone-8.1

c++ - avoiding busy wait with boost::asio poll -



c++ - avoiding busy wait with boost::asio poll -

i'm writing service on linux uses boost::asio::io_service io_service::poll in while loop. busy wait loop, e.g. wastes cpu cycles.

void application::run() { seek { std::cout << "tcpserver starting..\n"; _tcpserver.reset( new tcpserver(_io_service, boost::ref(_spstate)) ); // _io_service.run(); while( ! _spstate->quitsignalled() ) { _io_service.poll(); } std::cerr << "quit signalled, tcpserver stopping.. :/" << std::endl; } catch(std::exception & e) { std::cout << e.what() << "\n"; } }

i utilize poll instead of run check if thread in service has signalled service shutdown.

is there way of achieving without using poll in busy wait loop ?

the service uses async io on single thread, , other threads info processing.

i've added sleep between iterations of loop seems cut down waste of cpu time, hoping there might more efficient way?

void application::run() { using boost::this_thread::sleep_for; static const boost::chrono::milliseconds napmsecs( 50 ); seek { std::cout << "tcpserver starting..\n"; _tcpserver.reset( new tcpserver(_io_service, boost::ref(_spstate)) ); // _io_service.run(); while( ! _spstate->quitsignalled() ) { _io_service.poll(); boost::this_thread::sleep_for( napmsecs ); } std::cerr << "quit signalled, tcpserver stopping.. :/" << std::endl; } catch(std::exception & e) { std::cout << e.what() << "\n"; } }

i'd say, take advantage of fact boost::asio::io_service threadsafe default, , do

iosvc.run();

and signal service shutdown on "another thread in service" would:

iosvc.stop();

remember iosvc.reset() before phone call {run,poll}[_one] again, per documentation.

of course of study can utilize other means signal actual logical workers end, that's independent unrelated boost asio

c++ boost-asio busy-waiting

javascript - Angular app throws error -



javascript - Angular app throws error -

my code this

<div ng-app='myapp' ng-controller="mainctrl"> <div ng-repeat="prdelement in pacakageelement track $index" class="package-grid"> <div style="border: 1px solid; padding-bottom: 10px; padding-top: 10px"> <input placeholder="product code" /> <input placeholder="dimension" /> </div> <table class="hovertable"> <thead> <tr> <th>line #</th> <th>itcls</th> <th>item #</th> <th>line quantity#</th> <th>ship quantity</th> <th>pickquantity</th> <th>quantity in plt</th> <th>allready packed</th> </tr> </thead> <tbody> <tr ng-repeat="data in prdelement.data" ng-init="data.newquantity = data.quantity"> <td>{{data.itemid}}</td> <td>{{data.itcls}}</td> <td>{{data.itemid}}</td> <td>line quantity#</td> <td>ship quantity</td> <td>pickquantity</td> <td> <input type="text" ng-model="data.newquantity" placeholder="quantity" required=required /> </td> <td>allready packed</td> </tr> <tr> <td width="100%" colspan="4"> <button ng-show="prdelement.show" ng-click="newpackageitem( prdelement,$event)">next pallet</button> </td> <td width="100%" colspan="4"> <button ng-show="prdelement.show">remove pallet</button> </td> </tr> </tbody> </table> </div> (function () { angular.module('myapp', []).controller('mainctrl', function ($scope) { var counter = 0; $scope.pacakageelement = [{ name: counter, show: true, data: [{ name: 'item 1', itemid: '284307', itemcode: '', description: 'bicycle parts - frame', quantity: '100', handlingunit: 'ctn', weight: '613.04', class: '', lenght: '102', width: '42', height: '61', flag: 'p' }, { name: 'item 2', itemid: '284308', itemcode: '', description: 'bicycle parts - fork', quantity: '200', handlingunit: 'ctn', weight: '242.99', class: '', lenght: '75', width: '34', height: '18', flag: 'p' }] }]; $scope.newpackageitem = function (packageelement, $event) { var npackageelement = {}; angular.copy(packageelement, npackageelement); counter++; packageelement.show = false; npackageelement.name = counter; angular.foreach(npackageelement.data, function (row) { if (row.quantity != row.newquantity || row.quantity != 0) { row.quantity = row.quantity - row.newquantity; } }); $scope.packageelement.push(npackageelement); }; }); }());

here trying duplicate first dataset , calculations on it. works fine except function newpackageitem. function lone throws error

typeerror: cannot read property 'push' of undefined @ scope.$scope.newpackageitem

fiddle

you misspelled property "packageelement" "pacakageelement". alter instances utilize "packageelement" , should work.

javascript angularjs

Travis sudo is disabled -



Travis sudo is disabled -

i want utilize apt install packages test, however, fails due sudo disabled. found next in test output:

sudo, firefox addon, setuid , setgid have been disabled.

it seems output comes this line in travic-ci, setting paranoid_mode false in .travis.yml not work.

how enable sudo access?

ps: using private repo.

edit: next .travis.yml fail due sudo: must setuid root when running sudo apt-get update -qq

language: python python: - "3.4" before_install: - sudo apt-get update -qq script: - nosetests

setting sudo: true and/or paranoid_mode: false not work.

sudo access turned off on our docker based architecture, used in 2 contexts:

repositories opt in using sudo: true in .travis.yml file (it additionally needs turned on on our side) on our educational programme (see http://education.travis-ci.com)

builds running on our docker based architecture cannot allowed sudo access due security concerns in lxc/docker layer. hope fixed in near future, unfortunately issue out of our own hands.

we working on improving firefox addon, uses sudo itself, shouldn't. we'll post on our blog 1 time has happened.

travis-ci

eclipse - How to always enable command handler in Egit -



eclipse - How to always enable command handler in Egit -

in egit, ..... when right click project, click "show in history", history view shows list of commits, select 1 commit, right click , pop menu shows (checkout, create branch, create tag, .....revision comment). need add together new item in pop menu called "add factory", when click it, go "addtofactoryhandler" implementation.

i want menu item there when right click commit in history view.

class="lang-xml prettyprint-override"><extension point="org.eclipse.ui.menus"> <menucontribution locationuri="popup:org.eclipse.egit.ui.historypagecontributions"> <command defaulthandler="xxxxxxxxxxx.addtofactoryhandler" commandid="xxxxxxxxxx.addtofactory" label="addtofactory" style="push" > </command> </menucontribution> </extension> <extension point="org.eclipse.ui.handlers"> <handler class="xxxxxxxxxxx.addtofactoryhandler" commandid="xxxxxxxxxx.addtofactory"> </handler> </extension>

then in history view, first time select commit, right click , popup menu shows grayed out "add factory". sec time, right click , goes away.

i appreciate help .. thanks!

you need utilize org.eclipse.ui.commands extension point define command id.

also note command in menucontribution not have defaulthandler parameter.

so like:

class="lang-xml prettyprint-override"><extension point="org.eclipse.ui.commands"> <command id="xxxxxxxxxx.addtofactory" defaulthandler="xxxxxxxxxxx.addtofactoryhandler" description="description" name="name"> </command> </extension> <extension point="org.eclipse.ui.menus"> <menucontribution locationuri="popup:org.eclipse.egit.ui.historypagecontributions"> <command commandid="xxxxxxxxxx.addtofactory" label="addtofactory" style="push" > </command> </menucontribution> </extension> <extension point="org.eclipse.ui.handlers"> <handler class="xxxxxxxxxxx.addtofactoryhandler" commandid="xxxxxxxxxx.addtofactory"> </handler> </extension>

eclipse git plugins

scala - Why TypeTag doesnt have method runtimeClass but Manifest and ClassTag do -



scala - Why TypeTag doesnt have method runtimeClass but Manifest and ClassTag do -

i have code generically transform string dto, if using manifest , classtag, both of can utilize method runtimeclass runtime class, typetag doesnt have method

class objectmapper[t] { def readvalue(x: string, t: class[t]): t = ??? } class reader { def read[w: manifest](x: string): w = { val mapper = new objectmapper[w] mapper.readvalue(x, implicitly[manifest[w]].runtimeclass.asinstanceof[class[w]]) } }

may know why typetag doesnt have method runtimeclass

many in advance

assuming typetag comes scala.reflect.runtime.universe, can class this:

def runtimeclass(tag: typetag) = tag.mirror.runtimeclass(tag.tpe)

it doesn't have method because not typetags runtime universe.

scala

javascript - How do browsers render contents of a canvas element -



javascript - How do browsers render contents of a canvas element -

how browser render contents of html canvas? things context.lineto(x, y). there must component converts function calls pixel data. want know if there way pixel info without rendering somewhere.

i want know if can run sort of stand lone javascript engines (v8) , pass javascript code , pixel info output.

what want know if there way pixel info without rendering somewhere.

natively no, there no way pixel info besides using canvas (technically bitmap) rasterize vector info (paths) in browser.

the browsers typically utilize underlying graphic core scheme (ie. directx etc.) rasterization. have no access through browser (nor on top of v8/node.js unless modify it). sub-system handle rasterizing of lines, circles, arcs , ellipses pixels, fill polygons , forth, not building array of point positions simply "walking" slope (put simple of course of study - fill uses different approach though based on line scanning).

for lines means current pixel illustration registered temporary relative previous one, circle/ellipses pixel typically in add-on mirrored here , there. in essence there no registration of absolute or relative pixel positions can extracted after rasterization took place.

if after array positions of each pixel need implement own solution of algorithm. unless need special reason cannot see why not utilize canvas much faster you, or work in vector space directly, rasterize them when needed.

you can utilize javascript implement using various line algorithms , have out there. see marke's first-class reply starter. did retro-canvas while can have @ see algorithms used in javascript. optimized well.

in add-on need implement 2d matrix rotation, scaling , translation if want flexibility/compatibility of canvas.

one thing need aware of though approach eliminate anti-aliasing of import smooth looking result. you'll have add together on top if need (you seek sync internal lines drawn on canvas need exact same @ stage can problem linux, mac, windows etc. uses different graphic sub-systems perchance minor variations in result) , require register additional pixels different colors/alpha values.

some resources:

bresenham line , circle algorithm efla line algorithm bresenham ellipse algorithm polygon fill algorithm

these basic building blocks typical polygonal shape (an arc part of circle didn't include this, there exists optimized approaches out there).

you can in add-on utilize catmull/rom , cardinal splines bezier typically implemented 2. order (quadratic, 1 command point) , 3. order (two command points), if want ability create smoother shapes, font outlines , forth.

another possible approach draw shapes on off-screen canvas in white color on black or transparent background, scan each line , set each pixel find it's position , relative color (to alpha) in array. however, not give continuous lines, each pixel's position whatever part of...

javascript html5 web html5-canvas

c++ - Avoiding redeclaration for header to source file -



c++ - Avoiding redeclaration for header to source file -

let's have 2 files foo.h , foo.cpp

foo.h

class foo { public: foo(); ~foo(); private: /* fellow member functions */ static void dothis(); /* fellow member variables */ static int x; protected: };

foo.cpp

#include "foo.h" int foo::x; void foo::dothis() { x++; }

can avoid hassle of having declare each variable in foo.cpp again? if removed line int foo::x; linker error unresolved external symbol.

is there way of doing without having type line each variable i'm planning use?

you need re-declare static variables. if create variable in class definition without making them static, can leave them there. example:

foo.h

#ifndef _foo_h_ #define _foo_h_ class foo{ private: static int i; //static variable shared among instances int o; //non-static variable remains unique among instances public: foo(); //consructor }; #endif

foo.cpp

int foo::i = 0; //only static variables can initialized when in class //no definition required non-statics foo::foo(){ //constructor code here = 0; };

the #ifndef block prevents header accidentally beingness included multiple times same source file. in case header included in header, which, if these blocks not present, result in infinite include loop , forcefulness compiler quit when counts include depth that's high.

c++

javafx - Starting multiple animations at the same time -



javafx - Starting multiple animations at the same time -

i'm trying start transition in each box of every row, successive boxes (left right) starting own transitions before previous ones finish. looked @ sequentialtransition, seems imply transitions started 1 after after previous 1 finishes.

i'm thinking need utilize paralleltransition each row, how can go doing this?

i noticed constructor paralleltransition(animation... children); possible phone call constructor 1 time animations, given how i'm instantiating each animation separately?

gridpane gp; ... (int i=0;i<gp.getrowconstraints().size();i++) { timeline tl = new timeline(); tl.setcyclecount(animation.indefinite); tl.setdelay(duration.millis((math.random() * 2500) + 500)); (int j=0;j<gp.getcolumnconstraints().size();j++) { tile t = new tile(); tl.getkeyframes().addall( new keyframe(duration.zero, new keyvalue(t.huemultiplier, 15)), new keyframe(duration.millis(5000), new keyvalue(t.huemultiplier, 1)) ); gp.add(t, j, i); } ... }

animation not start until phone call play() method of it. creating them separately in different places adding paralleltransition valid.

paralleltransition pt = new paralleltransition(); ... for(...) { timeline tl = new timeline(); ... pt.getchildren().add(tl); } ... pt.play();

javafx javafx-2 javafx-8

javascript - How to update source codes of a phonegap application from server -



javascript - How to update source codes of a phonegap application from server -

i have been developing phonegap applications need create updates oftenly. problem pushing new ipa itune store take long. so, uploaded application source codes(minified javascript) server , download application , "eval" minified js files. sense using eval has limitations , not right way. so, can tell me right way accomplish this. give thanks much.

i'd love have well. you're ahead of me w/your eval() approach - i'd have same concerns there. here's i'm aware out there on topic - hope helps?

ideapress(?)

i caught wind of 1 - not sure how feasible it claims we'd like. have main site looks bit flaky definitly checking out see if it's feasible or not.

hockeyapp?

hockeyapp (possibly dead-end now). thought there used pretty clear solution phonegap devs integrate hockeyapp api/feature set mobile apps recent google search on turning much less think - maybe it's dead end now? http://goo.gl/gqov5o

org.apache.cordova.file

this requires more work , haven't pushed far plenty yet see if means of updating app post-app-store-deployment. based on what i've read if you're updating code webview shouldn't have worry app store rejection or anything. related tutorial

testflight app testing (apple)

i haven't gotten play w/this yet sounds promising @ to the lowest degree beta/testing phase of development. i, you, need solution end-users, not app testers, i'll still looking might replace me having maintain own over-the-air app installs best/testing periods.

javascript cordova

python - Elasticsearch full-text autocomplete -



python - Elasticsearch full-text autocomplete -

i'm using elasticsearch through python requests library. i've set analysers so:

"analysis" : { "analyzer": { "my_basic_search": { "type": "standard", "stopwords": [] }, "my_autocomplete": { "type": "custom", "tokenizer": "keyword", "filter": ["lowercase", "autocomplete"] } }, "filter": { "autocomplete": { "type": "edge_ngram", "min_gram": 1, "max_gram": 20, } } }

i've got list of artists i'd search using autocomplete: current test case 'bill w', should match 'bill withers' etc - artist mapping looks (this output of get http://localhost:9200/my_index/artist/_mapping):

{ "my_index" : { "mappings" : { "artist" : { "properties" : { "clean_artist_name" : { "type" : "string", "analyzer" : "my_basic_search", "fields" : { "autocomplete" : { "type" : "string", "index_analyzer" : "my_autocomplete", "search_analyzer" : "my_basic_search" } } }, "submitted_date" : { "type" : "date", "format" : "basic_date_time" }, "total_count" : { "type" : "integer" } } } } } }

...and run query autocomplete:

"query": { "function_score": { "query": { "bool": { "must" : { "match": { "clean_artist_name.autocomplete": "bill w" } }, "should" : { "match": { "clean_artist_name": "bill w" } }, } }, "functions": [ { "script_score": { "script": "artist-score" } } ] } }

this seems match artists contain either 'bill' or 'w' 'bill withers': wanted match artists contain exact string. analyser seems working fine, here output of http://localhost:9200/my_index/_analyze?analyzer=my_autocomplete&text=bill%20w:

{ "tokens" : [ { "token" : "b", "start_offset" : 0, "end_offset" : 6, "type" : "word", "position" : 1 }, { "token" : "bi", "start_offset" : 0, "end_offset" : 6, "type" : "word", "position" : 1 }, { "token" : "bil", "start_offset" : 0, "end_offset" : 6, "type" : "word", "position" : 1 }, { "token" : "bill", "start_offset" : 0, "end_offset" : 6, "type" : "word", "position" : 1 }, { "token" : "bill ", "start_offset" : 0, "end_offset" : 6, "type" : "word", "position" : 1 }, { "token" : "bill w", "start_offset" : 0, "end_offset" : 6, "type" : "word", "position" : 1 } ] }

so why not excluding matches 'bill' or 'w' in there? there in query allowing results match my_basic_search analyser?

i believe need "term" filter instead of "match" 1 "must". have split artist names in ngrams searching text should match 1 of ngrams. happen need "term" match ngrams:

"query": { "function_score": { "query": { "bool": { "must" : { "term": { "clean_artist_name.autocomplete": "bill w" } }, "should" : { "match": { "clean_artist_name": "bill w" } }, } }, "functions": [ { "script_score": { "script": "artist-score" } } ] } }

python elasticsearch python-requests

ios - What's causing the massive changes in autorotation in 8.1 compared to 8.0.2? -



ios - What's causing the massive changes in autorotation in 8.1 compared to 8.0.2? -

i'm coding video processing app , submit app store when ios 8.1 came out. updated iphone xcode , hell broke loose. in simple single viewcontroller interface nil rotating anymore except statusbar, doesn't automatically hidden anymore in landscape mode...

i figured because using deprecated willanimaterotationtointerfaceorientation: little custom rotation actions had, implemented traitcollectiondidchange: , viewwilltransitiontosize: specs instead. viewwilltransitiontosize never gets called in app , traitcollectiondidchange: called once, @ startup. device isn't telling app device has rotated.

after googling i've tried using name:uideviceorientationdidchangenotification. @ to the lowest degree selector called 1 don't know how manually handle all rotation.

my didfinishlaunching... , viewdidload simple. alloc uiwindow, storyboard, set viewcontroller there, create rootviewcontroller, makekeyandvisible. based on 1 of apple's avfoundation demo apps. in didload add together subviews , toolbar etc, nil out of ordinary , did work on 8.0 , 8.0.2 on kinds of devices 7.1 simulator etc. still runs flawlessly on ipad 8.0.2... reason haven't posted code i'm 100% sure right on end.

main weird thing can't seem find problem. no errors in console or elsewhere either.

does have thought of might causing this? didn't think point release create such massive differences , again, no 1 else seems having this. issue/bug in actual storyboard file?

and, mainly, since can rotation notifications through uideviceorientationdidchangenotification, how manually handle rotation/resizing stuff? have been looking on answers no avail , out of time spend on project :(

cheers!

alloc'ing uiwindow problem.

first, create sure navigation controller (or whatever you're using) set "initial view controller" in storyboard.

secondly, in appdelegate.m file, remove references uiwindow , rootviewcontroller appear in application didfinishlaunchingwithoptions. in case, removing next 2 lines fixed issues.

self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; [self.window makekeyandvisible];

you don't need set window's rootviewcontroller if using storyboards.

they're not needed when using storyboards, until 8.1 there never harm using them. took 2 days figure out, help , others too.

ios objective-c xcode auto-rotation ios8.1

mongodb - What is the simplest transaction framework in Java? -



mongodb - What is the simplest transaction framework in Java? -

given have simple task: process piece of info , append file. ok if dont have exceptions, may happen. if goes wrong remove changes file.

also, may have set variables during processing , homecoming previous state too.

also, may work database doesn't back upwards transactions (to best of knowledge mongodb not), rollback db somehow.

yes, can prepare issue file manually backuping file , replacing it. looks need transaction framework.

i dont want utilize spring monster this. much. , dont have elb container manage ejb. have simple java stand-alone application, needs transaction support.

do have other options instead of plugging spring or ejb?

if don't want utilize spring, seek implements simple two-phase commit mechanism: two-phase commit protocol

java mongodb transactions jta

angularjs - Angular UI Router - onEnter not get the $stateParams -



angularjs - Angular UI Router - onEnter not get the $stateParams -

according faq code should work:

$stateprovider.state("items.add", { url: "/add", onenter: ['$stateparams', '$state', '$modal', '$resource', function($stateparams, $state, $modal, $resource) { console.log($stateparams.param1); // should print "bla bla bla" $stateparams.param1 isnot defined; }], url: "/test", onenter: ['$state', function($state){ $state.go('add', {param1: 'bla bla bla'}); } });

and should print "bla bla bla"..

can tell me why not working?

this code has multiple syntax errors , don't see how could've run (missing ], duplicate properties in same object, etc).

my best guess haven't defined param1 parameter. can't utilize arbitrary parameters when transitioning state, must either part of url or defined in params state argument.

angularjs angular-ui angular-ui-router

ios - Handoff action disappears after a period of time, need to call periodically? -



ios - Handoff action disappears after a period of time, need to call periodically? -

i'm implementing handoff in app. in app i've created handoff controller global entire application, phone call [useractivity becomecurrent] once. however, issue having handoff icon (app icon in lock screen , in app switcher) disappear after period of time (~10 minutes), , when relaunch app (i.e. calls becomecurrent again), handoff feature appear.

i not calling invalidate during 10 minutes, i've verified setting breakpoint.

so required phone call becomecurrent periodically? it's not written in documentation.

note: i've created handoff controller opposed implementing protocol in view controller because there many view controllers should allow handoff occur.

ios objective-c ios8 ios8.1 handoff

Permission denied when i try to execute a python script from bash? -



Permission denied when i try to execute a python script from bash? -

this question has reply here:

-bash: ./manage.py: permission denied 2 answers

i downloaded python script web , when seek execute bash throws exception:

user:python_script user$ ./python_script.py -n some_parameter -b

the output following:

-bash: ./python_script.py: permission denied

the file ready has: #!/usr/bin/python @ top of script. how can solve this?

you need add together execute permissions so:

chmod u+x python_script.py

this assumes script owned you. if isn't, might need alter group/other execute permissions or chown file appropriate.

python bash shell python-2.7

java - How to open thread using process? -



java - How to open thread using process? -

i have thread write in file using printwriter

class nthread implements runnable { thread t; printwriter w; private volatile boolean running=true; public nthread(int p, printwriter w) { t=new thread(this); this.w=w; t.setpriority(p); } public void run() { while(running) { w.println("id: " + t.getid()); } } public void stop() { running=false; } public void start() { t.start(); } }

and seek using new process open thread.

public class filewrite { public static void main(string[] args) { thread.currentthread().setpriority(thread.max_priority); thread ref_mainthread=thread.currentthread(); seek { printwriter printwriter = new printwriter("c:\\write.txt"); printwriter.println("id main thread" + ref_mainthread); nthread p1=new nthread(thread.norm_priority + 4,printwriter); process process1 = new processbuilder("p1",".start()").start(); seek { thread.sleep(1000); } process1.destroy(); printwriter.close(); } grab (ioexception e) { system.out.println(e.getmessage()); } }

i seek write in 1 file 2 processes. how can it?

process process1 = new processbuilder("p1",".start()").start();

you telling operating scheme run programme named "p1", ".start()" first command line argument.

if you're on linux, it's same if typed "p1 .start" in shell window. if you're on windows, same if typed in cmd.exe window. either way, it's not going think it's going do.

the p1 in nthread p1=new nthread(thread.norm_priority + 4,printwriter); variable in java program. fact refers object can used start thread not cause programme named p1 magically appear on $path (or %path% if you're on windows.)

java multithreading process

c# - Change button style on page load -



c# - Change button style on page load -

this table , on table have cells in form of buttons. css sheet have made them green.

<asp:table id="table1" runat="server" borderwidth="2px" bordercolor="#0033cc" backcolor="#ffcccc" > <asp:tablerow> <asp:tablecell cssclass="table-cell-room" id="d256">d256<br /></asp:tablecell> <asp:tablecell><asp:button runat="server" width="100px" text="boka" id="r1b1" onclick="button_click_first_row" cssclass="buttons"/></asp:tablecell> <asp:tablecell><asp:button runat="server" width="100px" text="boka" id="r1b2" onclick="button_click_first_row" cssclass="buttons"/></asp:tablecell> <asp:tablecell><asp:button runat="server" width="100px" text="boka" id="r1b3" onclick="button_click_first_row" cssclass="buttons"/></asp:tablecell> <asp:tablecell><asp:button runat="server" width="100px" text="boka" id="r1b4" onclick="button_click_first_row" cssclass="buttons"/></asp:tablecell> <asp:tablecell><asp:button runat="server" width="100px" text="boka" id="r1b5" onclick="button_click_first_row" cssclass="buttons"/></asp:tablecell> </asp:tablerow>

i have database table called room , contains id, button_id , checkifbooked. want utilize "colum" checkedifbook see if booked, meaning checkedifbooked = 1.

all of work have no thought style buttons on table of have checkedifbooked = 1.

meaning in database table have r1b1 , it's value checkedifbooked = 1. have no thought code in page load. don't want utilize

if(button_id == r1b2){ checkedifbooked == 1 //do styling on button }

cause have alot of buttons , in c# code utilize sender new button right id button clicked.

possible solution #1

when rendering page, add together additional css class button if isbooked = true

if (isbooked) { /// render "isbooked" tablecell button <asp:tablecell> ... cssclass="isbooked"/></asp:tablecell> } else { /// render "not booked" tablecell button <asp:tablecell> ... cssclass="button"/></asp:tablecell> }

then in css:

.isbooked { /* isbooked button styles here */ }

so when code gets rendered html, css classes in place:

<!-- illustration html output --> < ... class="button" ... ></> < ... class="isbooked" ... ></> < ... class="button" ... ></> possible solution #2

on page load, have jquery booked buttons, , disable them, or style them, etc..

$(document).ready(function(){ $("isbooked").each(function(index){ // each isbooked element available via $(this) $(this).addclass("bookedbutton"); $(this).prop("disabled", true); // ... }); });

security note: disabling form button on client-side (via javascript) isn't enough, need validate info on server side. if disable form elements on client, create sure server verifies nil "booked" trying submitted form.

hope helps.

c# database button styles

C memory allocation affects char array length -



C memory allocation affects char array length -

#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { //step 1 char *key = malloc(10000); int *arr = malloc(sizeof(int)); free(arr); free(key); //step 2 char *msg = malloc(10000); printf("size: %zu \n", strlen(msg)); free(msg); homecoming 0; }

could explain this:

if execute both step 1 , 2, length of msg 6, 4 if exectue both step 1 , 2, without allocation , freeing of key, length 0 if execute step 2, length of msg 0

why allocation of int , key array impact length of char array? realize strlen requires '\0' char, why behave different?

char *msg = malloc(10000); printf("size: %zu \n", strlen(msg));

msg allocated, not initialized, undefined behavior phone call strlen(msg).

in cases, perhaps happens in uninitialized memory allocated malloc, first 0 appeared @ different places.

c arrays memory allocation

winapi - difference between GetDesktopWindow() and HWND_DESKTOP -



winapi - difference between GetDesktopWindow() and HWND_DESKTOP -

there's win32 api function, getdesktopwindow(), returns handle of desktop window.

and there's 1 - hwnd_desktop macro. couldn't find official info in msdn, it's found in winuser.h

#define hwnd_desktop ((hwnd)0)

so, what's difference between them?

hwnd_desktop used mapwindowrect() indicate using screen coordinates, as documented on msdn. you'll notice value equal null, listed there. i'm guessing hwnd_desktop came first.

of course, valid windows cannot null real, hwnd_desktop isn't handle of desktop window. while don't know of real things can it, proper way desktop window's handle function.

(for it's worth, illustration getdesktopwindow() uses returned handle position dialog box on screen. don't know if current preference utilize current monitor's work area instead...)

winapi

Woocommerce - Custom Shortcode - Add to Cart Button - How? -



Woocommerce - Custom Shortcode - Add to Cart Button - How? -

i working custom loop woocommerce. defined shortcode. code looks this:

<?php add_shortcode( 'kurse', 'ik_kurse' ); function ik_kurse( $atts, $content = null ) { // shortcode parameters extract(shortcode_atts(array( "per_page" => '' ), $atts)); // woocommerce global global $woocommerce; // create object ob_start(); // create query arguments array $query_args = array( 'posts_per_page' => '', 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', ); // add together meta_query query args $query_args['meta_query'] = array(); // check products stock status $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); // create new query $r = new wp_query($query_args); // if query homecoming results if ( $r->have_posts() ) { $content = '<ul class="rc_wc_rvp_product_list_widget">'; // start loop while ( $r->have_posts()) { $r->the_post(); global $product; $description= $prod_term->description; $content .= '***add cart button'; $content .= '<li>'; $content .= $product->get_sku(); ?> <br /><?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ); $content .= " | "; $content .= $product->get_price_html(); $content .= '</li>'; } $content .= '</ul>'; } // clean object $content .= ob_get_clean(); // homecoming whole content homecoming $content;}

i can not figure out how add together "add cart" button here, in line every single product. can help? give thanks you!

woocommerce shortcode

regex - Regular expression for number in JavaScript -



regex - Regular expression for number in JavaScript -

i want regular look numbers, not less 3 , more 7 digit , should not take characters.

i tried (/^[0-9]{3,7}$/) - accepting character 'e'. eg: 1e3, 23e4, 123e4 failing.

my guess 1e3 number written in engineering notation, not string. e means "times 10 powerfulness of", 1e3 means 1 x 10^3 = 1000, , 23e4 means 230000. if case, when convert number 1e3 string, output "1000", represents number not less 3 digits , not more 7, right regex matches this.

javascript regex

excel - Vba Screen flickering after using Screenupdating = False -



excel - Vba Screen flickering after using Screenupdating = False -

i have vba code includes application.screenupdating = false. have checked debug.print , @ each stage of within code, screenupdating = false. however, screen still keeps flickering. have read several google posts on nil has been helpful.

please see next code:

application.screenupdating = false sheet3.benchmark1.clear sheet3.benchmark2.clear sheet3.offshorefund_list.clear application.screenupdating = true

thanks, adam

excel vba excel-vba flicker

html - How to fade out and close YUI div element -



html - How to fade out and close YUI div element -

how can close multiple instances of yui div elements (modules) on 1 page. next code 1 instance :

class="snippet-code-js lang-js prettyprint-override">yui({filter: 'raw'}).use('node','anim', function(y) { var anim = new y.anim({ node: '#panel1', to: { opacity: 0 } }); var onend = function() { var node = this.get('node'); node.get('parentnode').removechild(node); }; anim.on('end', onend); y.one('#panel1 .yui3-remove').on('click', anim.run, anim); }); class="snippet-code-html lang-html prettyprint-override"><div id="panel1" class="yui3-module"> <div class="yui3-hd"><h3>learners progress</h3> <a title="fade remove element" class="yui3-remove"><em>x</em></a></div> <div class="yui3-bd" style="border:0px solid black" id="learnerstatus"></div> </div>

how can modify code utilize multiple divs code takes id of div. so, have replicate each div. there other way?

there dozens of different ways accomplish goal , here 1 of them: http://jsfiddle.net/2rw84usl/

html:

<div class="items"> <div class="item"> <h3>learners progress</h3> <span class="remove">close</span> </div> <div class="item"> <h3>learners progress</h3> <span class="remove">close</span> </div> </div>

script:

yui().use('node','anim', function(y) { var anim = new y.anim({ to: { opacity: 0 }, duration: 0.5, on : { end : function() { var node = this.get('node'); node.get('parentnode').removechild(node); } } }); y.one('.items').delegate('click', function(e) { anim.set('node', e.target.get('parentnode')).run(); }, '.remove'); });

please note: i'm using event delegation here because more effective way "listen" events many similar elements (such close buttons).

read more event delegation here: http://yuilibrary.com/yui/docs/event/#delegation

html events panel yui

How can I repeat elements in place in an array in Python? -



How can I repeat elements in place in an array in Python? -

how can repeat elements in place in array in python?

or similarly, more simple this:

drange = []; in xrange(j): drange.append(i); drange.append(i);

it should produce: [0, 0, 1, 1, 2, 2, ... j-1, j-1]

>>> j = 3 >>> drange = [] >>> in xrange(j): ... drange.extend([i]*2) ... >>> drange [0, 0, 1, 1, 2, 2]

or list comprehension

>>> drange = [i in xrange(j) k in range(2)] >>> drange [0, 0, 1, 1, 2, 2]

in cases method can appropriate

>>> drange = [i//2 in xrange(j*2)] >>> drange [0, 0, 1, 1, 2, 2]

python

Excel cell content into multiple rows into another sheet -



Excel cell content into multiple rows into another sheet -

i have requirement in excel want re-create each text ends pulistop row of sheet. ex:

setting configuration.

creating environment.

pushing tasks.

now assume above text in 1 cell , want re-create each sentence ends pulistop individual rows of new sheet. below.

setting configuration.

creating environment.

pushing tasks.

please help me in doing have many no. of sheets needs modification.

thanks in advance. chakri.

check if can useful you:

copy cell(s) clipboard (ctrl+c). paste notepad or similar text editor. note: in notepad lines appear next each other, nevermind, line jumps still there. replace in text editor " (double quotes) nothing. copy whole text of editor. paste excel.

this works in case. if have many cells next each other, method can process @ 1 time same effort. work you?

excel

multithreading - cudaDeviceSynchronize() waits to finish only in current CUDA context or in all contexts? -



multithreading - cudaDeviceSynchronize() waits to finish only in current CUDA context or in all contexts? -

i utilize cuda 6.5 , 4 x gpus kepler.

i utilize multithreading, cuda runtime api , access cuda contexts different cpu threads (by using openmp - not matter).

when phone call cudadevicesynchronize(); wait kernel(s) finish in current cuda context selected latest phone call cudasetdevice(), or in cuda contexts?

if wait kernel(s) finish in cuda contexts, wait in cuda contexts used in current cpu thread (in illustration cpu thread_0 wait gpus: 0 , 1) or cuda contexts (cpu thread_0 wait gpus: 0, 1, 2 , 3)?

following code:

// using openmp requires set: // msvs option: -xcompiler "/openmp" // gcc option: –xcompiler –fopenmp #include <omp.h> int main() { // execute 2 threads different: omp_get_thread_num() = 0 , 1 #pragma omp parallel num_threads(2) { int omp_threadid = omp_get_thread_num(); // cpu thread 0 if(omp_threadid == 0) { cudasetdevice(0); kernel_0<<<...>>>(...); cudasetdevice(1); kernel_1<<<...>>>(...); cudadevicesynchronize(); // kernel<>() wait? // cpu thread 1 } else if(omp_threadid == 1) { cudasetdevice(2); kernel_2<<<...>>>(...); cudasetdevice(3); kernel_3<<<...>>>(...); cudadevicesynchronize(); // kernel<>() wait? } } homecoming 0; }

when phone call cudadevicesynchronize(); wait kernel(s) finish in current cuda context selected latest phone call cudasetdevice(), or in cuda contexts?

cudadevicesynchronize() synchronize host set gpu, if multiple gpus in utilize , need synchronized, cudadevicesynchronize() has called separately each one.

here minimal example:

cudasetdevice(0); cudadevicesynchronize(); cudasetdevice(1); cudadevicesynchronize(); ...

so, reply cudadevicesynchronize() syncs streams in current cuda context

source: pawel pomorski, slides of "cuda on multiple gpus". linked here.

multithreading cuda gpgpu nvidia

latex - Toc LOF alignment issue in lyx -



latex - Toc LOF alignment issue in lyx -

i'm doing thesis in latex , using lyx editor accomplish it. want place toc , lof @ center of page. used

\usepackage{tocloft} \renewcommand{\cfttoctitlefont}{\hfill\huge\hfill}

but pushing toc caption right.

how center lof in same way?

you should insert content before table of contents/toc title after:

\usepackage{tocloft} \renewcommand{\cfttoctitlefont}{\hfill<titlefont>} \renewcommand{\cftaftertoctitle}{\hfill\mbox{}}

<titlefont> represents font switches you're interested in making. adjustments list of figures/lof (list of tables/lot), utilize \cftloftitlefont , \cftafterloftitle (\cftlottitlefont , \cftafterlottitle).

latex lyx toc

c - Difference between u8, uint8_t, __u8 and __be8 -



c - Difference between u8, uint8_t, __u8 and __be8 -

while browsing linux networking code, came across these datatypes:

u8 uint8_t __u8 __be8

(same things 16, 32 , 64 bits)

can please explain difference between these datatypes , utilize which? have seen definitions of these datatypes not clear me.

uint8_t standard c , represents unsigned 8-bit integral type. if on scheme not have 8-bit addressable units not defined; otherwise typedef unsigned char.

anything __ in reserved implementation use. means compiler writers , standard library writers can utilize identifiers without worrying name clash user code. may see when looking in internals of standard library implementation.

u8 non-standard means same uint8_t. reason u8 might used in code written before uint8_t added standard c.

c linux linux-kernel

javascript - Restrict container/parent for Sortable -



javascript - Restrict container/parent for Sortable -

ok, here again, playing @rubaxa's sortable plugin (and somewhere around here, 1 rather complicated...)

a few discoveries (it took me time understand mechanism, think i'm quite right)

case 1

if set 1 div same-type contents, it's instantly sortable. e.g.:

html

<div id="mycontainer"> <h3>item 1</h3> <h3>item 2</h3> </div>

javascript

new sortable(document.getelementbyid("mycontainer"));

demo: http://jsfiddle.net/b02wfe4o/

case 2

if set 1 div different-type contents (e.g. h2s , h3s, have specify draggable class. e.g.:

html

<div id="mycontainer"> <h3 class="mydraggable">item 1</h3> <h4 class="mydraggable">item 2</h4> </div>

javascript

new sortable(document.getelementbyid("mycontainer"), { draggable: '.mydraggable' });

demo: http://jsfiddle.net/qemz00eq/1/

case 3

if set 2 (or more) divs, side-by-side, works pretty much same way. e.g.:

html

<div id="mycontainer1"> <h3 class="mydraggable">item 1.1</h3> <h4 class="mydraggable">item 1.2</h4> </div> <div id="mycontainer2"> <h3 class="mydraggable">item 2.1</h3> <h4 class="mydraggable">item 2.2</h4> </div>

javascript

new sortable(document.getelementbyid("mycontainer1"), { draggable: '.mydraggable' }); new sortable(document.getelementbyid("mycontainer2"), { draggable: '.mydraggable' });

demo: http://jsfiddle.net/qeyxxj4y/

the issue

now, if sortable kid of sortable b?

html

<div id="mycontainer1"> <h3 class="mydraggable">item 1.1</h3> <h4 class="mydraggable">item 1.2</h4> <div id="mycontainer2"> <h3 class="mydraggable">item 2.1</h3> <h4 class="mydraggable">item 2.2</h4> </div> </div>

javascript

new sortable(document.getelementbyid("mycontainer1"), { draggable: '.mydraggable' }); new sortable(document.getelementbyid("mycontainer2"), { draggable: '.mydraggable' });

demo: http://jsfiddle.net/j7feslkp/8/

well, not work expected:

mycontainer2 items can moved/sorted within container. fine. mycontainer1 items though can moved in mycontainer2 well, mean take element 1.1 , set within mycontainer2 works - wasn't happening when 2 containers side-by-side.

so, how can disable behaviour? mean: each container's items must move within container , not within children.

how can done?

you gave separate sortables, , split them in 2 different groups. alter class of 1 of groups in html , js initialize them group.

javascript jquery html css rubaxa-sortable

Using REST to fetch SharePoint View Items -



Using REST to fetch SharePoint View Items -

i trying build right url homecoming items in sharepoint view using rest api.

using browser , next url can homecoming items in list.

https://mysharepoint.sharepoint.com/sites/mysite/_api/web/lists/getbytitle('announcements')/items

and can view definition using next url.

https://mysharepoint.sharepoint.com/sites/mysite/_api/web/lists/getbytitle('announcements')/views/getbytitle('latest news')/

but cannot figure out need set @ end of url items returned the view.

sp.view object not contain methods manipulating list items. sp.view object contains sp.view.viewquery property specifies query used list view. means next approach used retrieving list items view:

perform first request caml query list view using sp.view.viewquery property perform sec request retrieve list items specifying caml query how homecoming list items list view using rest api using javascript function getjson(url) { homecoming $.ajax({ url: url, type: "get", contenttype: "application/json;odata=verbose", headers: { "accept": "application/json;odata=verbose" } }); } function getlistitems(weburl,listtitle, querytext) { var viewxml = '<view><query>' + querytext + '</query></view>'; var url = weburl + "/_api/web/lists/getbytitle('" + listtitle + "')/getitems"; var querypayload = { 'query' : { '__metadata': { 'type': 'sp.camlquery' }, 'viewxml' : viewxml } }; homecoming $.ajax({ url: url, method: "post", data: json.stringify(querypayload), headers: { "x-requestdigest": $("#__requestdigest").val(), "accept": "application/json; odata=verbose", "content-type": "application/json; odata=verbose" } }); } function getlistitemsforview(weburl,listtitle,viewtitle) { var viewqueryurl = weburl + "/_api/web/lists/getbytitle('" + listtitle + "')/views/getbytitle('" + viewtitle + "')/viewquery"; homecoming getjson(viewqueryurl).then( function(data){ var viewquery = data.d.viewquery; homecoming getlistitems(weburl,listtitle,viewquery); }); }

usage

getlistitemsforview(_sppagecontextinfo.webabsoluteurl,'announcements','latest news') .done(function(data) { var items = data.d.results; for(var = 0; < items.length;i++) { console.log(items[i].title); } }) .fail( function(error){ console.log(json.stringify(error)); });

rest sharepoint-2013

linux - How to parse MySQL slow query log for last 24 hours of entries -



linux - How to parse MySQL slow query log for last 24 hours of entries -

i'd process mysql slow query log , retrieve lastly 24 hours of entries, log rotation isn't alternative @ present.

below illustration log entry

# query_time: 0.000431 lock_time: 0.000124 rows_sent: 8 rows_examined: 25 set timestamp=1415792064; select `username`, `password`, `date_created` joomla_users order `kid` desc; # user@host: joomla[joomla] @ [192.168.168.100]

i utilize awk or grep or similar solution executed via command line or part of script identify entries placed in mysql slow query log file within lastly 24 hours comparing "set timestamp" line each entry , place said entries separate log file.

i recommend using percona toolkit's query digest tool sort of analysis. it's straightforward install , you'd want analysis of slow queries (analyze them based on query footprints, not individual arguments in queries, exclude types of queries based on regex expressions, etc)

take percona toolkit (http://www.percona.com/doc/percona-toolkit/2.1/pt-query-digest.html). if decide utilize it, next code should easy adapt

pt-query-digest --since '2014-11-01' --filter '$event->{arg} =~ m/^select/i' /var/log/mysql/mysql-slow-query.log > /tmp/pt_slow_nov

what that's saying analyze queries 2014-11-01 onward, @ select queries, read slow query log /var/log/mysql/slow-query.log (obviously you'll need reference file location) , output analysis /tmp/pt_slow_nov. if you're familiar grep , awk, should pretty straightforward parameterize --since portion of query , stick in cron.

mysql linux awk sed grep

android - savedInstanceState memory implications -



android - savedInstanceState memory implications -

i working on android project few other developers , bug raised instance states not beingness retained on garbage collection:

the actual bug reported:

the app has 1 activity bunch of fragments. if "don't maintain activities" checked in developer options , user clicks on button changes visible fragments, , navigates away app , back, relaunches app original state instead of lastly state.

another dev on project raised next concern:

"the saving of instances cause apps in memory size bloat. already, because of amount of drawables, apps memory size high.

its ok, if app restarts after while of non usage user."

my understanding savedinstance bundle gets written physical memory, not correct? above quote valid concern?

my understanding savedinstance bundle gets written physical memory, not correct?

i interpreting "written physical memory" meaning "written file on filesystem" (a.k.a., "persisted").

the instance state bundle not persisted. android 5.0+ gives different hook persistablebundle is persisted , hence survives reboot.

however, instance state bundle passed across process boundaries core os process. info can used if process terminated, user returns app while task still around (e.g., via recent-tasks list).

is above quote valid concern?

the piece of quote reasonably evaluated people here on is:

the saving of instances cause apps in memory size bloat

saving 1 byte in bundle consume more memory saving 0 bytes in bundle. hence, mathematically, quote accurate. key maintain bundle small. can't big anyway other reasons (1mb limit ipc calls). little instance state bundles should not problem.

android android-fragments android-lifecycle android-bundle

ruby - Only allow module to define method if including class/module does not -



ruby - Only allow module to define method if including class/module does not -

i'm having lots of fun activemodel's serialization, tangled web of as_json , serializable_hash.

my app has big collection of models share behavior including module, we'll phone call sharedbehavior.

my team has decided have default format want these classes follow when beingness cast json (for rendering in rails app), of them should behave little differently. due odd behavior in these 2 methods activemodel library, adding whitelisted or blacklisted attributes in models gets overridden method definition in module, , passed on super declarations in activemodel.

for reason, i'd module apply definition of these methods models if not explicitly overridden in models (in essence, take module out of ancestor chain few method calls), still need shared behavior module.

i tried solving conditionally, dynamically applying method on module inclusion in irb:

class def foo puts 'in a' end end module d def self.included(base) unless base.instance_methods(false).include?(:foo) define_method(:foo) puts 'in d' super() end end end end class b < include d end class c < include d def foo puts 'in c' super end end

with declaration, expected output of c.new.foo be

in c in

but instead

in c in d in

my other thought move logic out module , include module in every class (there 54 of them) not explicitly override method, there couple downsides that:

it introduces bit of implicit coupling in project new model include module iff not want override method implementation the current implementation of these serialization methods in module have behavior , attributes established module, sense unintuitive have sec module knows , depends on implementation details of sharedbehavior, though sec module have nil first.

can else think of solution, or maybe spot oversight of mine in code illustration above allow me create phone call in included hook? (i tried switching order in c class defined foo method , included d module, saw same behavior).

there 2 tricky bugs here.

ruby evaluates classes, order of expressions matters. include d before defining foo in c, when included hook called, foo won't defined in base. need include d @ end of class. you're defining foo in d. after including d in b, d#foo defined, meaning it's still included in c if prepare previous bug. need base receiver of define_method.

but there's interesting twist: fixing sec bug makes first bug irrelevant. defining foo in base directly, overwritten later definitions. doing

class c < def foo puts 'in d' super() end # overwrites previous definition! def foo puts 'in c' super end end

so summarize, need

# in d.included base.class_eval define_method(:foo) puts 'in d' super() end end

ruby module include active-model-serializers

vb.net - Execute a program with a parameter from a *.bat file -



vb.net - Execute a program with a parameter from a *.bat file -

i help issue. have vb application located foler:

c:\folder\program.exe

i need execute using *.bat file, need send parameter this:

comprate&--&c:\folder\subfolder\comprate&--&false&--&

when execute application using ide (vs2010) goes case statement (in case 'comprate') , generates file same name folder 'c:\folder\subfolder\'

i have tried in bat file this:

"c:\folder\program.exe" "comprate&--&c:\folder\subfolder\comprate&--&false&--&"

this

"c:\folder\program.exe" comprate&--&c:\folder\subfolder\comprate&--&false&--&

and other options.

escape ampersands ^

& seperates commands on line. && executes command if previous command's errorlevel 0. || (not used above) executes command if previous command's errorlevel not 0 > output file >> append output file < input file | output of 1 command input of command ^ escapes of above, including itself, if needed passed programme " parameters spaces must enclosed in quotes + used re-create concatinate files. e.g. re-create file1+file2 newfile , used re-create indicate missing parameters. updates files modified date. e.g. re-create /b file1,, %variablename% inbuilt or user set environmental variable !variablename! user set environmental variable expanded @ execution time, turned sellocal enabledelayedexpansion command %<number> (%1) nth command line parameter passed batch file. %0 batchfile's name. %* (%*) entire command line. %<a letter> or %%<a letter> (%a or %%a) variable in loop. single % sign @ command prompt , double % sign in batch file. . --

vb.net batch-file windows-7 cmd

javascript - Why am I receiving a undefined is not a function error -



javascript - Why am I receiving a undefined is not a function error -

i have next jquery animates div top , slides down:

$(document).read(function () { $("#msearch").toggle( function () { $("#msearchb").animate({ top: '35' }, 500); }, function () { $("#msearchb").animate({ top: "-35" }, 500); } ); });

everytime click on msearch link, maintain getting next error:

uncaught typeerror: undefined not function (anonymous function)

how resolve it?

you have typo. utilize ready, not read.

javascript jquery

clojure - Can't get browser repl to work from chestnut template (figwheel, weasel) -



clojure - Can't get browser repl to work from chestnut template (figwheel, weasel) -

i seek started clojurescript using chestnut leiningen template combines piggyback, figwheel , weasel. after upgrading leiningen installation 2.5.0, can start clojure repl, after issuing recommended run , browser-repl commands, run cryptic error. there seems core.async issue well, don't know whether it's related.

chestnut-borked.server=> (run) 2014-10-07 12:38:06.506:info:oejs.server:jetty-7.6.13.v20130916 2014-10-07 12:38:06.545:info:oejs.abstractconnector:started selectchannelconnector@0.0.0.0:10555 starting figwheel. starting web server on port 10555 . #<server org.eclipse.jetty.server.server@6cdd377c> compiling clojurescript. figwheel: starting server @ http://localhost:3449 figwheel: serving files '(dev-resources|resources)/public' compiling "resources/public/js/app.js" ["src/cljs"]... warning: utilize of undeclared var cljs.core.async/do-alts @ line 62 file:/home/schauer /.m2/repository/org/clojure/core.async/0.1.278.0-76b25b-alpha/core.async-0.1.278.0-76b25b-alpha.jar!/cljs/core/async/impl/ioc_helpers.cljs warning: bad method signature in protocol implementation impl/handler lock-id @ line 214 file:/home/schauer/.m2/repository/org/clojure/core.async/0.1.278.0-76b25b-alpha/core.async-0.1.278.0-76b25b-alpha.jar!/cljs/core/async.cljs warning: utilize of undeclared var cljs.core.async.impl.protocols/lock-id @ line 217 file:/home/schauer/.m2/repository/org/clojure/core.async/0.1.278.0-76b25b-alpha/core.async-0.1.278.0-76b25b-alpha.jar!/cljs/core/async.cljs warning: utilize of undeclared var chestnut-borked.dev/put! @ line 14 src/cljs/chestnut_borked/dev.cljs [... warnings removed after first reply ...] warning: bad method signature in protocol implementation impl/handler lock-id @ line 214 resources/public/js/out/cljs/core/async.cljs warning: utilize of undeclared var cljs.core.async.impl.protocols/lock-id @ line 217 resources/public/js/out/cljs/core/async.cljs compiled "resources/public/js/app.js" in 21.377 seconds. notifying browser file changed: /js/app.js notifying browser file changed: /js/out/goog/deps.js notifying browser file changed: /js/out/chestnut_borked/core.js notifying browser file changed: /js/out/chestnut_borked/dev.js

besides warnings, far, -- jetty seems have started successfully. however, when seek start browser-repl, run error , connection seems broken:

chestnut-borked.server=> (browser-repl) warning: bad method signature in protocol implementation impl/handler lock-id @ line 214 file:/home/schauer/.m2/repository/org/clojure/core.async/0.1.278.0-76b25b-alpha/core.async-0.1.278.0-76b25b-alpha.jar!/cljs/core/async.cljs arityexception wrong number of args (0) passed to: compiler/with-core-cljs clojure.lang.afn.throwarity (afn.java:429) chestnut-borked.server=> (browser-repl) java.io.ioexception: no client connected websocket @ weasel.repl.server$send_bang_.invoke(server.clj:25) @ weasel.repl.websocket$send_for_eval_bang_.invoke(websocket.clj:130) @ weasel.repl.websocket$websocket_eval.invoke(websocket.clj:109) @ weasel.repl.websocket.websocketenv._evaluate(websocket.clj:34) @ cljs.repl$evaluate_form.invoke(repl.clj:113) @ cemerick.piggieback$cljs_eval$fn__5152.invoke(piggieback.clj:115) @ clojure.lang.afn.applytohelper(afn.java:152) @ clojure.lang.afn.applyto(afn.java:144) [...]

update: after input lnmx, it's becoming clear weasel isn't functioning properly. if take @ js elements browser sees, dev script apparently doesn't loaded , neither repl.js weasel, although there goog.adddependency calls them in app.js.

chestnut 0.5.0 has been released now. contains updated clojurescript should prepare issue weasel (the browser-connected repl), several other improvements.

clojure clojurescript

Making new activity in Android Studio results in error every time -



Making new activity in Android Studio results in error every time -

i amazed creativity of team behind entire android project... come new , exciting ways create our lives more miserable introducing horrible, horrible bugs, errors , randomness...

so, whenever l create new activity, ends woth error.

so, process of making new activity:

right after create one, next error appears:

and have go to: project construction - dependencies - , remove add together com.android.support:appcompat , like, bug fixed?

why hell have every time? nil happens..i create new activity , goes hell !

did add together dependency build.gradle file ? have installed android back upwards library sdk manager ?

android android-activity build-error

Parse URL From Right - Jquery/Regex -



Parse URL From Right - Jquery/Regex -

this question has reply here:

how can query string values in javascript? 73 answers

i have url similar to:

url/search/searchresult?searchtext=firstname%20lastname

using jq, how can parse after "searchtext=" , while replacing %20 space.

i'm looking homecoming string in next format:

"firstname lastname"

i figure can done regex, struggle working it, examples helpful.

thanks

you can this

var value = decodeuricomponent(url.split('?')[1].split('=')[1]);

jquery regex

find verified status for a list of facebook pagenames -



find verified status for a list of facebook pagenames -

i have 782 facebook page links page names in excel file. want find out how many of them verified fb. started find solution. got few articles not relevant question , relevant had limited info or not understand. after searching bit more have home wrote code given below not echo verified status. how can utilize if need check 782 pagenames. please help...

<?php function verified($pagename){ // query in fql $fql = "select is_verified"; $fql .= " page username = '$pagename'"; $fqlurl = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql); // facebook response in json $response = file_get_contents($fqlurl); homecoming json_decode($response); } $fb = verified('nokia'); echo $fb[0]->is_verified; ?>

edit: more info: searched , found can done using fql , api v21 both

https://graph.facebook.com/fql?q=select is_verified page username=nokia nokia/?fields=is_verified

here documentation

https://developers.facebook.com/docs/reference/fql/page/

i want help in getting code repaired , need if have check 782 pagenames. presently have set links in mysql mytable table , trying out things. help here appreciated.

i believe verified status not in page table (anymore), not show in docs: https://developers.facebook.com/docs/graph-api/reference/v2.1/page

also, fql deprecated , not work in newer apps anymore, see changelog: https://developers.facebook.com/docs/apps/changelog

i think there no way check if page verified, unfortunately. way how may possible fql using app created before apr 21st, 2010. is, before v2.1 came out, without fql.

facebook facebook-graph-api excel-vba facebook-fql facebook-php-sdk

c# - pager style in skin gridview in asp.net -



c# - pager style in skin gridview in asp.net -

hi trying create skin gridview contain css files

every thing work fine pager number style on hover didn't alter color of font dont know why

skin code :

<asp:gridview runat="server" width="95%" autogeneratecolumns="false" skinid="gridblue" cellpadding="4" forecolor="#333333" horizontalalign="center" font-size="10" font-names="arial" borderwidth="2px" allowpaging="true" pagesize="5" allowsorting="true"> <headerstyle font-bold="true" forecolor="#faf6e0" height="30px" cssclass="gv_hd" /> <footerstyle font-bold="true" forecolor="#faf6e0" height="30px" cssclass="gv_ft" /> <rowstyle backcolor="#faf6e0" cssclass="gv_row" height="30px" /> <alternatingrowstyle backcolor="#ede0b9" cssclass="gv_row" height="30px"/> <pagersettings mode="numeric" /> <pagerstyle height="35px" cssclass="gv_pgr" verticalalign="middle" horizontalalign="center" /> <editrowstyle backcolor="#dfc987" verticalalign="middle" horizontalalign="center" cssclass="gv_slct" forecolor="#5f5f5f" /> <selectedrowstyle backcolor="#dfc987" verticalalign="middle" horizontalalign="center" font-bold="true" cssclass="gv_slct" forecolor="#5f5f5f" /> <emptydatatemplate> <center><h1 class="gv_mpty">no records found</h1></center> </emptydatatemplate> </asp:gridview>

css code :

.gv{text-align:center;} .gv_hd{height:22px;text-decoration:none;border:#5f5f5f solid 2px;background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #548975), color-stop(1, #37705a));background:-moz-linear-gradient(top, #548975 5%, #37705a 100%);background:-webkit-linear-gradient(top, #548975 5%, #37705a 100%);background:-o-linear-gradient(top, #548975 5%, #37705a 100%);background:-ms-linear-gradient(top, #548975 5%, #37705a 100%);background:linear-gradient(to bottom, #548975 5%, #37705a 100%);} .gv_hd a{text-decoration:none;} .gv_hd a:hover{text-decoration:underline;} .gv_hd a:active{text-decoration:underline;} .gv_ft{padding:10px;text-decoration:none;border:#5f5f5f solid 2px;background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #548975), color-stop(1, #37705a));background:-moz-linear-gradient(top, #548975 5%, #37705a 100%);background:-webkit-linear-gradient(top, #548975 5%, #37705a 100%);background:-o-linear-gradient(top, #548975 5%, #37705a 100%);background:-ms-linear-gradient(top, #548975 5%, #37705a 100%);background:linear-gradient(to bottom, #548975 5%, #37705a 100%);} .gv_row{text-align:center;color:#5f5f5f;padding:} .gv_row a{text-decoration:none;} .gv_row a:hover{text-decoration:underline;} .gv_pgr{color:#5f5f5f;padding:20px;background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #faf6e0), color-stop(1, #e7d6a1));background:-moz-linear-gradient(top, #faf6e0 5%, #e7d6a1 100%);background:-webkit-linear-gradient(top, #faf6e0 5%, #e7d6a1 100%);background:-o-linear-gradient(top, #faf6e0 5%, #e7d6a1 100%);background:-ms-linear-gradient(top, #faf6e0 5%, #e7d6a1 100%);background:linear-gradient(to bottom, #faf6e0 5%, #e7d6a1 100%);} .gv_pgr a{font-weight:bold;margin-top:10px;background-color:transparent;padding:4px 10px;text-decoration:none;border:1px solid #d9c074;} .gv_pgr a:hover{font-weight:bold;background-color:#548975;border:1px solid #d9c074;color:white;} .gv_pgr a:active{font-weight:bold;background-color:#548975;color:#faf6e0;border:1px solid #d9c074;} .gv_pgr span{background-color:#548975;color:#faf6e0;border:1px solid #d9c074;padding:4px 10px;} .gv_mpty{color:#5f5f5f;} .gv_slct a{text-decoration:none;text-align:center;} .gv_slct a:hover{text-decoration:underline;text-align:center;}

on hover font of pager didn't alter

when grid rendered, can utilize f12 check css, html. create sure row class want create highlight work.

c# css asp-classic

ios - In objective-c how to get characters after n-th? -



ios - In objective-c how to get characters after n-th? -

i have number represented string. longer 4 chars. need create new string 5th till end number.

for illustration if have 56789623, need have 9623 result (5678 | 9623).

how that?

p.s. suppose simple question, don't know how inquire google that.

nsstring *str = @"56789623"; nsstring *first, *second; if ([str length] > 4) { first = [str substringwithrange:nsmakerange(0, 4)]; sec = [str substringwithrange:nsmakerange(4, [str length] - 4)]; } else { first = str; sec = nil; }

ios objective-c

backbone.js - Error with multiple browserify bundles in backbone application -



backbone.js - Error with multiple browserify bundles in backbone application -

i want set vendor dependencies file seen in examples. problem modules depend on each other not find module depend on. error not find module underscore when included in html. here config:

class="snippet-code-js lang-js prettyprint-override">{ vendor: { src: [], dest: 'dist/vendor.js', options: { require: ['jquery', 'underscore', 'backbone', 'backbone.marionette', 'vis'] } }, dev: { options: { external: ['jquery', 'underscore', 'backbone', 'backbone.marionette', 'vis'] }, src: ["public/app/marionette_shim.js", "public/app/main.js"], dest: "dist/bundle.js" } }

i made repository it: https://github.com/blacksonic/browsebone after running grunt browserify:dev , grunt browserify:vendor , running index.js error: uncaught error: cannot find module '/home/blacksonic/workspace/browsebone/node_modules/underscore/underscore.js'

backbone.js marionette browserify

Why http post on android fails over 3g? -



Why http post on android fails over 3g? -

i have android application makes http post request server containing namevaluepairs, , works fine on wifi network, when utilize same http post on 3g, server gets http request empty body. here code request

list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>( 3); namevaluepairs.add(new basicnamevaluepair("name", params[0])); namevaluepairs.add(new basicnamevaluepair("dni", params[1])); namevaluepairs.add(new basicnamevaluepair("token", params[2])); url url = new url(url_server); httpurlconnection conn = (httpurlconnection) url .openconnection(); conn.setreadtimeout(30000); conn.setconnecttimeout(50000); conn.setrequestmethod("post"); conn.setdoinput(true); conn.setdooutput(true); outputstream os = conn.getoutputstream(); bufferedwriter author = new bufferedwriter( new outputstreamwriter(os, "utf-8")); writer.write(getquery(namevaluepairs)); writer.flush(); writer.close(); os.close(); conn.connect(); int responsecode = conn.getresponsecode(); bufferedreader in; if (responsecode == 404) in = new bufferedreader(new inputstreamreader( conn.geterrorstream())); else in = new bufferedreader(new inputstreamreader( conn.getinputstream())); string inputline; stringbuffer response = new stringbuffer(); while ((inputline = in.readline()) != null) { response.append(inputline); } in.close();

here code getquery method

private string getquery(list<namevaluepair> params) throws unsupportedencodingexception { stringbuilder result = new stringbuilder(); boolean first = true; (namevaluepair pair : params) { if (first) first = false; else result.append("&"); result.append(urlencoder.encode(pair.getname(), "utf-8")); result.append("="); result.append(urlencoder.encode(pair.getvalue(), "utf-8")); } homecoming result.tostring(); }

any thought why happens?

i have new info. made form send http post on web browser. form works great , sends body on 3g on windows phone , on wifi. when seek utilize chrome of android phone on 3g send http post, arrives empty, , if seek send http post 1 computer connected hotspot of android phone fails. when seek same computer connected wifi network, no problem @ all. weird. ideas?

my advice utilize google's volley library networking. pretty much best selection when comes networking on android. should not 3g problem. if is, problem might isolated one.

here have resources at(volley easy use):

https://developers.google.com/events/io/sessions/325304728 https://developer.android.com/training/volley/index.html

android http post 3g

node.js - How Do I Assign LDAP Password Via LDAPjs? -



node.js - How Do I Assign LDAP Password Via LDAPjs? -

i'm using ldapjs.

i got code sites:

var newuser = { cn: 'new guy', sn: 'guy', uid: 'nguy', mail: 'nguy@example.org', objectclass: 'inetorgperson', userpassword: ssha.create('s00prs3cr3+') }

the thing is, password saved octetstring, , can't used login. here knows how assign password using node (ldapjs preferred)?

try saving in plain text.

most ldap server implementations expect receive password in plain text , server encrypt password.

there dependancies on ldap server implementation , configuration.

-jim

oh, did not mention ad. active directory quite different. uses unicodepassword, not userpassword. password operations must on encrypted connection. , finally, password must "text value in utf-16". quotes required.

node.js ldap ldapjs

How to check if XML Data is valid for java XMLDecoder -



How to check if XML Data is valid for java XMLDecoder -

we serializing , deserializing info java xmlencoder , xmldecoder. can read object in illustration provided in javadoc of xmldecoder:

xmldecoder d = new xmldecoder(new bufferedinputstream(new fileinputstream("test.xml"))); object result = d.readobject(); d.close();

readobject parses input , returns object, if there one. if not throw arrayindexoutofboundsexception.

i wondering if there way validate contents provided xmldecoder (in illustration above file content of "test.xml") in advance xmldecoder can work it. (i aware set there setexceptionhandler method, handler called during parsing, done when calling readobject). or there "xmlencoder" dtd or xsd of sort?

java xml xml-serialization

ios - storyboard disabled my view -



ios - storyboard disabled my view -

for reason storyboard disabled view. can move elements can not see them.

any suggestions on how prepare this?

thanks

you have changed size class. "greyed out" views in navigator greyed out because defined under different size class.

change any-any , prob come back. if not seek other size classes.

ios iphone storyboard uistoryboard

c# - PDFsharp blank pages issue -



c# - PDFsharp blank pages issue -

i have been using pdfsharp merge 2 pdfs in 1 document , print it. seems working fine of time, whenever under heavy load (even making 4 simultaneous post requests) of printed pages blank. known issue pdfsharp , if is, have fix?

what testing?

i trying print 3 pages in duplex part of 1 request , have been testing 4 simultaneous calls. so, altogether have 12 pages.

result

i getting half of pages blank (so 5-6 pages).

another test did – did test made 100 requests (so printed 100 * 3 = 300 pages) , pages came out fine. however, making 1 request, waiting finish , 1 time finished made requests. seems suggest pdfsharp not able print documents correctly when used in asynchronous manner. however, part of application have create asynchronous requests waiting 1 request finish not option.

ps - using latest pdfsharp version 1.32

the generated (concatenated) pdf fine, there no blank pages in it. when printed blank pages.

pdfsharp not print pdf files @ all. cannot blame pdfsharp if printing fails under heavy load.

afaik pdfsharp not thread-safe (like libraries). if manipulate several pdf files @ same time, have utilize different threads - 1 thread each pdf file.

most utilize adobe reader print pdf files. may have serialize calls adobe reader.

c# printing pdfsharp

json - Error in twFromJSON(out) - R twitteR package -



json - Error in twFromJSON(out) - R twitteR package -

i have searched extensively online still unable find work-around next error whilst using 'twitter' bundle in r:

"error in twfromjson(out) : error: malformed response server, not json. cause of error twitter returning character can't parsed r. remedy wait long plenty offending character disappear searches (e.g. if using searchtwitter())."

it comes after running next code:

# clear used libraries rm(list=ls()) #set working directory setwd("c:/users/toshiba/google drive/programming/projects/hds/shiny/twitter") #load libraries library (twitter) library (rjsonio) library (dismo) library (maps) library (ggplot2) library (xml) load("twitter_credentials") registertwitteroauth(twitcred) ##############################start app######################################## start_date = '2014-10-10' end_date = tostring(as.date(start_date)+1) #search tweets containing ebola - goes 8 days including today ebolatweets <- searchtwitter("ebola", n = 1250, since=start_date, until=end_date, cainfo="cacert.pem") tweetframe <- twlisttodf(ebolatweets) # convert dataframe

is not possible somehow skip offending tweet instead of breaking loop?

any help much appreciated!

using current version of twitter (1.1.8) on github (which handles authentication much more simply), have no problems.

library(devtools) install_github('twitter', 'geoffjentry') library (twitter) setup_twitter_oauth(consumer_key='blah', consumer_secret='blah', access_token='blah', access_secret='blah') # keys , tokens apps.twitter.com start.date <- '2014-10-10' end.date <- as.character(as.date(start_date) + 1) ebolatweets <- searchtwitter('ebola', 1250, since=start.date, until=end.date) ebola <- twlisttodf(ebolatweets) head(ebola) # text # 1 rt @chillvibessonly: ebola: i'm in broom broom\n\namerica: out me country # 2 rt @rubensancheztw: #alucinante tve usa imágenes de united nations hospital alemán para ilustrar una info sobre el carlos iii http://t.co/5f5okmsjar ht… # 3 rt @danlpda: dejen de hablar del Ébola, me da miedo # 4 realiza republic of colombia estudios 3 viajeros por temor ébola: pese no presentar síntomas del virus los pasajeros... http://t.co/c5ijmgoqki # 5 que es eso del ebola? voy llorar # 6 rt @micamamonde: ebola no te tenemos miedo http://t.co/osglmamfnp # favorited favoritecount replytosn created truncated replytosid id replytouid # 1 false 0 <na> 2014-10-10 23:59:59 false <na> 520725464223326209 <na> # 2 false 0 <na> 2014-10-10 23:59:59 false <na> 520725464185581568 <na> # 3 false 0 <na> 2014-10-10 23:59:59 false <na> 520725463304785921 <na> # 4 false 0 <na> 2014-10-10 23:59:59 false <na> 520725463270821889 <na> # 5 false 1 <na> 2014-10-10 23:59:59 false <na> 520725463120244737 <na> # 6 false 0 <na> 2014-10-10 23:59:59 false <na> 520725463044734976 <na> # statussource screenname retweetcount # 1 <a href="http://twitter.com/download/android" rel="nofollow">twitter android</a> jamesekisses 684 # 2 <a href="http://twitter.com/download/android" rel="nofollow">twitter android</a> patillagrande 2059 # 3 <a href="http://twitter.com" rel="nofollow">twitter web client</a> ariifranciscovi 2 # 4 <a href="http://twitterfeed.com" rel="nofollow">twitterfeed</a> colnros 0 # 5 <a href="http://twitter.com/download/iphone" rel="nofollow">twitter iphone</a> zoevignieri 0 # 6 <a href="http://twitter.com" rel="nofollow">twitter web client</a> felicitasalbano 10 # isretweet retweeted longitude latitude # 1 true false <na> <na> # 2 true false <na> <na> # 3 true false <na> <na> # 4 false false <na> <na> # 5 false false <na> <na> # 6 true false <na> <na>

json r twitter

c++ - emscripten issue with ubuntu version "aborting from js compiler due to exception: unknown vector type | undefined" -



c++ - emscripten issue with ubuntu version "aborting from js compiler due to exception: unknown vector type <4 x i8> | undefined" -

i cannot compile current version of emscripten ubuntu repos

here error

http://pastebin.com/j5z0ztts

i suspect might because emscripten outdated in repos, why there no bug reports??

could help? cannot find updated information.

thanks in advance.

the reason because using /usr/bin/clang++ comes linux distribution.

this version not back upwards javascript backend. in order utilize emscripten, you have compile fastcomp (an llvm clang compiler javascript backend added)

if have not built fastcomp yet, emscripten won't work.

check out page installation instructions:

http://kripken.github.io/emscripten-site/docs/building_from_source/llvm-backend.html

if have built fastcomp, problem in emscriptenrc file, , path.

this how worked around issue:

i created file called emscriptenrc.sh did this:

export path=/home/mike/emscripten/fastcomp/build/master/bin:/home/mike/emscripten/fastcomp/build/master/include:/home/mike/emscripten/fastcomp/build/master/lib:$path

then after created file

i rebuilt ~/.emscripten configuration file calling

./emcc -v emscripten build directory -- seemed right version of clang registered...

now can go ahead , compile emcc

i suggest reading http://kripken.github.io/emscripten-site/docs/building_from_source/llvm-backend.html rest of documentation prior trying utilize emscripten.

c++ ubuntu emscripten

java - Why does this method not return whether the area is bigger than the parameter cubed? -



java - Why does this method not return whether the area is bigger than the parameter cubed? -

i'm working on minecraft plugin protect area. have area class created after player selects 3 blocks, , area class has method named "toobig", used detecting if area bigger if "block^3". problem method returns false.

public boolean toobig(int i) { boolean bo1, bo2, bo3; bo1 = math.abs(b1.getx() - b2.getx()) > i; bo2 = math.abs(b1.getz() - b2.getz()) > i; bo3 = math.abs(b1.gety() - b3.gety()) > i; homecoming bo1 && bo2 && bo3; }

b1, b2, , b3 block objects.

your utilize of variables inconsistent.

public boolean toobig(int i) { boolean bo1, bo2, bo3; bo1 = math.abs(b1.getx() - b2.getx()) > i; bo2 = math.abs(b1.getz() - b2.getz()) > i; bo3 = math.abs(b1.gety() - b3.gety()) > i; homecoming bo1 && bo2 && bo3; }

your algorithm wrong altogether. formula of calculating volume of rectangular cuboid region is

base (length * width) * height

where length, width , height of cuboid the distance maximum point through axis minimum point instead of randomly 2 points subtracting. right code getting area be:

public boolean toobig(int i) { int minx = math.min(math.min(b1.getblockx(), b2.getblockx()), b3.getblockx()); int maxx = math.max(math.max(b1.getblockx(), b2.getblockx()), b3.getblockx()); int miny = math.min(math.min(b1.getblocky(), b2.getblocky()), b3.getblocky()); int maxy = math.max(math.max(b1.getblocky(), b2.getblocky()), b3.getblocky()); int minz = math.min(math.min(b1.getblockz(), b2.getblockz()), b3.getblockz()); int maxz = math.max(math.max(b1.getblockz(), b2.getblockz()), b3.getblockz()); int area = (maxx - minx) * (maxy - miny) * (maxy - miny); }

to create work:

return area > math.pow(i, 3);

see also:

block.getblockx()

java minecraft bukkit

Converting C to mips assembly, Unaligned address error -



Converting C to mips assembly, Unaligned address error -

i'm doing assignment now, it's done maintain getting error saying

unaligned address in inst/data fetch: 0x10010016

at line:

lw $t3,0($a1) # value of b[k] , save t3

i search online , find reply saying have utilize .align 2 prepare this, doesn't work problem.

can please give me hint on this, literally spend 6 hours on this..

thank much

here code:

# -> $a0 # b -> $a1 # n -> $a2 # j -> $a3 # k -> $s0 # -> $t0 .data .align 2 arra: .word 1,2,7,4,5 arrb: .word 3,4,7,2,9 .text la $a0, arra # have array a[] = { 1,2,7,4,5} la $a1, arrb # have array b[] = {3,4,7,2,9} addi $a2,$zero,0 # n = 0 addi $a2,$zero,3 # n = 3 addi $a3,$zero,0 # j = 0 addi $a3,$zero,3 # j = 3 addi $s0,$zero,0 # k = 0 addi $s0,$zero,2 # k = 2 g: addi $sp, $sp, -24 sw $ra, 20($sp) # save $ra on stack sw $s0, 16($sp) # save $s0 (k) on stack sw $a0, 12($sp) # save a0(a) on stack sw $a1, 8($sp) # save a1(b) on stack sw $a2, 4($sp) # save a2(n) on stack sw $a3, 0($sp) # save a3(j) on stack move $a3,$s0 # set j = k jal f # f(a,b,n,k,k) add together $a1,$a1,$s0 # homecoming address of b[k] lw $t3,0($a1) # value of b[k] , save t3 add together $v0, $t3,$zero # homecoming value lw $a3,0($sp) lw $a2,4($sp) lw $a1,8($sp) lw $a0,12($sp) lw $s0,16($sp) lw $ra,20($sp) addi $sp,$sp,24 jr $ra f: bne $a2, $zero, else # if (n != 0) go else addi $t0, $zero, 1 # set $t0 = 1 sw $t0, 0($a1) # set b[0] = 1 addi $t0, $zero, 1 # set $t0 = 1 sw $t0, 0($a1) # set b[0] = 1 addi $t0, $zero, 1 # set = 1 loop forloop: slt $t1,$s0, $t0 # if k < i, end loop, utilize $t1 store boolean value bne $t1, 1, forloopdone add together $a1, $a1, $t0 # b[i] address add together $t2,$zero,$zero sw $t2, 0($a1) # b[i] = 0 addi $t0, $t0, 1 # = + 1 j forloop else: bne $a3, $zero, updatej # test if (j == 0), if not, j = j -1 j iteratef updatej: addi $a3, $a3, -1 # j = j -1 j iteratef iteratef: addi $a2, $a2, -1 # iterate, n = n - 1 j f # f(b, a, n-1, j_update, k) bne $a3, $zero, forloop1ini # if (j != 0), go for_loop1_ini lw $a0, 0($a0) # there might sth wrong here sw $a1, 0($a1) # set b[0] = a[0] addi $a3, $a3, 1 # j++ forloop1ini: addi $t0, $a3, 0 # set = j forloop1start: slt $t1,$s0, $t0 bne $t1, 1, forloop1done add together $a0, $a0, $t0 # a[i] address lw $t1, 0($a0) # t1 = a[i] lw $t2, -4($a0) # b[i] add together $a1, $a1, $t0 # b[i] address add together $t1, $t1, $t2 # t1 = a[i-1] + a[i] sw $t1, 0($t1) # b[i] = a[i-1] + a[i] addi $t0, $t0, 1 # i++ j forloop1start forloop1done: nop forloopdone: nop jr $ra

your problem not taking business relationship size of each element of array. each element occupies 4 bytes. therefore, instead of issuing

add together $a1,$a1,$s0 # homecoming address of b[k]

you should multiply index 4 (which size of element) effective offset:

sll $s1, $s0, 2 # compute effective offset (i.e. multiply index 4) add together $a1,$a1,$s1 # homecoming address of b[k] lw $t3,0($a1) # value of b[k] , save t3

c assembly mips