Posts

Showing posts from March, 2011

c# - Deploy WPF Application with SQL Server -

i'm using visual studio 2012. created wpf app client using service based database , published app fails access database. have installed sql server 2008. please guide me through process on how deploy app using sql server , changes should make in connection string , app.config or other change need make. have googled , searched on stack overflow 2 days find detailed solution. for 1 pc, there no need service based database. because service based database, there should background service running handle requests. came across same issue when had deploy wpf application client's machine. unless have multi-user app , need central database, best choice use sqlite. 1 disk file not need service running connection. the connection string have match place of sqlite file. can refer link start. sqlite wpf also sqlite supports both db first , code first approaches of entity framework , linq sql. find bit hard convert worth it. not can tell in 1 answer, try maybe write articl...

php - laravel 5.3 new Auth::routes() -

recently start use laravel 5.3 write blog, have question after run php artisan make:auth when run this, generate routes in web.php this code in it: auth::routes(); route::get('/home', 'homecontroller@index'); then run php artisan route:list , find lots of actions, logincontroller@login... but didn't find these actions in app\http\controllers\auth , these? and auth::routes() stand for, can't find routes auth. i need help, thank answer question auth::routes() helper class helps generate routes required user authentication. can browse code here https://github.com/laravel/framework/blob/5.3/src/illuminate/routing/router.php instead. here routes // authentication routes... $this->get('login', 'auth\logincontroller@showloginform')->name('login'); $this->post('login', 'auth\logincontroller@login'); $this->post('logout', 'auth\logincontroller@logout')->name('logo...

java - Red X Mark in android studio application while running -

Image
i wish if 1 can me in android studio problem? i came while working on application have no idea whatsoever since tried possible solution can resolve issues. any appreciated. the red x there saying cannot build/run project. because had error while indexing application. error happens when open project. needs index code again. couple things can remove this: go gradle file, delete something, , type back. ask "refresh" project. you may try cleaning , rebuilding project. basically, reloading code should fix problem. if can find way refresh project, can try use way too.

bash - How to extract x lines every y number of lines -

i have big file want extract x lines every y number of lines. searched around , found answers on how print first z lines, tail -n +<lines skip + 1> i'm trying combine sed don't know how. to print first 2 lines of every tex lines, try: awk -v x=2 -v y=10 '(nr - 1) % y < x' for example: $ seq 20 | awk -v x=2 -v y=10 '(nr - 1) % y < x' 1 2 11 12 how works awk reads through input line-by-line. print line if condition (nr - 1) % y < x true. nr line number starting @ 1 first line.

java - Javax.swing and AJDT issues -

i'm student , new aop , have think in use aspects define, in them, questions deal colors, borders, size of font, , that's it. that, downloaded complement ajdt of eclipse can work aspects (my version of eclipse 4.3 kepler , ajdt 2.2.3). i have aspect called "style" point cut captures call constructor of class frmprueba, , 1 advice around replace instance of formulary created another, configure button same formula, in yellow. problem this, aspect define style, pops error: https://s13.postimg.org/m2a13phuf/1.png - https://s13.postimg.org/twamp3pnb/2.png i searched lot on internet didn't find solution this.

Javascript: Getting undefined on input box that takes a range from 0 to 10 -

i have 2 buttons (+ , -) , input box value of 10. input must take value 0 10 , can't figure out why i'm getting undefined after reach either 0 or 10 on input box. tried using parseint values. perhaps i'm not doing on right place. appreciate help. var fighterscore1 = document.getelementbyid("fighterscore1"); fighterscore1.value = 10; var fighter1inc = document.getelementbyid("fighter1inc"); var valor = 10; fighter1inc.onclick = function (valor) { fighterscore1.value = increasevalue(valor); }; fighter1dec.onclick = function (valor) { fighterscore1.value = decreasevalue(valor.value); }; function decreasevalue() { if (valor <= 0 ) { } else { valor--; return valor; } }; function increasevalue() { if (valor >= 10 ) { valor = 10; } else { valor++; valor = valor; return valor; } }; <div id="rwid1"> <button id="...

javascript - Query subdocuments MongoDB Node.JS -

i have collection of objects have sub dictionary contains data given institution, identified provider_id . how can query collection, products , return produce contain given provider id? "natl_total_cost": 1.27478784e9, "natl_average": 8338.487, "natl_report_count": 152880, "name": "wax", "provider_cost_dict": { "340008": { "report_count": 181, "total_cost": 1335465, "average_cost": 7378.26 }, "340001": { "report_count": 643, "total_cost": 5026724, "average_cost": 7817.6113 }, ... how query of products returns products contain given provider id in provider_cost_dict ? you can use $exists operator db.getcollection('yourcoll').find({"provider_cost_dict.340008": { $exists: true }})

javascript - Get key from value with this node.js dictionary -

i using node.js collection module. http://www.collectionsjs.com/ i key value inside dictionary. here code; "use strict"; var dict = require("collections/dict"); var data_type = new dict( { "00": "data_not", "01": "data_sensor", "02": "data_sensor2", "03": "data_sensor3", }); getting value key easy. data_type.get("00"); return data_not . however, encountering problem in getting key value. preferably, data_type.getkey("data_not"); , have return "00" . other methods welcomed. will have more 1 same values in dict ? possible methods use map() function in collectionjs mapdict = []; dict.map(function(v,k) { ' if (v === "data_not") { mapdict.add(v,k); } }); mapdict.get(0);

bash - Php version reads as one version, when I need another -

on mac/terminal, i'm attempting set local server laravel keep getting error php version not date. have attempted install needed 5.6 version via tutorial, i'm assuming needs updated in bash, possibly things using composer. not how update bash correctly or here. https://coolestguidesontheplanet.com/upgrade-php-on-osx/ how updated. also, if have suggestions can learning prevent question in future appreciated/where start. edit: error: package requires php >=5.6.4 php version (5.5.36) not satisfy requirement. terminal command: composer update install php homebrew brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/homebrew-php brew unlink php56 brew install php70 see if works you. had alias php7 in ~/.bash_profile

Executing a Python file from within Python, feeding it input and retrieving output -

i'm writing web application users may attempt solve various programming problems. user uploads executable .py file , application feeds pre-determined input , checks whether output correct. (similar how codeforce works) assuming have uploaded user's script, how execute user's script within own python script, feeding user's script input captured normal input() function, , retrieving output print() functions can verify correctness? figured out. note : if going use in production environment, make sure place restrictions on user can execute. executor.py import subprocess # create process process = subprocess.popen( ['python3.4','script_to_execute.py'], # shell command stdin=subprocess.pipe, stdout=subprocess.pipe, stderr=subprocess.pipe ) # encode string bytes, since communicate function accepts bytes input_data = "captured string".encode(encoding='utf-8') # send input process, retr...

canvas - Passing an image from Java to JavaFX WebView -

i've got application window using javafx. window contains simple webview display html document. inside html document, there script tag, executing java function, returns pixels int[]. i'm using following code draw image onto canvas: var context = canvas.getcontext('2d'); var imagedata = context.createimagedata(canvas.width, canvas.height); var buffer8 = new uint8clampedarray(imagedata.data.buffer); var buffer32 = new uint32array(imagedata.data.buffer); buffer32.set(pixels); context.putimagedata(imagedata, 0, 0); this works, performance 0.07 seconds per frame, giving me total of ~ 15 fps, using 640x480 canvas currently. goal @ last 30fps 1920x1080 (currently 5 fps), , higher values. solution come create/populate whole buffer @ once on java side, have no idea how manage that. appreciated.

javascript - derive strong password from hash -

i crypto newb, looking avoid blunder. have read quite bit on deterministic password generation. have scheme feel comfortable with. looking on 1 of components. firstly, plan on using scrypt master password. have other unique inputs combined scrypt output create final password derivative. i'm focused here on question of how adhere different password requirement schemes. below function can run in jsfiddle. should output generated password , number of iterations required match requirements. can store 3 tuple of character requirements password scheme, input parameters, , number of iterations required. hope strong , can avoid bruit forcing. unsure how generate caps, , special characters via typical hex hash conversion, below think works not sure attacks may subject to. commenting out padding seems creates issues? is there issue converting octal (am losing randomness?) , char? sample code var input_secret = "e" var max_it = 1000 var special_chars = 10 var digit_ch...

bitmap - Why cannot android studio 2.1.3 import android.graphics.BitmapFactory? -

Image
i'm learning android using android studio 2.1.3, , want use bitmapfactory decode bitmap. when import android.graphics.bitmapfactory , import sentense gray, , hint box has no bitmapfactory in it, this: you see,there bitmap,bitmapregiondecoder,bitmapshader in it. why that? how can import bitmapfactory? can give me hand? please, thank sincerely.

node.js - res.redirect creating another request on the same route -

Image
this first time here, hope post correctly. i working loopback here, , having problem when try redirect route. have 2 middlewares. first, checks firebase if user if authenticated , allowed visit /dashboard. if no, call next() middleware , 1 redirects /login again. dashboard.js: 'use strict'; const firebase = require("firebase"); exports.dashboard = (req, res, next) => { firebase.auth().onauthstatechanged((user) => { if (user) { console.log("before render: "+res.headerssent); // false res.render("dashboard", {photourl: user.photourl, displayname: user.displayname, email: user.email }); console.log("after render: "+res.headerssent); } else { // console.log("on else" ); next() } }); }; exports.notlogged = (req, res) => { console.log("no 1 logged in"); res.redirect('/log...

Cannot update document's property in SharePoint 2013 using OpenCMIS -

i'm using sharepoint 2013 , i'm trying update document's property opencmis 0.14.0 the code simple: final string prop = "mycustomproperty"; session session = buildsessionwithatompubbinding("https://domain/_vti_bin/cmis/rest/?getrepositories"); operationcontext oc = session.createoperationcontext(); oc.setfilterstring(prop); cmisobject doc = session.getobjectbypath("/docs/contracts/doc.xsl", oc); system.out.println("doc id before checkout: " + doc.getid()); final map<string, string> prop = new hashmap<string, string>(); prop.put(prop, "ironman"); system.out.println(prop); cmisobject newobj = doc.updateproperties(prop); but following exception: doc id before checkout: 6010-512 exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.cmisconnectionexception: redirects not supported (http status code 302): found @ org.apache.chemistry.opencmis.client.bindings.spi.atompub....

How to create a state store with HashMap as value in Kafka streams? -

i need create state store string key hashmap value. tried below 2 methods. // first method statestoresupplier avgstorenew = stores.create("avgsnew") .withkeys(serdes.string()) .withvalues(hashmap.class) .persistent() .build(); // second method hashmap<string ,double> h = new hashmap<string ,double>(); statestoresupplier avgstore1 = stores.create("avgs") .withkeys(serdes.string()) .withvalues(serdes.serdefrom(h.getclass())) .persistent() .build(); the code compiles fine without error, runtime error io.confluent.examples.streams.wordcountprocessorapiexception in thread "main" java.lang.illegalargumentexception: unknown class built-in serializer can suggest me correct way create state store? if want create state store, need provide serializer , deserializer class type want use. in kafka stream, there single abstraction called serde wraps seria...

scala - Apache Flink : Creating a Lagged Datastream -

i starting out apache flink using scala. can please tell me how create lagged stream(lagged k events or k units of time) current datastream have? basically, want implement auto regression model (linear regression on stream time lagged version of itself) on data-stream. so, method needed similar following pseudo code. val ds : datastream = ... val laggedds : datastream = ds.map(lag _) def lag(ds : datastream, k : time) : datastream = { } i expect sample input , output if every event spaced @ 1 second interval , there 2 second lag. input : 1, 2, 3, 4, 5, 6, 7... output: na, na, 1, 2, 3, 4, 5... given requirements right, implement flatmapfunction fifo queue. queue buffers k events , emits head whenever new event arrives. in case need fault tolerant streaming application, queue must registered state. flink take care of checkpointing state (i.e., queue) , restore in case of failure. the flatmapfunction this: class lagger(val k: int) extends flatmapfuncti...

c# - How to get relative path of file which is in project folder? -

i tried using @"~\testdata\test.xml" , trying file bin/debug instead of project folder. you can achieve getting parent of current directory, using directory class in system.io namespace. see code example. using system.io; namespace consoleapplication15 { class program { static void main(string[] args) { var projectfolder = directory.getparent(directory.getcurrentdirectory()).parent.fullname; var file = path.combine(projectfolder, @"testdata\test.xml"); } } }

objective c - View lose cornerRadius with Animation of UIViewAnimationOptionTransitionFlipFromLeft on iOS 8 -

in code, have set: imageview.layer.maskstobounds = yes; imageview.layer.cornerradius = imageview.frame.size.width/2; and run in animation block: [uiview transitionwithview:imageview duration:1.0 options:uiviewanimationoptiontransitionflipfromleft animations:nil completion:^(bool finished) { imageview.hidden = yes; }]; but when running on ios 8, imageview normal, means there no cornerradius imageview . could tell me why? you need slash corners of uiimage not uiimageview using calayer using below code. // load image on imageview programmatically uiimage *image = [uiimage imagenamed:@"yourimage.png"]; // assign changes reflected using method before load image imageview image = [self makeroundedimage:image radius:_imageview.frame.size.width/2]; _imageview.image = image; // method create round image -(uiimage *)makerou...

c# - My custom date format is not formatting date with newton soft json in mvc -

i trying display date in dd-mm-yyyy date getting in format: 2016-08-08t16:17:40.643 i using asp.net mvc , returning data in json format displaying date angular js. here answer trying link , have combined answer given perishable dave , dav_i : public class jsonnetfilterattribute : actionfilterattribute { public override void onactionexecuted(actionexecutedcontext filtercontext) { if (filtercontext.result jsonresult == false) { return; } filtercontext.result = new jsonnetresult( (jsonresult)filtercontext.result); } private class jsonnetresult : jsonresult { private const string _dateformat = "dd-mm-yyyy"; public jsonnetresult(jsonresult jsonresult) { this.contentencoding = jsonresult.contentencoding; ...

php - PDO access denied for user 'username'@'%' -

i need connect remote mysql server using php page; the connection works charm, moment try create database, doesn't exist yet, error: exception 'pdoexception' message 'sqlstate[42000]: syntax error or access violation: 1044 access denied user '[myusername]'@'%' database '[mydbname]'' in [myurl]/php/db_manager.php:76 as can see, have access denied "%". now: "%"? furthermore: main file private function createdb() { if($this->cm->update("create database if not exists " . $this->dbname . " default character set utf8 collate utf8_general_ci;", array())) { // error here $this->cm->update("use " . $this->dbname . ";", array()); return true; } return false; } $this->cm instance of correctly initialized pdo wrapper pdo wrapper file public function update($query, $values) try{ $sql = $this->db->prepare($query); $sql->ex...

html - Making <a> active in menu when over div-element -

Image
i'm trying make links active when i'm on elements scrolls to. i've tried every single line of code i've found 2 days. nothing working. i'm using cferdinandi's smoothscroll script. <div data-scroll-header id="menu"> <div id="menu-content"> <a data-scroll href="#weare">company</a> <a data-scroll href="#product">product</a> <a data-scroll href="#technical">technical specifications</a> <a data-scroll href="#footer">get in touch</a> </div> </div> with "smooth-scroll" script. <script> smoothscroll.init({ updateurl: true, }); </script> update (the css): #menu { background-color:white; position:fixed; top:0; left:0; height:90px; width:100%; z-index:99999; transition: top 0.2s ease-in-out; } #menu { ...

jquery - Change height of header in table bootstrap -

i have bootstrap table : <table class="table-bordered table-condensed table-hover"> <thead> <tr> <th>id</th> <th>productname</th> <th>price</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>bicycle</td> <td>5000</td> </tr> </tbody> </table> i want change height of thead ,th : "15px" . with default font-size table head bigger 15px. have reduce font-size (and padding) desired height. thead th { font-size: 0.6em; padding: 1px !important; height: 15px; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel=...

javascript - Make a store without using Vuex -

i trying understand how use vuex, since i'm pretty new vuejs world, didn't understand well. so i'm looking alternative. i want share data between 2 components, let's this. i have view file (component contain product) , cart component.so want build add cart feature, , that's why need kind of store. any idea, advice ? thanks. just use object. from official docs: var sourceoftruth = {} var vma = new vue({ data: sourceoftruth }) var vmb = new vue({ data: sourceoftruth }) https://vuejs.org/guide/application.html#state-management

java - Spring Boot: use several locale message.properties for logging depending on 'args' value -

i kind of new in spring boot. want setup spring boot aplication choose specific locale messages.properties file when specific arg used when starting program. these message.properties fields used log program events , sending out email reports customers. the examples found suitable web applications. , couldn't find suitable examples on how can achieved using inbuilt spring boot technology. well, regular spring boot application run main() method - can set default locale via locale.setdefault method before run spring application, so: @springbootapplication public class demoapplication { public static void main(string[] args) { locale defaultlocale = determinelocalefrom(args); locale.setdefault(defaultlocale); applicationcontext context = springapplication.run(demoapplication.class, args); messagesource messagesource = context.getbean(messagesource.class); // when fetching messages, read default locale messagesource.getmessage("my.mes...

excel - conditional formatting not all options -

i used conditional formatting while , had option called number used change "" (blank). @ work. on macbook , using excel mac , when try use conditional formatting have 3 options on custom formats. font, border , fill. there way enable more advanced optons or options missing in excel mac? unfortunately, excel mac still inferior product compared excel windows , lot of features have been in excel windows while not available in excel mac. excel mac excel windows in version 2007. conditional formatting number formats introduced excel 2010 windows, iirc. can't find documentation can created on mac, chances excel mac can't this. don't shoot messenger.

r - Adding legends to multiple line plots with ggplot -

Image
i'm trying add legend plot i've created using ggplot. load data in 2 csv files, each of has 2 columns of 8 rows (not including header). i construct data frame each file include cumulative total, dataframe has 3 columns of data ( bv , bin_count , bin_cumulative ), 8 rows in each column , every value integer. the 2 data sets plotted follows. display fine can't figure out how add legend resulting plot seems ggplot object should have data source i'm not sure how build 1 there multiple columns same name. library(ggplot2) i2d <- data.frame(bv=c(0,1,2,3,4,5,6,7), bin_count=c(0,0,0,2,1,2,2,3), bin_cumulative=cumsum(c(0,0,0,2,1,2,2,3))) i1d <- data.frame(bv=c(0,1,2,3,4,5,6,7), bin_count=c(0,1,1,2,3,2,0,1), bin_cumulative=cumsum(c(0,1,1,2,3,2,0,1))) c_data_plot <- ggplot() + geom_line(data = i1d, aes(x=i1d$bv, y=i1d$bin_cumulative), size=2, color="turquoise") + geom_point(data = i1d, aes(x=i1d$bv, y=i1d$bin_cumulative), color="royalblue...

java - How to make writes to array visible to other Threads -

i have input array of basic type int, process array using multiple threads , store results in output array of same type , size. following code correct in terms of memory visibility? import java.util.concurrent.countdownlatch; import java.util.concurrent.executionexception; import java.util.concurrent.executorservice; import java.util.concurrent.executors; import java.util.concurrent.timeunit; public class arraysynchronization2 { final int width = 100; final int height = 100; final int[][] img = new int[width][height]; volatile int[][] avg = new int[width][height]; public static void main(string[] args) throws interruptedexception, executionexception { new arraysynchronization2().dojob();; } private void dojob() throws interruptedexception, executionexception { final int threadno = 8; executorservice pool = executors.newfixedthreadpool(threadno); final countdownlatch countdownlatch = new countdownlatch(width ...

java - Background image selecting in the app -

what wanted. i'm having problem setting background app. wanted page selections of wallpaper/background app user choose. once chose background wanted clicking image view, whole app should use image background.that's all. what i've done. i've created activity has 2 imageview choices of wallpaper available , assigns image view set background image when user click on them. problem don't know how save setting , apply other activity in project. xml <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop=...

android - Set AutocompleteTextView hint in a single line with Ellipsize end -

Image
i want set hint of autocompletetextview in single line string truncated dots(...) in end. i using singleline="true" , maxlines="1" , ellipsize="end" . but still hint shown in 2 lines. although text set single line. need hint should need shown in single line. preview in android studio shows hint in single line. when run on device shows in 2 lines.(s5, nexus-5, nexus-6, j7). i want imeoption should search. i.e. imeoptions="actionsearch" hence can't change actionnext. below xml code: <relativelayout android:id="@+id/lilaysearchmap" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone" android:paddingleft="10dp" android:background="@color/cococo" android:paddingright="10dp"> <autocompletetextview ...

c# - WinForm: Inherited Panel wont Autosize -

first of all: english pretty bad. i'm sorry if there grammar , writing errors. my question: our company using same dll lot of programs. in on of multiused dlls, created basic ui object, used often. found bug, when dll used in specific programm: my team created panel via winform. normaly works great: whenever start panel, form autosized according current free space got. realize this, used following code: this.tablelayoutpanelmain.autosize = true; this.tablelayoutpanelmain.autosizemode = system.windows.forms.autosizemode.growandshrink; no problems far. but, after specific panel used again in same program - think created panel inherited somehow - wont autosize anymore. instead got pre-defined size: this.tablelayoutpanelmain.size = new system.drawing.size(341, 69); i dont have idea, why panel isnt reloading again , autosizing again. biggest issue here is, dont have access specific program, bug occurs , our dll used. know error somehow occours there. i ...

c# - Why `.Reverse().TakeWhile(..)` seems to have an invalid index? -

please see code: using system; using system.linq; public class test { public static void main() { var s = "5401"; console.writeline(s); var predicate = (d,i) => { var r = > 0 ? s[i-1] >= s[i] : true; console.write($"{i}: {s[i]}; "); if(i > 0) console.write($"{i-1}: {s[i-1]};"); console.writeline($" result: {r}"); return r; }; console.writeline(new string(s.takewhile(predicate).toarray())); // case: console.writeline(new string(s.reverse().takewhile(predicate).toarray())); } } it outputs: 5401 0: 5; result: true 1: 4; 0: 5; result: true 2: 0; 1: 4; result: true 3: 1; 2: 0; result: false 540 0: 5; result: true 1: 4; 0: 5; result: true 2: 0; 1: 4; result: true 3: 1; 2: 0; result: false 104 why call reverse() in second case not work? enumerable.reverse returns new reversed sequence , referring same string instance ...

Visual Studio how to change path to settings file -

Image
my "documents" folder path not accessible , need change path currentsettings.vssettings file. problem import wizard not work. after click on next button, wizard disappear. so question is, possible change path manually in config file somewhere or doing wrong ? you can try , save currentsettings.vssettings file going in visual studio under tab tools -> options, under environment section, in import , export settings. in example: tools/options/environment/import , export settings

java - Program ignoring "If Else" and printing everything -

i'm trying create random number generator program tracks player's wins, losses, winning percentage , total winnings. logic of program player gets 3 chances per session , computer generates random number player needs guess or rather should match. i've tried use if & else statements tell user if needs guess higher number or lower number within 3 allowed guesses. what's happening ignores conditions , prints 3 chances @ once , ends game. any inputs on highly appreciated. game class: import java.util.scanner; public class game { player player; luckynumbergenerator lng; public game() { player = new player(); lng = new luckynumbergenerator(); } public void eventloop() { scanner scanner = new scanner(system.in); int choice = 0; boolean exit = false; while (!exit) { system.out.println("welcome guessing game"); system.out.println("========================...