Posts

Showing posts from February, 2014

java - JFrame window doesn't show up? -

i'm building space invader style game in java. first do, i'm trying make sense of it. main requirement runs on desktop. now i'm trying use jframe this, isn't letting me want do. when run app, show java "app" running in dock (i run osx), actual jframe window doesn't show up. this how create window: public gildeinvaders() { add(new panel()); settitle("gilde opleidingen space invaders"); setdefaultcloseoperation(exit_on_close); setsize(500, 500); //setsize(gildeinvaders.getconfiguration().getint("game.width"), gildeinvaders.getconfiguration().getint("game.height")); setlocationrelativeto(null); setvisible(true); setresizable(true); } public static void main(final string[] args) throws ioexception { new gildeinvaders(); } the panel i'm initiating instance of jpanel, think right approach: public class panel extends jpanel implements runnable { // lot of variables her...

sql server - How to get the message of RaiseError of a procedure in another procedure -

i have 2 procedures proc_a , proc_b . in both procedure transaction managed. proc_b throws error calling raiseerror , passes message in condition raiserror ('initiator inactive', 16, 1, 'approve transaction'); i executing (calling) proc_b in proc_a . want error message thrown proc_b in proc_a . how can that? try this: create procedure dbo.testa begin raiserror ('initiator inactive', 16, 1, 'approve transaction'); end; go create procedure dbo.testb begin begin try exec dbo.testa; end try begin catch select error_message(); end catch end; go exec dbo.testb; go drop procedure dbo.testb; drop procedure dbo.testa;

windowlistener - Cannot downcast an Object into Frame in Java Window Event handling -

i learning basic event handling in java. i working on frame closing method (implemented windowlistener). understand getsource() call returns object actual event taking place. when downcast window, works fine when downcast 1 more level below (to frame), doesn't work , gives error- frame cannot resolved type in main class, extending frame. @override public void windowclosing(windowevent e) { object objsource= e.getsource(); //window objwindow = (window)objsource; - works fine frame objwindow = (frame)objsource; //- why doesn't work objwindow.dispose(); } unfortunately import java.awt.frame; package not imported in code hence giving error in closing frame window. above code works both frame , window call.

c# - Async methods return null -

if try mock type containing async method such : interface foo { task<int> bar(); } then mock's bar method returning null. guess moq choosing default(task<int>) default return value method, indeed null . moq should rather choose task.fromresult(default(int)) default value. can force moq make async methods returning non-null tasks ? if interested, made extension class makes async methods stubing less verbose : public static class setupextensions { public static ireturnsresult<tmock> returnstask<tmock, tresult>( isetup<tmock, task<tresult>> setup) tmock : class { return setup.returns(() => task.fromresult(default(tresult))); } public static ireturnsresult<tmock> returnstask<tmock, tresult>( isetup<tmock, task<tresult>> setup, tresult value) tmock : class { return setup.returns(() => task.fromresult(value)); } public static ireturnsr...

javascript - Angular ng-bind-html - prevent execution of JS code -

i have problem ng-bind-html directive. i email html data external services (not trusted), may happen receive <script> tag inside message body. don't want execute js code on page. using ng-bind-html directive this. i created example , problem alert() function executed. how deny this? var app = angular.module('myapp', ['ngsanitize']); app.controller('mainctrl', function ($sce, $scope) { $scope.text = " <script>alert(222)</script> <script>alert(222)</script>"; }); <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myapp" ng-controller="mainctrl"> <div ng-bind-html="text"></div> </div> https://jsfiddle.net/suvroc/0c0ee472/8/ since have referenced old version of angularjs, prevented getting proper errors, difficult interpret. tried in similar...

jquery - Node.js and Socket.io not working on this Example -

can please take @ following code , let me know doing wrong on that? running node.js + express + socket.io on ubuntu 12.4 trying create simple push function. server working cant see div id "status" content on page , apparently function not running! thanks , comment in advance , sorry long post! here app.js file /** * module dependencies. */ var express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = require('http') , path = require('path'); var app = express(); // environments app.set('port', process.env.port || 3000); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyparser()); app.use(express.methodoverride()); app.use(app.router); app.use(express.static(path.join(__dirname, 'public'))); //...

How to read an element in an array and see if it matches with a target string despite double letters -

so i'm trying find amount of times string present in array. if had array of {ab, abbbb, aaaabbb, ac} , had target string of ab, frequency of string ab 3 in array. program disregard repeating abbbb , aaaabbbb , read these element ab. have code changing duplicated sequence non-repeating sequence , comparing target if statement, it's not working , i'm not sure why. `it returning 0 value, when there should number. this code: public static int findfreqwithmutations (string target, string [] arr) { int count=0; (string s:arr) { string ans= ""; (int i=0; i<s.length()-1; i++) { if (s.charat(i) != s.charat(i+1)) { ans= ans + s.charat(i); } } if (ans == target) { count++; } } return count; } ` i'm going make assumption java context clues. looks you're getting wrapped in searching str...

c# - MVC Login Failure using ReturnURL -

my goal return 401 error login controller. fired stock mvc site built in .net membership provider. happening is, when return 401 controller, getting http://xxxxx/account/login?returnurl=xxxx dont want redirect happen, want controller return 401 can handle on client side. issue appreciated. all of code stock membership provider except login method on account controller [httppost] [allowanonymous] public async task<actionresult> login(loginviewmodel model) { if (!modelstate.isvalid) { return view(model); } // doesn't count login failures towards account lockout // enable password failures trigger account lockout, change shouldlockout: true var result = await signinmanager.passwordsigninasync(model.email, model.password, model.rememberme, shouldlockout: false); switch (result) { case signinstatus.success: return new httpstatuscoderesult(200); case signinstatus.lockedout: return view("l...

Multiple subdomain contexts for drupal -

the project working on wants split site regions via subdomains, example: usa.domain za.domain ke.domain each subdomain have it's own content (news, about, etc), , main domain site show content (news) sub domains. what best way achieve using drupal? able use drupal 8 this? i managed figure out. i ended installing domain module works expected solution work. once have installed, , set few domain records in configuration adding content specific domains simple clicking checkbox. a cool note menu structure plays along nicely module too, although might clever drupal. i used drupal 8 , though module doesn't have official release yet, works perfectly.

From Eclipse to PhpStorm: Cannot find declaration to go to -

i switched eclipse phpstorm 10. in eclipse can go class $x = "xclass"; ctrl + left mouse click on "xclass" . in phpstrom message : cannot find declaration go to . i'm looking since more 1 hour run. the problem use kind of declaration ( $x = "xclass"; ) often. foo.php <?php namespace foo; class foo { private $bar = 'foo'; public function getbar() { return $this->bar; } } index.php <?php include 'foo.php'; use foo\foo; $class = 'foo\foo'; $foo = new $class(); echo $foo->getbar(); navigation on $class = 'foo\foo'; won't work default. can cropy class , use ctrl+n , ctrl+v use phpstorm's classsearch . to able use ctrl + left mouse have install navigate literal . file > settings > plugins > browse repositories > search > navigate literal if using proxy have change settings before being able browse repositories.

angular - Renderer multiple selectRootElement Issue (with plnkr provided) -

Image
i trying use renderer.selectrootelement elements component, described here . everything works fine, unless select 1 element ( plnkr ). as can see, have created component: export class examplecomponent implements oninit{ @input() start: any; @input() end: any; constructor(public _renderer:renderer){ }; ngonchanges(){ } ngoninit(){ console.log("ng on chan start date",this.start); console.log("ng on init end date",this.end); var container = this._renderer.selectrootelement('.container'); console.log(container); var inner1 = this._renderer.selectrootelement('.inner1'); console.log(inner1); var inner2 = this._renderer.selectrootelement('.inner2'); console.log(inner2); } } when try run this, have error of : exception: selector ".inner1" did not match elements in [{{exampledata.end}} in mainviewcomponent@3:65] (h...

indexing - How to delete index in Neo4j1.9.9? -

question1: there way delete node indexes except using neo4j rest api? question2: neo4jtemplate.delete(t entity) delete node. delete node indexes well? question3: use following cypherto delete node , relationships. delete node indexes well? start node=node({nodeid}) match node-[r]-() delete r, node thanks. do mean delete node index or entire index? either way, yes, can remove node indexusing java api if have access embedded api ( http://neo4j.com/docs/1.9.9/indexing-remove.html ). deleting entire index possible using theindex.delete() sdn (<4.x) remove node index. not delete entire index. no, must manually remove node index.

c# - Razor declarative helper passing model as parameter -

how can pass model custom html helper parameter? currently have following file @helper labelfor(string label, string hint) { <label for="@label">@label</label> <span class="mif-info" data-role="hint" data-hint-background="bg-blue" data-hint-color="fg-white" data-hint-mode="1" data-hint-position="top" data-hint="@hint"></span> } which called with @myhelpers.labelfor(html.displaynamefor(model => model.title).tostring(), "description") how can simplify @myhelpers.labelfor(model => model.title, "description") i guess, can achieve same using mvc displaytemplates. did try path?

javascript - Conditional showing in Angular + ionic: Show if Id has specific value -

i trying show block in angular if id of specific value. i tried in following code ng-if="{{what.nid}} === 12" , didn't work. this tried:- <ng-map zoom="11" center="[40.74, -74.18]" ng-if="{{what.nid}} === 12"> <marker position="[40.74, -74.18]" /> <shape name="circle" radius="400" center="[40.74,-74.18]" radius="4000" /> <control name="overviewmap" opened="true" /> </ng-map> ng-if accepts expression, using {{}} inside of not necessary, use ng-if="what.nid === 12"

java - Name Reversing in strings -

write method lastnamefirst takes string containing name such "harry smith" or "mary jane lee", , returns string last name first, such "smith, harry" or "lee, mary jane". im supposed check against http://wiley.code-check.org/codecheck/files?repo=bjlo2&problem=05_02 i post string firstname = name.substring(0, name.indexof(" ")); string lastname = name.substring(name.indexof(" ")); string cname = lastname + ", " + firstname; if ( lastname == " " ) { cname = firstname; } return cname; i 0/4 everytime please im lost. it might simpler create array using split function of string class, join them: string cname = string.join(", ", collections.reverse(arrays.aslist(name.split(" ")))); string.join in java 8 believe, if you're not using 8 can use following: string[] names = name.split(" "); string cname = names[1...

sorting - Does Python bytearray use signed integers in the C representation? -

i have written a small cython tool in-place sorting of structures exposing buffer protocol in python. it's work in progress; please forgive mistakes. me learn. in set of unit tests, working on testing in-place sort across many different kinds of buffer-exposing data structures, each many types of underlying data contained in them. can verify working expected cases, case of bytearray peculiar. if take granted imported module b in code below performing straightforward heap sort in cython, in-place on bytearray , following code sample shows issue: in [42]: #numpy array out[42]: array([ 9, 148, 115, 208, 243, 197], dtype=uint8) in [43]: byt = bytearray(a) in [44]: byt out[44]: bytearray(b'\t\x94s\xd0\xf3\xc5') in [45]: list(byt) out[45]: [9, 148, 115, 208, 243, 197] in [46]: byt1 = copy.deepcopy(byt) in [47]: b.heap_sort(byt1) in [48]: list(byt1) out[48]: [148, 197, 208, 243, 9, 115] in [49]: list(bytearray(sorted(byt))) out[49]: [9, 115, 148, 197, 208, 243...

ruby - NMatrix division of arrays with different shapes -

i have nmatrix array this x = nmatrix.new([3, 2], [3, 5, 5, 1, 10, 2], dtype: :float64) i want divide each column maximum value along column. using numpy achieved this y = np.array(([3,5], [5,1], [10,2]), dtype=float) y = y / np.amax(y, axis = 0) but nmatrix throws error when try this x = x / x.max left- , right-hand sides of operation must have same shape. (argumenterror) edit i'm trying follow this tutorial . , scale input, tutorial divides each column maximum value in column. question how achieve step using nmatrix. my question how achieve same nmatrix. thanks! a generic column-oriented approach: > x = nmatrix.new([3, 2], [3, 5, 5, 1, 10, 2], dtype: :float64) > x.each_column.with_index |col,j| m=col[0 .. (col.rows - 1)].max[0,0] x[0 .. (x.rows - 1), j] /= m end > pp x [ [0.3, 1.0] [0.5, 0.2] [1.0, 0.4] ]

php - Two forms submit only one button javascript and open popup window -

Image
this javascript <script type="text/javascript"> $(document).ready(function () { $("#submitbutton").click(function () { var $form1 = $("#form1"); $.post($form1.attr("action"), $form1.serialize(), $('form[name="formsub"]').each(function () { var $form = $(this); $.post($form.attr("action"), $form.serialize(), }) }); }); </script> <form id="form1" action="exam_fee_update1.php" method="post"> // code </form> <form id="form2" action="exam_fee_update1.php" name= "formsub" method="post"> // code </form> when submit 2 forms data insert want after submit of 2 forms open popup window , display submit details.. me. jquery $.post throws callback once request done: after each form submitted disp...

PHP Curl request with http authentication and POST -

i'm having trouble trying code running. i'm trying use curl post , http authentication i'm unable work. i'm using following code: public function index(){ $call = $this->call("url_to_call", $this->getcredentials(), $this->getjson()); } private function getcredentials(){ return "api_key_here"; } private function getjson(){ return $json; } private function call($page, $credentials, $post){ $url = "url_to_call"; $page = "/shipments"; $headers = array( "content-type: application/vnd.shipment+json;charset=utf-8", "authorization: basic :" . base64_encode($credentials) ); $ch = curl_init(); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_timeout, 60); curl_setopt($ch, curlopt_httpheader, $headers); // apply post our curl call curl_setopt($ch, curlop...

sqlite - Update records based on other records in the same table -

Image
i have table (pump_table) pump flow (pump_flow), pump station names (name) , sub name (sub_name) information, presented in table extract below: i transfer pump_flow value sub_name pump 1 pump_flow field sub_name; pump 2, pump 3,... pump n, of pump station having same name. the script i've created looks this: update [pump_table] set [pump_flow] = ( select [pump_flow] [pump_table] [name] = [name] , [sub_name] = "pump 1" ) [name] = [name] , [sub_name] != "pump 1" ; it keeps on returning value pump_flow field of first record in table has 'pump 1' in sub_name field. the filter name = name matches. to refer value in table, must use table name. if other table instance of same table, must rename 1 table: update pump_table set pump_flow = (select pump_flow pump_table p1 p1.n...

java - How to handle multiple spinner selected item comparison? -

i trying app display either text or image when 2 spinners selected values equal each other. public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); spinner sp1 =(spinner)findviewbyid(r.id.sp1); string txtfromspinner1 = sp1.getselecteditem().tostring(); spinner sp2 = (spinner)findviewbyid(r.id.sp2); string txtfromspinner2 = sp2.getselecteditem().tostring(); if (txtfromspinner1.equals(1)&& txtfromspinner2.equals(2)){ textview textelement = (textview)findviewbyid(r.id.txresult); textelement.settext("3"); } } } try this: spinner sp1 =(spinner)findviewbyid(r.id.sp1); spinner sp2 = (spinner)findviewbyid(r.id.sp2); textview textelement = (textview)findviewbyid(r.id.txresult); button showresult = (button)fi...

javascript - OnClientClick causes webpage refresh -

i have asp.net button on webpage: <asp:button id="tickbutton" runat="server" onclientclick="selectsome()" text="tick" /> and javascript function: function selectsome() { var id = document.getelementbyid("ctl00_contentplaceholder1_txtselectsome").value; if (isnan(id)==false) { var frm = document.forms[0], j = 0; (i = 0; < frm.elements.length; i++) { if (frm.elements[i].type == "checkbox" && j < id) { frm.elements[i].checked = true; j++; } } } else { alert("you must enter number.") } return false; } when click on button; javascript function runs , webpage refreshes. why webpage refresh? according link; returning false should stop webpage refreshing: stop page reload of asp.net button use r...

html - PHP- Validation message under text field -

new this. validation code works perfectly. however, trying message echo under each text field. i have tried changing echo error message (changing echo $c_errorerr/$c_pass1err ) , echo $c_errorerr/$c_pass1err next input field , wrapping in span class. however, method stops validation messages working. suggestions html <!-- <div id="first">--> <input type="email" id="email" name="email" placeholder="email address" value='' required> <br> <figure> <input class ="login-field" type="password" id="pass1" name="pass1" value="" placeholder="password" maxlength="30" required><!--<span class="error"><?php //echo $c_pass1err; ?></span>--> <input class =...

list - Variable assignment and modification (in python) -

Image
when ran script (python v2.6): a = [1,2] b = a.append(3) print >>>> [1,2,3] print b >>>> [1,2,3] i expected print b output [1,2] . why did b changed when did change a? b permanently tied a? if so, can make them independent? how? memory management in python involves private heap memory location containing python objects , data structures. python's runtime deals in references objects (which live in heap): goes on python's stack references values live elsewhere. >>> = [1, 2] >>> b = >>> a.append(3) here can see variable b bound same object a . you can use is operator tests if 2 objects physically same, means if have same address in memory. can tested using id() function. >>> b >>> true >>> id(a) == id(b) >>> true so, in case, you must explicitly ask copy . once you've done that, there no more connection between 2 distinct list objects. >>...

unity3d - unity 2D (look at) object disappears -

i have moving object want @ target it's moving towards, here code: void update () { transform.lookat( target.transform.position); } the problem object @ target while moving, disappears screen, it's there @ same :/ edit: since game in 2d view, object kinda turns sideways, when talking disappearing still there, happening turns , faces object it's looking at. hope makes things more clearer. check sorting layer order of 2d object. if has order less order of other object disappear behind it. can check in detail link. https://unity3d.com/learn/tutorials/modules/beginner/2d/sorting-layers

How enable "Individual column searching (select inputs)" in Jquery datatables? -

i trying achieve individual column searching (select inputs) i loading data jquerydatatable via ajax call. but select dropdown per column not showing up. my code below <script type="text/javascript" language="javascript"> $(function () { $('#mytable').datatable({ "bserverside": true, "sajaxsource": "@url.action("getajaxdata", "home")", "bprocessing": true, "searching": false, "aocolumns": [ { "sname": "first name" }, { "sname": "last name" }, { "sname": "nationality" }, { "sname": "date of birth" } ], "initcomplete": function () { this.api().columns().every(function () { ...

android - Permission Denial Issue even after adding the required permission in manifest file -

here error log: permission denial: starting intent { act=android.settings.wifi_display_settings cmp=com.android.settings/.settings$wifidisplaysettingsactivity } requires com.android.setting.permission.allshare_cast_service @ android.os.parcel.readexception(parcel.java:1472) @ android.os.parcel.readexception(parcel.java:1426) @ android.app.activitymanagerproxy.startactivity(activitymanagernative.java:2329) @ android.app.instrumentation.execstartactivity(instrumentation.java:1426) @ android.app.activity.startactivityforresult(activity.java:3513) @ android.app.activity.startactivityforresult(activity.java:3474) @ android.app.activity.startactivity(activity.java:3716) @ android.app.activity.startactivity(activity.java:3684) manifest file permission: <uses-sdk android:minsdkversion="17" /> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.setting.permission.allshare_cast_service" ...

Android expand animation on Button click -

Image
i try make tests ux , animation. want @ click on button expand until button has size of parent layout. here simple interface : i succeed create own animation, it's simple class takes begin x, end x, begin y , end y. here class : import android.view.view; import android.view.animation.animation; import android.view.animation.transformation; public class expandanimation extends animation { protected final view view; protected float pervalueh, pervaluew; protected final int originalheight, originalwidth; public expandanimation(view view, int fromheight, int toheight, int fromwidth, int towidth) { this.view = view; this.originalheight = fromheight; this.originalwidth = fromwidth; this.pervalueh = (toheight - fromheight); this.pervaluew = (towidth - fromwidth); } @override protected void applytransformation(float interpolatedtime, transformation t) { view.getlayoutparams().height = (int) (originalhe...

python - How to convert each digit in an int to hex -

i want convert integer variable hex value digit wisely. means, 499, need output of "/x04/x09/x09". please help. use string formatting functions: n = 499 print("".join("\\x{0:02x}".format(int(i)) in str(n))) prints \x04\x09\x09

how to use scanf in for loop as a condition in c programming languange -

Image
as in following codes did not understand usage of scanf in for loop. how can use or when use it? can me ? #include<stdio.h> int main() { char word[10]; int count[10] = {0}; printf("enter text:\n"); for(scanf("%s", word); word[0] != '.'; scanf("%s", word)) { int len; for(len = 0; word[len] != '\0'; len++); count[len]++; } int i; for(i = 1; < 10; i++) { printf("there %d words %d letters\n", count[i], i); } a for loop has 3 parts. first part executed first, , never executed again. doing for(scanf("%s", word); word[0] != '.'; scanf("%s", word)) { is equivalent to scanf ("%s", word); for(; word[0] != '.'; scanf("%s", word)) { if you're not understanding how for loop works, see flowchart: ( source ) if want tutorial, see this tutorial on loops .

ruby - Rails 4 ODBC Connection -

i've been using ruby connect external ibm db2 odbc database using third-party driver. however, when try same thing in rails, error thrown: im003 (160) specified driver not loaded due system error 182 i've tried these gems (odbc-rails uses development.rb, same result): gem 'rails-dbi' gem 'dbd-odbc' gem 'ruby-odbc' gem 'odbc-rails' here line of code throws error: dbi.connect("dbi:odbc:my_odbc_connection", username, password) i can run line of code @ ruby console, not @ rails console same ruby version. using windows 8.1 i have given full permissions folder containing library. tested running commands in administrative mode cli. i have looked rails guides see if there security feature blocking driver being loaded in rails , seems issue resides rails somewhere. if has ideas, grateful.

excel - If column X contains value, add column Y value to worksheet range -

i'm sure has been answered elsewhere, require specific development of required vba code. the scenario: membership database (worksheet "members") contains members details including whether "active" or not. i trying make program down column c; if cell contains "active" copy corresponding column value 2nd worksheet template range, "active members". any suggestions appreciated. kind regards. this copy active users second worksheet called active members sub copyactive() dim counter, rowno long counter = 1 rowno = 1 until sheets("members").cells(counter, 1) = "" if ucase(sheets("members").cells(counter, 3)) = "active" sheets("active members").cells(rowno, 1) = sheets("members").cells(counter, 1) rowno = rowno + 1 counter = counter + 1 end if counter = counter + 1 loop end sub

python - How can I fix that line re.sub -

i want pass variable re.sub there error , can't figure out how fix it? preset_name = "preset " data = re.sub("name=\"%s[^]]*/select", lambda x:x.group(0).replace('selected',''), html) % preset_name here error: typeerror: not arguments converted during string formatting data =re.sub("name=\"%s[^]]*/select" % preset_name, lambda x:x.group(0).replace('selected',''), html) % operates on string

ios - Cannot press "next" button on TestFlight external test -

Image
on testflight external testing, went follows, not proceed further because "next" button diabled. 1) added build test 2) selected build test 3) input "what test" & "beta app description" any idea how enable "next" button? i solved below: go build list (testflight builds > ios) choose newly uploaded version fill in fields go external testing select version fill in form next button got enabled!

Reuse same sprite node within multiple scenes in sprite kit using Swift -

i create sprite node in gamescene following. reuse createnodea1 or nodea1 in other skscene . how can that? import spritekit class gamescene: skscene { var nodea1: sknode! required init?(coder adecoder: nscoder) { super.init(coder: adecoder) } override init(size: cgsize) { super.init(size: size) // add sprite node scene nodea1 = createnodea1() addchild(nodea1) } } // create dot 1 func createnodea1() -> sknode { let spritenode = sknode() spritenode.position = cgpointmake(cgrectgetmidx(self.frame)/1.5, cgrectgetmidy(self.frame)/2.0) let sprite = skspritenode(imagenamed: "dot_1") sprite.zposition = 3.0 sprite.name = "a1_broj" spritenode.addchild(sprite) return spritenode } } there few ways this. you subclass other scenes subclass of scene loadnode function gives scenes access function. i asked question last year swift multiple level scenes another way might bit easier if n...

javascript - Switch multiple div position jquery every x seconds -

i need switch many div (#box) positions every 3 seconds using javascript or jquery. thank in advance. here html code: <div class="container"> <div class="box"> <div class="molecule img"> </div> <p>molecule 1 description</p> </div> <div class="box"> <div class="molecule img"> </div> <p>molecule 2 description</p> </div> <div class="box"> <div class="molecule img"> </div> <p>molecule 3 description</p> </div> </div> you can use setinterval() , following example switches div , change it's text color. var $div = $('.box'), index = 0, length = $div.length; setinterval(function() { $div.css('color', 'black').eq(index).css('color', 'red'); inde...

c - Message receive program only printing every other message -

i have implemented 2 programs section 7.6 of http://beej.us/guide/bgipc/output/html/multipage/mq.html . i have extended there 2 receiving programs , 1 goes determined message type. the problem arises in receiving program, b , c. supposed print out messages entered program everytime, print messages every other time. this message sent, reads first 6 chars , if urgent sets the message type. buf.mtype = 2; while(fgets(buf.mtext, sizeof buf.mtext, stdin) != null) { int len = strlen(buf.mtext); strncpy(typetest, buf.mtext, 6); if(strncmp(typetest, "urgent", 6) == 0){ buf.mtype = 1; } printf("this message %s \n", buf.mtext); /* ditch newline @ end, if exists */ if (buf.mtext[len-1] == '\n') buf.mtext[len-1] = '\0'; if (msgsnd(msqid, &buf, len+1, 0) == -1) /* +1 '\0' */ perror("msgsnd"); } this message received, if sta...

ios - Tried to pop to a view controller that doesn't exist -

i'm trying return previous view controller i'm running issues (to understanding) shouldn't happening. a short description of i'm trying do: have 4 view controllers: a, b, c , d. basic ui flow -> b -> c -> d. after finishing work in c, want return b. my code: let viewcontrollerarray = self.navigationcontroller?.viewcontrollers for(var i=0;i<viewcontrollerarray?.count;i++){ if(viewcontrollerarray![i].iskindofclass(inventorylistviewcontroller)){ self.navigationcontroller?.poptoviewcontroller(viewcontrollerarray![i], animated: true) } } this works fine if b still exists on navigationcontroller's stack. if b has been removed stack (due memory-related reasons) gives me tried pop view controller doesn't exist error (obviously). thing i'm confused shouldn't if-statement prevent poptoviewcontroller method getting called if b doesn't exist o...

ios - Where to remove observer for NSNotificationCenter in Objective-C -

i dont want add observer in viewdidappear , remove in viewdiddisappear.will not serve case. i have tried doing in dealloc. my root vc in navcontroller.then second vc pushed in navcontroller, addobserver notifications sent rootvc.the problem when pop secondvc dealloc not called or may somtimes not called alltogether. - (void)viewdidload { [super viewdidload]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(newmessagesnotification:) name:_newmessagenotificationlistenername object:nil]; } - (void)newmessagesnotification:(nsnotification *)notification { //some implementation } if not want remove in viewdiddisapear think should remove right after called navigationcotnroller pop methode. think can't tell exact moment when should remove because don't know when want remove , why isn't in viewwilldisapier or in viewdiddisapier.

php - Wordpress Trying to use get_title() in loop array as the category name -

on wordpress page template im trying use get_title() in arguments array loop cant return posts. this im to; <?php $args = array( 'category_name' => 'the_title();' ); $the_query = new wp_query( $args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class="entry"><?php the_content(); ?></div> <?php endwhile; else: ?> <p>sorry, there no posts display</p> <?php endif; ?> im unable posts return on page unless manually enter slug category want use not ideal page slug same post category slug. my logic behind dont want have individual page templeate each page different cat end hundreds of page templetes. any appreciated cheers jon you're passing the_title(); string ' ' . also, the_title() gets title of object in...

Installshield Include redistributable with program setup exe -

just got installshield pro , i've created setup singleimage executable. i need include visual c++ 2005 sp1 redistributable within setup. i've ticked redistributable want in menu under 'application data'. i've right clicked , changed 'build location' 'extract setup.exe'. however, when build setup, has folder called 'issetupprerequisites' has vc++ redistributable in it. is there anyway can incorporate in single exe installer? if remove folder downloads redistributable internet. thanks yes. can include contents of issetupprerequisites folder inside exe changing location in setup.exe tab of releases view. can change on .prq .prq basis right clicking prerequisite in redistributables view , selecting location there.

Duplicating an array 1:1 in zsh -

although seems simple, there small nuance obvious solution. the following code cover situations: arr_1=(1 2 3 4) arr_2=($arr_1) however, empty strings not copy over. following code: arr_1=('' '' 3 4) arr_2=($arr_1) print -l \ "array 1 size: $#arr_1" \ "array 2 size: $#arr_2" will yield: array 1 size: 4 array 2 size: 2 how go getting true copy of array? it " array subscripts " issue, specify array subscript form select elements of array ($arr_1 instance) within double quotes: arr_1=('' '' 3 4) arr_2=("${arr_1[@]}") #=> arr_2=("" "" "3" "4") each elements of $arr_1 surrounded double quotes if empty. a subscript of form ‘[*]’ or ‘[@]’ evaluates elements of array; there no difference between 2 except when appear within double quotes. ‘"$foo[*]"’ evaluates ‘"$foo 1 $foo[2] ..."’, whereas ‘"$foo[@]"’ ev...

python 3.x - Removing second element of a list -

i working on code has list of integers such list1 = [1,2,3,4,5] , want print out 1 3 4 5 print out "new list" without second element. you can use indexes slicing (i assume want keep original list intact): >>> list1[0:1] + list1[2:] [1, 3, 4, 5] so in general skip i element (when 0 included): >>> list1[0:i] + list1[i+1:]

android - Dynamically adding rows on top of items and when task is finished, the added rows should be removed in recyclerview -

please don't mark duplicate. i trying create recyclerview in displaying data server. process working fine. now, want post data server. when button clicked pop window appears in selecting image or video text post server. after uploading server showing result, but, want show user progress of uploading image or video in recyclerview on top of items. user can post number of posts , every single post there should row in recyclerview , after posting successfully, particular row should removed recyclerview.

iphone - iScroll on div with dynamically added images -

i'm using phonegap create iphone application. i'm trying use iscroll zoom functionality. i'm having problem cannot scroll until zoom in on div. once un-zoom div it's automatically scrolled top. i've looked @ following 2 threads thought neither solution worked situation. thread 1 thread i have div has images added after ajax call. created div wrapper around should zoomable. code followed <div id = 'zoom-wrapper'> <div id="historyresponse"></div> </div> i have js function called showhistory() has ajax call. on success images added historyresponse div using .append(). after reading 2 threads mentioned above tried added things myscroll.refresh() or destroying recreating myscroll @ end of js function showhistory() nothing fixed problem. are there other things can try fix problem? thanks in advance! try pass option checkdomchanges:true . helped me once sort out similar problem when myscroll.refre...

Disemvowel in swift -

we can remove of vowels string in javascript this: function disemvowel(str) { str = str.replace(/([aeiouaeiou])/g, '') return str; } i implement same function in swift, curious how can write shorter javascript? func disemvowelthestring(string: string) -> string { var replacedstring = string let vowels = ["a", "e", "i", "o", "u", "a", "e", "i", "o", "u"] vowel in vowels { if string.containsstring(vowel) { replacedstring = replacedstring.stringbyreplacingoccurrencesofstring(vowel, withstring: "") } } return replacedstring } one option filter vowels input string's characters: func removevowels(input: string) -> string { let vowels: [character] = ["a", "e", "i", "o", "u", "a", "e", "i", "o", "u"] let result...

bitmap - Sending a stream of screen captures in C++ -

i'm looking way convert screen capture char* in efficient way. thought capturing screen using bitmap object, converting bitmap object array of bytes , char*, couldn't find way convert bitmap array of bytes. thought iterating every pixel in screen capture , saving rgb values in array, creates array big me. the end goal return char* object in fastest way doesn't return object large, , char* contains data of screen captured. you don't given enough info/code understand you're trying achieve this. e.g. how planning represent colour coefficients? anyway, way go use opencv library, e.g.: cv::mat mat = cv::imread("path/to/your/file.bmp"); char table[mat.rows * mat.cols * 3]; // assuming have 3 colour channels unsigned int index = 0; cv::matiterator_<uchar> it, end; for( = mat.begin<uchar>(), end = mat.end<uchar>(); != end; ++it) table[index++] = *it;

html - Force some margin-top to one of 2 inline-block elements -

i have following code image text on right, on same line. text kind of vertically centered image : | | img mytext here | | here code img, .info { display: inline-block; } <img src="http://placehold.it/100x150"> <span class="info"> <span>foo</span> <span>blah</span> </span> i tried apply margin info class moves img well. how can ? thanks as mentioned use vertical-align center items vertically. also, have make them inline-blocks add padding: img, .info { display: inline-block; vertical-align:middle; } .info { padding-left:32px; } <img src="http://placehold.it/100x150"> <span class="info"> <span>foo</span> <span>blah</span> </span>

azure - Powershell Create a New Windows 10 VM -

when creating new style vm in azure via powershell use specify image set-azurermvmsourceimage -vm $virtualmachine -publishername microsoftwindowsserver -offer windowsserver -skus 2012-r2-datacenter -version "latest" i have been looking through publishers/offers cant seem find windows 10? am looking under wring publisher? looking under windows ones presuming using msdn subscription, otherwise don't have access win10. can run these commands image get-azurermvmimagepublisher get-azurermvmimageoffer -location westeurope -publishername microsoftvisualstudio get-azurermvmimagesku -location westeurope -publishername microsoftvisualstudio -offer windows the final command give list of win10 images ...

c - linux - kernel thread preemption -

i've got realtime linux kernel , i'm developing code kernel thread. thread called ethernet interrupt handler. noticed every call of thread takes 100 jiffies. in time reads 256 ethernet frames. ethernet 1gbps , download speed measured 4mb/s. think 4mb/s speed using 1gbps ethernet far slow. i'm trying profile kernel thread, because think 100 jiffies much. i'd ask if there way tell how many times kernel thread has been preempted? if inside thread, can give try following printk("preempt count %d\n",current_thread_info()->preempt_count); you can add @ entry of thread , check count difference between successive prints

java - How can I include test classes into Maven jar and execute them? -

in maven project, have test classes , source classes in same package, in different physical locations. .../src/main/java/package/** <-- application code .../src/test/java/package/** <-- test code it's no problem access source classes in test classes, run test runner in main method , access alltest.class can create jar , execute tests. public static void main(string[] args) { // alltest not found result result = junitcore.runclasses(alltest.class); (failure failure : result.getfailures()) { system.out.println(failure.tostring()); } system.out.println(result.wassuccessful()); } but doesn't work don't have access test code. don't understand since in same package. question : how can access test classes application classes? alternatively, how can maven package fat jar including test classes , execute tests? you should not access test classes application code, rather create main (the same main) in test scope , create...