Posts

Showing posts from March, 2014

io - Writing to a text file issue Java -

i coding function check if file cq.txt exists , if so, read it. have been having issue have declared printwriter outside of while loop. later in application, supposed write question 1: correct or question 2: correct file. but, not. creates text file when check it, shows empty. here code, thank in advance: package receiverhost; import java.io.*; import java.net.*; public class receiverhost { public static void main(string[] args) throws exception { //set socket on port 5000 serversocket server = new serversocket(5000); //set "cookie"/ text file written to/ read writer db = new bufferedwriter(new outputstreamwriter(new fileoutputstream("cq.txt"), "utf-8")); system.out.println("tcpserver waiting client on port 5000"); while(true){ //declare string fromclient string fromclient; socket connected = server.accept(); system.out.println(" client" + " " + connec

r - How to combine columns with identical names in a large sparse Matrix -

i have sparse dgtmatrix matrix package, has picked duplicate colnames . want combine these summing columns same names, forming reduced matrix. i found this post , adapted sparse matrix operations. but: it's still slow on large objects. wondering if has better solution operates directly on indexed elements of sparse matrix faster. instance, a@j indexes (from zero) labels in a@dimnames[[2]] , compacted , used reindex a@j . (note: why used triplet sparse matrix form rather matrix default of column-sparse matrixes since figuring out p value makes head hurt every time.) require(matrix) # set (triplet) sparsematrix <- sparsematrix(i = c(1, 2, 1, 2, 1, 2), j = 1:6, x = rep(1:3, 2), givecsparse = false, dimnames = list(paste0("r", 1:2), rep(letters[1:3], 2))) ## 2 x 6 sparse matrix of class "dgtmatrix" ## b c b c ## r1 1 . 3 . 2 . ## r2 . 2 . 1 . 3 str(a) ## formal class 'dgtmatrix' [package "mat

angularjs - [JavaScript][Angular]: TypeError: Cannot read property 'getCityData' of undefined -

this question has been asked many times before , i've tried answers not seem solve problem i'm facing. i'm new angular , trying pass value controller factory can retrieve json information through api. while i'm able value html controller, next step giving me typeerror: cannot read property 'getcitydata' of undefined. controller code follows: app.controller('maincontroller', ['$scope', function($scope, httpgetter) { var successfunction = function(data) { $scope.data = data; } var errorfunction = function(data) { console.log("something went wrong: " + data); } $scope.cityname = ''; $scope.getcityname = function(city) { $scope.cityname = city; httpgetter.getcitydata($scope.cityname, successfunction, errorfunction); }; }]); the factory code follows: app.factory('httpgetter', ['$http', function($http){ return { getcitydata: function(query,

javascript - { [Error: listen EADDRINUSE :::5000] -

what's wrong following server.js file? trying connect deployd heroku , keep getting following error. we're using nitrous, , have configure mongodb port 5000. appreciated. ton! server.js // require deployd var deployd = require('deployd'); // configure database etc. var server = deployd({ port: process.env.port || 5000, env: 'production', db: { host: '0.0.0.0', port: 5000, name: 'database_name', credentials: { username: 'username', password: 'password' } } }); // heroku requires these settings sockets work server.sockets.server.set('transports', ["xhr-polling"]); // start server server.listen(); // debug server.on('listening', function() { console.log("server listening on port: " + process.env.port); }); // deployd requires server.on('error', function(err) { console.error(err); process.nexttick(function() { // give server chance return error process.exit

vba - How do I insert text at my cursor location in Word? -

i'm trying have excel macro insert text @ cursor location in already-opened word document. this have written. i'm aware activedocument.range has start , end arguments, cannot seem able assign them "current selection" value. help? thanks? sub inserttext() dim rngtemp word.range set rngtemp = activedocument.range rngtemp .insertafter "this sample text" .font.name = "tahoma" .font.size = 11 .insertparagraphafter end end sub the current selection selection . if, indicate, need use in excel macro that's automating word, need use word.application object you've declared , instantiated qualify it. this: dim wdapp word.application set wdapp = getobject(, "word.application") wdapp.selection.text = "text @ current selection" 'get range current selection dim rng word.range set rng = wdapp.selection.range rng.text = "this text replace text in current selection" rng.collapse wdco

java - Akka actors processes one message at a time -

akka actor can process 1 message @ time , hence dont need worry concurrency. consider have system pizza shop. design this 1)webservice 2)akka ecosystem actors pizaacreater, deliveryhandler 3)web service accepts ther order , passes pizzacreater,pizzacreater creates pizza , passes deliveryhanlder. now there 1 instance of pizzacreater , deliveryhandler.this slow down entire system. 1)should create multiple pizzacreaters , deliveryhandler? 2)how customerservice pass order pizzacreater minimum load or how pizzacreater pass pizza delivieryhandler minimum load then? 3)is creating multiple instance of pizzacreaters / deliveryhandler ok? if "pizza creation" blocking operation (uses network/db) create router pizzacreatorworkers (the number of workers/threads depends on scenario). if "pizza creation" non-blocking - create 1 actor per request. same thing delivery: create router fixed number of deliveryhandles if delivery blocking otherwise create actor

java - Regular expression not matching on first and last word of string -

i trying write java program specific words in string. have working part doesnt seem match if word match first or last word in string. here example: "trying find first word".matches(".*[^a-z]find[^a-z].*") //returns true "trying find first word".matches(".*[^a-z]trying[^a-z].*") //returns false "trying find first word".matches(".*[^a-z]word[^a-z].*") //returns false any idea how make match on word in string? thanks in advance, craig the problem character class before , after words [^a-z] - think want word boundary character \b (as per colind's comment) opposed not character in a-z range. pointed out in comments (thanks) you'll needs handle start , end of string cases. so try, eg: "(?:^|.*\b)trying(?:\b.*|$)"

How to delete row from VORA Table -

is there functionality delete rows table, or remove file path list, or have drop entire table , re-create rows need? also there truncate function? vora tables based on files in hdfs. of today (vora1.2) can append existing table. there no delete or truncate functionality. can drop table , re-create based on different files.

ios - Internal name swift 2.0+? -

Image
this question has answer here: what meaning of '#' mark in swift language 5 answers before update swift 2.0+ worked. there no internal parameters? how should change let work correctly? i found out need delete "func" , "#" didn't d: func previewfile(#path: nsindexpath) { uiapplication.sharedapplication().networkactivityindicatorvisible = false self.fileisloading = false let previewql = qlreaderviewcontroller() previewql.datasource = self previewql.delegate = self previewql.hidesbottombarwhenpushed = true self.filepath = path self.navigationcontroller?.pushviewcontroller(previewql, animated: true) } so did ... enter image description here but if delete "path" work correctly? why declaration of parameter changed so? mean - works. why previewfile(indexpath!) instead of previewfi

python - CSV to Postgres database: "Error: extra data after last expected column" -

i trying convert .csv file postgres database. have set database appropriate number of columns match .csv file. have taken care strip " , " (comma characters) .csv file. here command typing psql : copy newtable 'path/to/file.csv' csv header; i have tried can think of. idea how fix this?

node.js - Can't get local file test.txt using http://localhost:8080/test.txt -

i've got server running on localhost:8080 , , files arranged this: /test server.js chatroom.html test.txt server.js: var express = require("express"); var app = express(); app.get("/", function(request, response) { response.sendfile(__dirname + "/chatroom.html"); }); app.listen(8080); so in browser when go http://localhost:8080 served chatroom.html fine. the problem i'm having: but when go http://localhost:8080/chatroom.html shows me "cannot /chatroom.html" and, likewise, if go http://localhost:8080/test.txt shows me "cannot /chatroom.html" i don't understand what's going wrong here, appreciated! you've defined 1 path express, root path "/". if want other files available need call app.get() them well. or, can put static assets in directory , use express.static serve them.

dynamic - How to dynamically add elements to a Dojo ComboBox -

i have dojo combobox declaratively created using standard html select. there onchange event on separate textbox invokes function data server via xhr , elements of response data become new options drop down. i've been trying examples across internet nothing far has worked. code i'm trying no errors. in fact, when @ contents of store after put, data in there. when click on drop down after data has been set, error "_autocompletermixin.js.uncompressed.js:557 uncaught typeerror: cannot read property 'tostring' of undefined": var newoptions = new array(); (var = 0; < jsondata.length; i++) { newoptions[i] = { value: jsondata[i].dataid, label: jsondata[i].dataname, selected: == 0}; } var select = registry.byid("combobox"); select.store.put(newoptions, { overwrite: true }); and "select.store.data = newoptions;". , moving code around "select.store.add(option)" within l

java - How to get the file name when using Part to upload files with JSF? -

i'm using below code snippet upload file using jsf private part uploadedfile; public part getuploadedfile() { return uploadedfile; } public void setuploadedfile(part uploadedfile) { this.uploadedfile = uploadedfile; } public void processfileupload() { if(!(uploadedfile==null)) { filename = uploadedfile.getname(); system.out.println(filename); filesize = uploadedfile.getsize(); filecontenttype = uploadedfile.getcontenttype(); } else { system.out.println("null"); my jsp code snippets shown below <h:form enctype = "multipart/form-data"> <h:outputlabel value="select file:" style="color:white"/> <h:inputfile id="fileupload" label="file upload" style="color:white" value="#{actionbeanworld.uploadedfile}" size="60" /> <h:commandbutton type = "submit" value = "upload" action = "#{actionbeanworld.processfileupload}"> </

html - get content align center -

Image
im trying build profile card view , im using bootstrap it. i build 2 div elements on class col-lg-3 , other 1 col-lg-9. problem content inside col-lg-9 not align in center. has more space on right side on left side , tryde them center. disabled margin , padding didnt worked. the col-lg-9 inside row , normal container. , inside col-lg-9 content. have here sample on bootplay if ya marke container can see contents class card hase right more space. thats html code of <div class="col-lg-9" style="min-height: 100px; background-color: #333"> <div class="container"> <div class="card"> <div class="model-image"> <img src="img/elliot.jpg"> </div> <div class="card-content"> <a class="card-header">team fu</a>

html - Why is this page wider than the display? -

i'm working on personal website, , i've run problem: after using css , container center list, page wider display causing horizontal scrollbar. why this? relevant code: html: <h2>my stack:</h2> <div class="list"> <ul class="list-unstyled"> <li>vim</li> <li>git</li> <li>zsh</li> <li>byobu</li> </ul> </div> css: body { margin: 0 2em 0 2em; font-size: 18px; width: 100%; } h1, h2, h3, h4, h5, h6, h7 { text-align: center; } p, div.list{ text-align: center; } ul { display: inline-block; } live copy: https://www.k7dxs.xyz/linux.php theoretically, navbar should compress , text should wrap, right? why isn't working? you need remove margin css body tag: body { // margin: 0 2em 0 2em; <-- remove font-size: 18px; width: 100%; } div.main { margin: 0 2em 0 2em; } wrap content in container-fluid in

security - How do encryption algorithms know if they have the right key -

i know bad idea try implement own encryption algorithms. here 1 reason why think not: for example let's want send plaintext = new byte[]{2,5,1,6,7} bob. if use aes encryption or know algorithm have: ciphertext = aes.encrypt(plaintext, key, iv); // have cipher text not readable if not have key , iv vector. if wants decrypt message have like: newplaintext = aes.decrypt(ciphertext, key, iv); now question how aes knows if entered right key? think more secure have algorithm not prompt brute force attacks. in other words if hacker knows used aes can keep trying lot of passwords until method aes.decrypt thorws no exception. consider algorithm: lets want send same byte array {2,5,1,6,7} bob. encryption algorithm may like: password = "securepassword"; i iterate though each byte on plain text , xor operator on ascii value of each character on password. instance first byte 2 xor (ascii value of 's') next value 5 xor (ascii value of 'e') @

javascript - Sending an array in POST body -

im trying send array node/mongodb server via , ajax post request. body contains other variables. here client side js code: function setupform(){ $("#add").submit(function(event) { event.preventdefault(); var name = $("#name").val(); var logo = $("#logo").val(); var phone = $("#phone").val(); var email = $("#email").val(); var address = $("#address").val(); var postcode = $("#postcode").val(); var openinghours = $("#openinghours").val(); var loc = [44, 44]; $.ajax({ type: "post", url: "http://localhost:3000/services", data: "name=" + name + "&logo=" + logo + "&phone=" + phone + "&email=" + email + "&address=" + address + "&postcode="+ postcode +"&openinghours=" + openingh

c# - Date Format Issue with Web service -

Image
i have web service input parameters. relevant xsd in wsdl below when added wsdl service reference in visual studio, generated class corresponding fields as system.datetime . below example of field in reference class added wsdl private system.nullable<system.datetime> startdatefield; my binding service create client custombinding below protected custombinding getcustombinding() { var custombinding = new custombinding() { name = "custombinding" }; custombinding.elements.add(new textmessageencodingbindingelement() { messageversion = messageversion.soap11 }); var securitybindingelement = securitybindingelement.createusernameovertransportbindingelement(); securitybindingelement.allowinsecuretransport = true; securitybindingelement.enableunsecuredresponse = true; securitybindingelement.includetimestamp = false; custombinding.elements.add(securitybindingelement); custombinding.elements.add(ne

date - Adjusting just the year of some data in R -

i have dataframe 730 observations , 1 of columns date column, of dates supposed 2007 , realise few seem have been mistakenly entered 2006. there way can use r select 2005's , change them 2008 without affecting month , day? it in date format in r , looks this. 2005-05-21 edit: this output asked for: structure(c(13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13604, 13597, 13597, 13597, 13597, 13597, 13597, 13597, 13597, 13597, 13597, 13598, 13598, 13598, 13598, 13598, 13598, 13598, 13598, 13598, 13598, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13607, 13608, 13608, 13608, 13608, 13608, 13608, 13608, 13608, 13608, 13608, 13608, 13608, 13608, 13608, 13

How to use chrome.history API to search urls that were done on mobile? -

https://developer.chrome.com/extensions/history : suggestions on how know if url in history done on mobile or pc? i believe can't @ present, according following, history local device. browser history signed-in devices not getting in chrome extension https://bugs.chromium.org/p/chromium/issues/detail?id=474511 ,

haskell - difference between two monads: ErrorT e Identity v and Either e v -

can explain difference between errort string identity integer and either string integer ? (to simplify this, i'm going answer in terms of exceptt type instead of the deprecated errort . answer not strictly true errort , it's true modulo annoying facts led deprecation of errort .) the key concept understand here isomorphism . put very informally, 2 types isomorphic when, in spite of being superficially different, "essentially same." we can put bit more meat on notion adding concept: 2 haskell types isomorphic if both can converted other in "lossless" fashion pair of inverse functions . in case, either e a , eithert e identity a isomorphic because following 2 functions inverses: toeither :: exceptt e identity -> either e toeither ma = runidentity (runexceptt ma) toexceptt :: either e -> exceptt e identity toexceptt (left e) = throwerror e toexceptt (right a) = return so going informal remarks above, tells 2 types "e

dynamic - Declare variable name dynamically -

the task create variable dynamic name . not type, name! all ways proposed me (e.g. via cl_abap_typedescr , cl_abap_elemdescr classes) useless. want implement semantically this, syntax incorrect: create data (name) type var_type. is there solution? i think if 'name' declared field-symbol work. effect statement declares symbolic field called . @ runtime, can assign concrete field field symbol using assign. operations performed field symbol directly affect field assigned it. try 1 out: data: b_1 type i, b_2 type i, b_3 type i, b_4 type i, num1(1) type n, fldname type fieldname. field-symbols: <fld> type i. 4 times. num1 = sy-index. concatenate 'b_' num1 fldname. assign (fldname) <fld>. <fld> = sy-index. enddo. write: b_1, b_2, b_3, b_4.

html - CSS on Mobile is not working -

i have following css. reason, works until @max-width:767 media query. however, not work not work on resolution, below it, is, @425. after that, it starts working again on resolutions below it. identifying issue appreciated. @media screen , (max-width: 767px) { header{height:auto;} body{padding-top:90px;} #div-header-submenu-rtl, #div-header-submenu {top:-5%; left:25%;} .text-center-767{text-align:center; padding-top:5px;} .search-div, .search-div-rtl{width:100%; margin-left:3px;} .search-div-rtl{padding-right:10px; margin-right:0px;} .txt-search{width: 85%;} .timeline-poster-name{ margin-top:auto;} .btn-comment-submit{width:20%; font-size:10px;} .affiliate-card-padd-3, .affiliate-card-padd-2,.affiliate-card-padd-4{ padding:15px;} .affiliate-card-padd-3-ar, .affiliate-card-padd-2-ar,.affiliate-card-padd-4-ar{ padding:15px;} .affiliate-frame, .select-affiliate, .affiliate-frame-store{ margin:0 auto;} .margin-left-50-767 {margin-lef

linux - How to change server in DNF -

i'm trying install package dnf command utility, , freezes on downloading stage. think, it's server problem. how can change server, dnf uses download from? thank answers. the server information stored in repo file: /etc/yum.repos.d/fedora.repo and /etc/yum.repos.d/fedora-updates.repo just need comment out mirror url, , uncomment baseurl lines , run dnf update also can add new mirror here it's recommended activate rpmfusin on system with: su #type root password rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm

c# - Webdriver tests failing due to System.Net.WebException timeout -

c# .net 4.5 vs 2013 nunit 3.2.1 webdriver , webdriver.support 2.53 so issue trying navigating ebay's sandbox login page , login. seems simple enough struggling page load before giving me system.net.webexception timeout error. here link trying go https://signin.sandbox.ebay.com/ and here code looks doing this. var ebaysandboxpage = new ebaysandboxloginpagemodel(driver); driver.manage().timeouts().setpageloadtimeout(timespan.fromseconds(200)); driver.navigate().gotourl(ebaysandboxloginpagemodel.sandboxurl); and here exception getting thrown every time try in firefox. test name: verifyitemssold test fullname: pomauctivatest.testsuite.postsaletestsuite<firefoxdriver>.verifyitemssold test source: c:\git\pomauctivatest\pomauctivatest.testsuite\postsaletestsuite.cs : line 204 test outcome: failed test duration: 0:00:00.0000001 result message: onetimesetup: openqa.selenium.webdriverexception : http request remote webdriver server url http://localho

javascript - How to have seperate link function instance for angular directives? -

i have directive has function in link fires whenever directive element moved. inside link function create random number. hope every directive instance have own randon number value. no matter of directives move print same value random. how can give each directive own instance of random. look @ console.log('moving', random); inside of drag: function().. inside setpixelsnap function. my directive 'use strict'; var cell_length = 80; var colors = ['#ef5350', '#7e57c2', '#ec407a', '#42a5f5', '#ffca28'] var app = angular.module('netjamapp'); /* directive listing tracks */ app.directive('myclip', ['$rootscope', 'diffsyncservice', function($rootscope, diffsyncservice) { return { restrict: 'e', scope: { clip: '=', ppb: '=', project: '=', track: '='

appcelerator - emailDialog carriage returns -

how can add line feeds messagebody of emaildialog? i've tried "\n" , " <br /> ", sethtml(true), nothing seems work, still emaildialog text running together. example: var strbody=""; (i=0, len=tabledata.length; i< len; i++) { strbody+=tabledata[i].children[0].children[1].text + "<br />"; } var emaildialog = ti.ui.createemaildialog(); emaildialog.subject = "test"; emaildialog.sethtml(true); emaildialog.messagebody = strbody; emaildialog.open

In AngularJS can I stop browser rendering until digest is complete? -

i have bootstrap input group displays differently depending on state. checking box cause textbox display , unchecking hide textbox. have adjust width of label have line correctly , without textbox <div class="input-group"> <div class="input-group-addon" ng-click="bcc.switchstate(item)"> <button class="btn btn-default chkitem-btn" aa-box-click="item.isnotok"> </button> </div> <label class="input-group-addon checkbox-label" ng-click="bcc.switchstate(item)" ng-class="{ default: !item.isnotok, checked: item.isnotok, 'checkbox-label-textbox': item.hastextbox && item.isnotok }"> {{item.caption}} </label> <input id="txt{{$index}}" type="text" class="form-control text"

Javascript / Openlayers for loop not working -

i'm creating map openlayers , having trouble getting features appear. i want take array, , assign each coordinate it's own marker. relevant code (full code @ bottom of post): var npctowns = [ [ 533, mapy-966 ], [ 833, mapy-1766 ], [ 2000, mapy-500 ], [ 1500, mapy-1700 ] ]; (var = 0; < npctowns.length; i++) { var lon = npctowns[i][0]; var lat = npctowns[i][0]; var npctownicons = new ol.feature({ geometry: new ol.geom.point([lon,lat]) }); var iconstyle = new ol.style.style({ image: new ol.style.icon ({ anchor: [0, 0], anchorxunits: 'pixels', anchoryunits: 'pixels', opacity: 1,

c++ - modifying vector returned by reference -

why size of below vector 0? #include <iostream> #include<vector> using namespace std; class { public: vector<int> t; const vector<int>& get(){ return t; } void print(){ cout<< " size "<<t.size(); // cout<<" \nelements %d "<<t[0]; } }; int main() { cout << "hello world" << endl; ob; vector<int> temp = ob.get(); temp.clear(); temp.push_back(3); temp.push_back(5); ob.print(); return 0; } it's because nothing happened it. it's still empty. you made copy of vector in temp , , modified copy, , not original class member. should use reference: vector<int> &temp = ob.get(); since returning reference get() , have assign reference. if don't, you're making copy of object. edit: also, change get() return mutable reference, rather const referenc

excel - Vb.net Custom sum formula not calculating when blank cell are present -

i have 2 problems 1 if have empty cells not work , second not calculate on tables when using sum column5 provided the cinches converting string 12'-3 1/16" 147.0625 inches , tonearest16th converts string closest nearest sixteen of inch 12'-3 1/16" problem when trying sum results using conversion because if there blank cell error show me love guys again public shared function totalsumtonearest(nums object) object '---------------------------------------------------------------------- '** demonstrates how use array(or range of multiple cells) ' function argument. ' can called formulas such =getarray(a1:b5), getarray(a1), ' or getarray({1,2,3;4,5,6}). '---------------------------------------------------------------------- dim sum double, v object on error goto handler if isarray(nums) each v in nums 'if typeof v.getvalue() excelempty 'else

android - Stop asynctask from other activity -

i creating app using asynctask download file server. has several activities. start 1 asynctask activity , want stop activity b. how can archieve ??? it possible call previous activity's public methods using typecasting of getparentactivity() method on activity b : ((previousactivity)getparentactivity()).somepublicmethod(); this works if opened activity b activity a. if want able call method activities, try creating static class , save instance of activity a. way, wherever on app, method can called. wary of null values when doing this. this sample of static class. public static class constants{ public static activitya activityainstance; } when open activitya ( oncreate method) save it's instance: constants.activityainstance = activitya.this; this part saves instance of activitya static class. whereever on app, can access instance , call it's public methods: e.g. app on activityz have import static class , call activitya instance: constants.

jsf 2 - How does JSF send form component values to another page? -

i'm new jsf, i'm trying understand standard way pages send parameters between each other. i have 1 page form elements: form.xhtml: <h:form> <p:selectmanybutton name="numbers" id="lstnumbers" > <f:selectitem itemvalue="1" itemlabel="1"></f:selectitem> <f:selectitem itemvalue="2" itemlabel="2"></f:selectitem> <f:selectitem itemvalue="3" itemlabel="3"></f:selectitem> </p:selectmanybutton> <br /><br /> <p:selectmanybutton name="letters" id="lstletters" > <f:selectitem itemvalue="a" itemlabel="a"></f:selectitem> <f:selectitem itemvalue="b" itemlabel="b"></f:selectitem> <f:selectitem itemvalue="c" itemlabel="c"></f:selectitem> </p:selectmanybutton> <p:commandbutton value="

java - Trouble with splitting an array into chunks -

i have array: private static int[] array = {5, 2, 1, 6, 3, 7, 8, 4}; i'm trying split two-dimensional array x amount of chunks, of chunks have equal length (in case, 2), assign each value of original array corresponding index within array. increment index of chunk number , reset index iterating through individual arrays hit length of one. problem is, code wrote perform isn't outputting anything: public class debug { private static int[] array = {5, 2, 1, 6, 3, 7, 8, 4}; private static void chunkarray(int chunksize) { int chunknumindex = 0; int chunkindex = 0; int numofchunks = (int)math.ceil((double)array.length / chunksize); int[][] twodimensionalarray = new int[numofchunks][chunksize]; (int = 0; < array.length; i++) { twodimensionalarray[chunknumindex][chunkindex] = array[i]; chunkindex++; while(chunknumindex < numofchunks) {

sql - Get date for nth day of week in nth week of month -

i have column values '3rd-wednesday', '2nd-tuesday', 'every-thursday'. i'd create column reads strings, , determines if date has come month, , if has, return date of next month. if has not passed yet month, return date month. expected results (on 4/22/16) above be: '05-18-2016', '05-10-2016', '04-28-2016'. i'd prefer mathematically , avoid creating calendar table if possible. thanks. partial answer, no means bug free. this doesn't cater 'every-' entries, give inspiration. i'm sure there plenty of test cases fail on, , might better off writing stored proc. i did try calculating day name , day number of first day of month, calculating next wanted day , applying offset, got messy. know said no date table cte simplifies things. how works a cte creates calendar current month of date , dayname. rather suspect parsing code pulls day name test data , joins cte. clause filters dates greater nt

php - Codeigniter missing argument -

Image
help guys. this error problem error: i think follow right tutorial, don't know wrong code there controllers public function edit($id){ $where = array('id' => $id); $data['barang'] = $this->model_barang->edit($where,'barang')->results(); $this->load->view('edit',$data); } public function update(){ $id = $this->input->post('id'); $jenis = $this->input->post('jenis'); $nama = $this->input->post('nama'); $harga = $this->input->post('harga'); $pemasok = $this->input->post('pemasok'); $data = array ( 'jenis' => $jenis, 'nama'=> $nama, 'harga' => $harga, 'pemasok' => $pemasok ); $where = array( 'id' => $id ); $this->model_barang->update($where,$data,'barang'); redirect('barang/tampil'

distance - NetLogo: select a patch with neighbors having certain qualities? -

Image
i want let turtle move patch , make "splotch". central patch = turtle location, can selected randomly, satisfy 2 conditions: has in distance turtle's actual position has surrounded (neighbors in radius) patches specific quality the reason create kind of "buffers" around turtle's position, aim obstruct close proximity of clumps. please, how can satisfy these 2 conditions? as far, have: to go ask turtles [ ; select 1 of patches in specific distance, , ; surrounded patches no magenta color let aaa one-of patches [distance myself > 3 , all? neighbors [pcolor != magenta]] ; how write condition above ?? ; , how replace "neighbors" "in-radius"?? move-to aaa ask neighbors [ ; create clump of magenta patches set pcolor magenta ] ask patch-here [ ; set central patch magenta set pcolor magenta ] ]

javascript - value of the select option going to be lost when it return a erro on the form -

i know sounds similar,but couldnt find useful article. have select option html tag in website im used select categories.but end user selected values disappear(come first value ever has been selected). in example have tag <select name="type" > <option value="">select category</option> <option value="car">car</option> <option value="van">van</option> <option> </select> in example first select box selected when browser loading first time , user can select value , must not empty.and if user select "van" , has been fill out other fields in form if return error before insert values database, select box value has been reset first value ("select category"). want prevent happening anymore.i hope of expert can me @ point.thank ! i think understand question. visitors web page complete number of data fields, 1 of select control. however, if there prob

iOS Crash at [UIViewController setTitle] -

i met crash symbolicated result: ios9.3.1(13e238) exc_bad_access kern_invalid_address 0x000000001500c018 crashed: com.apple.main-thread 0 libobjc.a.dylib 0x18181db90 objc_msgsend + 16 1 foundation 0x182a8e454 -[nsobject(nskeyvalueobservernotification) willchangevalueforkey:] + 324 2 quartzcore 0x184c8711c ca::layer::set_delegate(objc_object*) + 72 3 uikit 0x1872f2f40 -[uiview _createlayerwithframe:] + 580 4 uikit 0x1872f2a00 uiviewcommoninitwithframe + 688 5 uikit 0x1872f26f0 -[uiview initwithframe:] + 140 6 uikit 0x1872f9fb0 -[uilabel initwithframe:] + 48 7 uikit 0x187394f04 -[uinavigationitemview initwithnavigationitem:] + 200 8 uikit 0x18761de4c -[uinavigationitem _defaulttitleview] + 128 9 uikit 0x18761cfbc -[uinavigationitem _adddefaulttit

python - Handling negation in words -

i have bunch of strings like i don’t book and need below. how obtain this i not book you need this: replacement = {"n't": " not", "book":"notebook"} string = raw_input("enter sentence: ") rplc in replacement: string = string.replace(rplc, replacement[rplc]) print string works below: >>> ================================ restart ================================ >>> enter sentence: isn't book not notebook >>> add want replaced replacement variable.

javascript - Find Duplicate Array within Array -

given array of arrays, efficient way of identifying duplicate item? var array = [ [ 11.31866455078125, 44.53836644772605 ], [ // <-- here's duplicate 11.31866455078125, 44.53836644772605 ], [ 11.371536254882812, 44.53836644772605 ], [ 11.371536254882812, 44.50140292110874 ] ] i've been working on lodash accepted dependency, , how return "unique" list using _.uniqwith , _.isequal : _.uniqwith(array,_.isequal) with give "unique" version of list: [ [ 11.31866455078125, 44.53836644772605 ], [ 11.371536254882812, 44.53836644772605 ], [ 11.371536254882812, 44.50140292110874 ] ] but rather reporting unique elements, need element duplicated, , ideally index of first occurrence. is covered in lodash library combination of methods i'm missing? or going have live writing loops compare elements. probably overtired on this, fresh eyes on problem welcome. tryi

linux - How to kill program running in background in ubuntu? -

i'm working on mini2440 , building custom os using buildroot, testing purpose i'm using os downloaded official website. problem is, i'm using usbpush push os images in mini2440 through usb, popups message when enter below commond sudo ./usbpush supervivi-128m 0x30008000 unable claim usb interface 1 of device: not claim interface 0: device or resource busy i don't understand 1 concept that, whenever assign executable permission usbpush , runs automatically in background. it's seen below ps -ef | grep usb* silicod+ 2431 2207 0 10:25 pts/10 00:00:00 grep --color=auto usbpush i tried kill using sudo kill -9 2431 but creates new pid , again run itsellf in background. tried googling nothing works me. ============================================================= well, got solution. don't know problem usbpush tool, downloaded tool , works well. here link tool , may friendly_arm_mini2440_usbpush cheers....! lovely ;-) w

entity framework - How to keep my DbContext in another project? -

i'm trying use ef 6 custom conventions interface iconfigurationconvention not recognized! packages: entityframework 6.0.0-beta1-20702 i'm following this post unsuccessfully use custom conventions in ef6

Laravel 5 and Cloudflare SSL -

well, today first time decided use ssl on web project. firstly, configured domain in cloudflare.com. turned on page rules in cloudflare, automatic redirect website https. http://*example.com/* to make sure works, added simple index.php public_html , worked. mean, when entered web site, https active , site displayed me famous word: "hello world" after uploaded laravel project web server , configured virtual host. use nginx server. server { listen 80; root /home/user/www/example.com/public_html/public; index index.php index.html index.htm; server_name example.com location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$;

php - i am doing an add to cart program.i am listing several products on a single page.but i can only change the quantity of the first product -

i new php. doing add cart program.i listing several products on single page.but can change quantity of first product in list. while others taking default value 1. this program used listing multiple products on single page retrieving database.there different categories , therefore taking cat_id url. custproduct.php <?php session_start(); if (isset($_get['id'])) { // echo"id: ".$_get['id']; include ('custdb1.php'); echo "<h2>list of products:</h2>"; $sql = "select * `product` `cat_id`=".$_get['id']; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> product id: ". $row["pro_id"]. " - product name: ". $row["pro_name"]. "<br>"; echo "<img src='upload/".$row['pro_img']."'/>"; echo "<br&g

java - Image IO Write not writing -

basically trying save image have edited in jframe, have menu save item , have action listener set save item , works fine, file chooser comes , can select save it, thing when hit save, not there. here code, missing something? if(e.getsource().equals(save)){ jfilechooser keep = new jfilechooser(); keep.setselectedfile(new file ("newimage.jpg")); filenameextensionfilter filters = new filenameextensionfilter("jpeg", "jpg"); keep.setfilefilter(filters); file output = keep.getselectedfile(); int count = keep.showsavedialog(keep); bufferedimage out = filteredimage; if (count == jfilechooser.cancel_option){ } else{ try{ imageio.write(out, "jpg", output); //i put here see if reaching method system.out.println("writing method"); }catch(exception d){ } } }