Posts

Showing posts from September, 2014

php - Delete not deleting the selected post but its deleting the recently(newels) added post -

my update.php file: <?php ob_start(); session_start(); //declare basic variables $servername = "localhost"; $username = "bilal"; $password = "super"; $dbname = "coursework"; //create connection $link = mysqli_connect($servername, $username, $password, $dbname); //check connection if($link->connect_error){ die ("connection failed: " . $link->connect_error); } //security purpose, handiling escape string // $crested_by = $_post ['created_by']; $title = $_post['title']; $catagory = $_post['catagory']; $contact = $_post['contact']; $comment = $_post ['description']; $ses = $_session['email']; $date = date('y-m-d'); $availability = $_post ['availability']; $price = $_post ['price']; $id = $_post['wow']; // $created_by_id = $_session['created_by_id']; // $username = $_session['firstname']; if (isset

java - Systemd: Unknown lvalue '_JAVA_OPTIONS' in section 'Service' -

i'm running website in clojure. here http://www.luminusweb.net/docs/deployment.md says: note default jvm aggressive memory usage. if you're reduce amount of memory used can add following line under [service] configuration: [service] ... _java_options="-xmx256m" execstart=/usr/bin/java -jar /var/myapp/myapp.jar however, after adding service file, exception: unknown lvalue '_java_options' in section 'service' this not valid systemd.service(5) syntax. can specify environment variables using directive: environment=_java_options='-xmx256m' execstart=/usr/bin/java -jar /var/myapp/myapp.jar

excel - Calculate two sheets -

i need little 2 sheets in excel: sheet1 id name in stock 1 test 44 2 test2 55(become 50) 3 test3 66 sheet2 id name ordered 2 test2 5 end: when enter 5 in sheet2 ( ordered ) automatically subtract sheet1 ( in stock ) id 2 , name test2 . use lookup id , name, when enter 2 in id automatically show name test2 . need subtracting. know need use sumif no sure how. as correctly said in post, may use sumif. let's consider on 2 sheets, "id" in column a, "name" in column b, , "in stock" , "ordered" in column c. can calculate actual stock of third row, id "2", in cell c3 follows =55-sumif(sheet2!a:a,a3,sheet2!c:c) as expected result 50. approach way not convenient, because should add formula manually in every row of table on sheet1. suggested above others, better have @ least column put starting values of stock, can replace actual stock in figures reference relevant cell.

scala - Why is predicate pushdown not working? -

programm sketch i create hivecontext hivecontext . with context, create dataframe df jdbc relational table. i register dataframe df via df.registertemptable("testtable") . i start hivethriftserver2 via hivethriftserver2.startwithcontext(hivecontext) . the testtable contains 1,000,000 entries, columns id (int) , name (varchar) +-----+--------+ | id | name | +-----+--------+ | 1 | hello | | 2 | hello | | 3 | hello | | ... | ... | with beeline access sql endpoint (at port 10000) of hivethriftserver , perform query. e.g. select * testtable id='3' when inspect querylog of db sql statements executed see /*sql #:1000000 t:657*/ select \"id\",\"name\" test; so there happens no predicate pushdown , clause missing. questions this gives raise following questions: why no predicate pushdown performed? can changed not using registertemptable? if so, how? or known restriction of hivethriftserver? counterexam

Spring 4.3.0 + Tomcat : "Failed to load resource " message for static files -

i using spring mvc angularjs frontend. unfortunately, can't see static files when deploying in tomcat. my aim deploy angularjs frontend files , spring backend stuff single war file deployment in tomcat. i don't want use jsp nor spring xml files. this structure of eclipse maven folder : structure of webapp folder my index.html file contains following entries : <script type="text/javascript" src="bower_components/angular/angular.js"></script> <script src="bower_components/angular-route/angular-route.js"></script> <script src="bower_components/angular-xeditable/dist/js/xeditable.js"></script> <script src="bower_components/angular-resource/angular-resource.js"></script> <script src="js/app.js"></script> <script src="js/controllers.js"></script> <script src="js/services.js"></script> <link href="

nullpointerexception - Libgdx null Pointer -

i´m working on box2d jump , run game , want player teleported start when hits spike, when hits spike, null pointer exception. heres contact class: public class worldcontactlistener implements contactlistener { player player; @override public void begincontact(contact contact) { fixture fixa = contact.getfixturea(); fixture fixb = contact.getfixtureb(); player = new player(); int cdef = fixa.getfilterdata().categorybits | fixb.getfilterdata().categorybits; switch (cdef) { case hardwarerunner.player_bit | hardwarerunner.brick_bit: case hardwarerunner.player_bit | hardwarerunner.spike_bit: player.die(); } } and heres part of player class: public void defineplayer(){ bdef.position.set(32 / runner.ppm, (6 * 32) / runner.ppm); bdef.type = bodydef.bodytype.dynamicbody; b2body = world.createbody(bdef); fixturedef fdef = new fixturedef(); polygonshape shape = new polygonshape(); vector2[] vertice = new

r - How to compute integral of an array -

Image
i wondering if there way perform integral on arrays in r. have arrays s , r . want integrate them on pressure level ( p ) 1000 850. how can this? . the s , r , p data are s<-structure(c(0.0011979939772106, 0.0011979939772106, 0.0011979939772106, 0.00122851820731487, 0.00122654890214685, 0.00122457959697883, 0.00124164690843498, 0.00123705186304294, 0.0012324568176509, 0.00133617355649982, 0.00133617355649982, 0.00133617355649982, 0.00138048292278021, 0.00137752896502818, 0.00137457500727616, 0.00140575567243643, 0.00139951953940438, 0.00139328340637232, 0.00139820666929237, 0.00139820666929237, 0.00139820666929237, 0.00151308280409338, 0.00150192340814128, 0.00149076401218919, 0.00155575108273376, 0.00154426346925366, 0.00153277585577356 ), .dim = c(3l, 3l, 3l)) r<-structure(c(-15.1752538162522, -15.1929331135921, -15.2092524649828, -16.2142525214608, -16.2400914944961, -16.2604906837345, -17.2355719293295, -17.2641307942633, -17.2858899294509, -13.3842

c# - access tab1 viewmodel data in tab2 viewmodel -

i want access values of tab 1 in tab 2 using code below that. problem don't know how use value of tab 1 property in tab 2. xaml <grid> <tabcontrol> <tabitem datacontext="{binding children[0]}" x:name="tab1" header="tab1" > <checkbox content="checkbox" height="16" horizontalalignment="left" margin="176,132,0,0" name="checkbox1" verticalalignment="top" commandparameter="{binding ischecked, relativesource={relativesource self}, mode=oneway}" command="{binding resetpassword}" /> <!-- tab content --> </tabitem> <tabitem datacontext="{binding children[1]}" x:name="tab2" header="tab2" > <label content="{binding ischecked}" ></label> <!-- tab

How do I change the drawString font colour in java applet -

i have written paint method java applet , allows drawstring change colour whatever user inputs 3 text fields (r,g,b). default font colour black however, trying change green can't because font change colour have write g.setcolor(mixcolor). know how can make font colour start off green when run applet instead of black. import java.awt.*; import java.awt.event.*; import java.applet.*; public class text2 extends applet implements actionlistener { font textfont; textfield t1; textfield t2; textfield t3; int redcolor, greencolor, bluecolor; string as, ag, ab; button bttn; button bttn2; public void init() { // routine called system initialize // applet. sets font , initial colors // applet. adds button applet // changing message color. setbackground(color.lightgray); // applet filled background color before // paint method called. button , message // in applet appear on light gray background. redcolor=0; greencolor=0; bluec

mongodb - Is this scenario a big data project? -

i'm involved in project 2 phases , i'm wondering if big data project (i'm newbie in field) in first phase have scenario: i have collect huge amont of data i need store them i need build web application shows data users in second phase need analyze stored data , builds report , analysis on them some example data quantity; in 1 day may need collect , store around 86.400.000 record now thinking kind of architecture: to colect data asynchronous tecnology active mq , mqtt protocol to store data thinking nosql db (mongo, hbase or other) now solve first phase problems but second phase? i thinking big data sw (like hadoop or spark) , machine learning sw; can retrieve data db, analyze them , build or store in better way in order build reports , specific analysis i wondering if best approach how solve kind of scenario? in right way? thank you angelo as answered siddhartha, whether project can tagged bigdata project or not, depends on cont

linux - How do you output file size of multiple files in a directory using bash? -

the file extension .yuv there multiple files different extensions stored in same directory. use globbing du filesystem block based size: du -sh *.yuv ls actual file size: ls -l *.yuv

Can I share the import files with lots of python scripts -

i have lots of python scripts, share common module following sample how extract them file common_includes.py and in each python file, need require common_includes #!usr/bin/python3 # -*- coding: utf-8 -*- import requests import itertools html.parser import htmlparser lxml import etree import lxml import lxml.html html bs4 import beautifulsoup import json import requests import os import urllib.parse import urllib.request import urllib.error re import sub decimal import decimal pdb import set_trace import datetime import pymongo import yaml concurrent.futures import threadpoolexecutor create python file .py containing imports listed , make file name common_includes.py (from example) . when want link file other ones, include @ top. import sys sys.path.append(r'c:\users\python scripts') # filepath import common_includes # filename | not add .py you need use sys module

javascript - Angular2 routing canActivate and AuthGuard (JWT) with user role parameter -

in exaple project jwt authentication se how allow authenticated users route: import { routerconfig } '@angular/router'; import { home } './home'; import { login } './login'; import { signup } './signup'; import { authguard } './common/auth.guard'; export const routes: routerconfig = [ { path: '', component: login }, { path: 'login', component: login }, { path: 'signup', component: signup }, { path: 'home', component: home, canactivate: [authguard] }, { path: '**', component: login }, ]; i make step further , indicate user role have 'access' route - don't know how pass argument canactivate authguard (src) . achieve (for instance have 2 roles: admin , employee): { path: 'home', component: home, canactivate: [authguard] }, { path: 'users', component: adminusers, canactivate: [authguard('admin')] }, { path: 'users', comp

stata - Creating a flag using indexes -

i'm looking build flags students have repeated grade, skipped grade, or have unusual grade progression (e.g. 4th grade in 2008 , 7th grade in 2009). data unique @ student id-year-subject level , structured (albeit more variables): id year subject tested_grade 1 2011 m 10 1 2012 m 11 1 2013 m 12 2 2011 r 4 2 2012 r 7 2 2013 r 8 3 2011 m 6 3 2013 m 8 this code i've used: sort id year grade gen repeat_flag = . replace repeat_flag = 1 if year!=year[_n+1] & grade==grade[_n+1] /// & subject!=subject[_n+1] & id==id[_n+1] replace repeat_flag = 0 if repeat_flag==. one problem there lot of students took test in 6 grade, didn't take 1 in 7th , took 1 in 8th grade. varies across years , school districts, school districts adopted tests in differen

WCF hosted service library -

i looking on project uses wcf service library generates dll , dll added project has .svc file references wcf service library. i used have seperate wcf service application runs , can point url , debug code putting break points. straightforward. how debug service refereneces service library dlls , makes ajax calls?

Capturing Item clicks in listview vb.net -

i'm using following record items have been checked in listview. dim tert new arraylist each item in lvt.checkeditems tert.add(item.text) next dim message = string.join(environment.newline, tert.toarray()) the problem 1 item behind. example when check first item shows blank, second item shows first item , on. i'm using variable in oledb query having dynamic where clause need able capture clicks

php - orderBy in Laravel + jquery datatables -

Image
in database, here have i've tried query , order price $service_plans = db::table('service_plans') ->orderby('price', 'asc') ->get(); i kept getting did miss or did i'm not suppose here ? any hints ? p.s. keep in mind i'm using jquery datatables since you're using datatables jquery plug-in, remove orderby in controller query. instead, sort via datatables (which default): $('#datatable').datatable({ "order": [[ 2, "asc" ]] // order on init. # column, starting @ 0 }); there's nice little laravel package datatables set data. check , see if it'd useful: https://github.com/yajra/laravel-datatables

javascript - Node.js Passport not calling next function -

i'm building application using node uses passport.js handle user login using local database. so have following code gets called when user goes /profile. after logging in user gets redirected /profile. happen according morgan. app.get('/profile', passport.authenticate('local-login', { session : false, failureredirect : '/login' }), function(req, res) { console.log("testnow"); res.render('profile.ejs', { user : req.user // user out of session , pass template }); }); my local-login code following. passport.use('local-login', new localstrategy({ // default, local strategy uses username , password, override email usernamefield : 'email', passwordfield : 'password', passreqtocallback : true // allows pass entire request callback }, function(req, email, password, done) { // callback email , password our form // find user email same forms email // checking see if user t

Django/Python: Import once, use everywhere -

i have following structure views directory. views |--__init__.py |--a_management.py |--b_management.py |--c_management.py |--d_management.py |--e_management.py and __init__.py starts following: from a_management import * b_management import * c_management import * d_management import * e_management import * ......... ...etc... ......... in each of files ( a_management.py , b_management.py ...) need write same code importing modules: import sys,os django.shortcuts import render, redirect django.http import httpresponseredirect ......... ...etc... ......... is possible perform module imports in __init__.py ? when tried, still seems imports not found , errors like: nameerror: global name 'sys' not defined what using shared script system imports? btw, agree import * not greatest of idea. makes sense in use of importer , not sure in general setup. also, need careful circular imports. so, answer geared towards i need write same code importing modul

inheritance - Subclassing in python of instantiated superclass -

is possible subclass in python using instantiated superclass? i don't know how frame question let me give example. suppose have class rectangle , want build class coloredrectangle. don't want each coloredrectangle of same dimensions own new rectangle . when initiate coloredrectangle pass instantiated rectangle . ie., want r = rectangle([1,2]) r_red = coloredrectangle(r, "red") r_blue = coloredrectangle(r, "blue") but r_red , r_blue should able rectangle methods , attributes. example suppose rectangle had area() attribute. r.area 2 r_red.area 2 r_red , r_blue should "point" same rectangle . know writing: class coloredrectangle(rectangle): def __init__(self, rectangle, color): self.color = color self.rectangle = rectangle but i'd have write r_red.rectangle.area which ugly. inheritance inheritance such nice thing in python, , don't think have resort getattr hacks, if wan

javascript - Stop Sublime/Node.js shortening numbers -

when work big numbers sublime text 2 or node.js (i don't know 1 does) shortens big numers. example: var example = math.pow(2, 70); example = 1.1805916207174113e+21 i see full number (1180591620717411303424), don't know settings have change nor know find settings. it's nodejs that's "shortenting" these numbers. display large numbers in scientific notation, because javascript uses 64-bit floating point numbers. if you're referring displaying numbers not in scientific notation, i.e. 'x.xxxxxxxxxxe+yy', refer answer: how avoid scientific notation large numbers in javascript? if you're looking handle numbers larger 64-bit floats... javascript can't handle 64-bit integers, can it? and note mention of library "bignumber".

powershell - Sorting dates in a textfile -

i sorting text file has following pattern: moon|gamma|d5412|745|72|8:3:43:7:6:2016 bingo|denmark|4|4|985|12:11:43:7:12:2015 charlie|london|debb|517|10|7:15:43:6:5:2014 alpha|debra|devido|0|8745|6:33:43:23:6:2016 considering 7:3:43:7:6:2016 substring date in each line, need sort lines in ascending or descending order of dates. getting errors , unable sort text file. first, need split string delimiter | , grab last value each line: # index -1 last 1 $datestring = 'moon|gamma|d5412|745|72|8:3:43:7:6:2016'.split('|')[-1] you can use datetime.parseexact() static method parse input string sortable datetime object: [datetime]::parseexact($datestring,'h:m:s:d:m:yyyy',[cultureinfo]::invariantculture) now need put argument sort-object -property : get-content .\file.txt |sort-object -property { [datetime]::parseexact($_.split('|')[-1],'h:m:s:d:m:yyyy',[cultureinfo]::invariantculture)} default sort order of sort-object ascen

Login to website using jsoup in android returning login page instead of home page -

i have used input tags fields name source , tried possible ways using jsoup connect each time output html page showing in log.e same login page. protected void doinbackground(void... params) { try { connection.response loginform = jsoup.connect("http://adsl.yemen.net.ye/en/login.aspx") // .useragent("mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.103 safari/537.36") .method(connection.method.get) .execute(); loginform= jsoup.connect("http://adsl.yemen.net.ye/en/login.aspx") .data("ctl00$contentplaceholder1$loginframe$username", "masalahi2010") .data("ctl00$contentplaceholder1$loginframe$password", "mamam") // .data("ctl00$contentplaceholder1$loginframe$rememberme","true") .data("ctl00$contentplaceholder1$loginframe$loginbut

MATLAB:how can I use fprintf or sprintf to print matrix and vectors with strings togheter? -

i'm @ beginning matlab software ,and have 2 questions: 1) if want print matrix, preceeded string, using fprintf command, how can do? example, print matrix alone, use fprintf([repmat('%d\t', 1, size(r, 2)) '\n'], r'); but how can print string followed matrix, togheter in fprintf, without usind disp function ? example, if want print: >>the matrix inserted [1 3; 4 6] 2) how can same thing vectors (i know it's particular case of matrix) ? use, example: >>vectorname=[1 5 2]; >>strtrim(sprintf('%d ', vectorname)); and it's ok numbers of vector, if insert string in spintf result is: >>vectorname=[1 5 2]; >>strtrim(sprintf('your vector is: %d ', vectorname)) >>your vector 1 vector 5 vector 2 how can inglobe numbers, 1 ofter other, 1 command (sprintf, fprintf, ecc.)?? thank help! in both cases can use mat2str . first case: input_mat = [1 3; 4 6]; sprintf(

Powershell Out-file not working -

i have powershell script gathers file information on remote servers. when writing console, see results fine, don't seem getting written specified out-file: out-file -filepath $filepath -inputobject $date -force -encoding ascii -width 50 foreach($server in $serverlists) { $result += $server $result += $break foreach($filepath in $filepaths) { $result += $filepath $result += $break $command = "forfiles /p " + $filepath + " /s /d -1 > c:\temp\result.txt" $cmd = "cmd /c $command" invoke-wmimethod -class win32_process -name create -argumentlist $cmd -computername $server sleep 2 $result += get-content \\$server\c$\temp\result.txt $result += $break $result += $break write-host $result #out-file -filepath $filepath -append -inputobject $result -encoding ascii -width 200 remove-item \\$server\c$\temp\result.txt } $result += $break } out-file -filepath $filepath -append -inputobject $result -encoding

osx - Open searched files from the terminal -

in terminal have used find command search files containing word xyz. find . name "*xyz*" this gives me 2 results. ./xyz123.pdf ./uvwxyz.pdf is there command open first or second result immediately? open(1) open[1] or something? instead of open xyz123.pdf

sql - UPDATING column with column from different table with no correlation between the tables -

i have 2 tables. one called tcolor has 2 columns. 1 called "id" , other called "color" color column filled hex color values. id column null values. i have table in same database called testg. testg has 1 column called "id". i want update (not insert) tcolor's id column using testg's id column. how without getting ora-01427 error? also, ids testg, used query below. there way change query update statement wont have pull 1 column 1 table other. what mean is, taking query, converting update statement, can directly update tcolor id column. insert testg (id) select distinct terr_id (select distinct jta.terr_id, jta.name, low_value_char, comparison_operator, high_value_char, jtva.last_update_date, jtva.creation_date jtf_terr_values_all jtva, jtf_

Is it possible to submit more than 1 choices in "set /p choice" in batch programming? -

so here code, try explain problem little better. @echo off cls title sold products :start echo products echo. echo. echo 1) product1 2) product2 echo. echo 3) product3 4) product4 echo. echo 5) product5 6) product6 echo. set /p products= products have been sold?: echo %products% >> products.txt goto start basically need is.. instead of choosing 1 product time, able choose more 1 , append them on txt file... product1 , product2. p.s. sry bad english....

python - Django orm filter is an element of dict -

i'm trying set dict of filters orm queryset. here dict: section = self.kwargs['section'] # hot or new or trending threshold = {'hot': 'post_upvotes > 50', 'trending': 'post_upvotes__range=(20,50)', 'new': 'post_upvotes < 20'} return post.objects.filter(threshold[section]) but doesn't work. how can achieve ? try this: from django.db.models import q threshold = { 'hot': q(post_upvotes__gt=50), 'trending': q(post_upvotes__range=(20,50)), 'new': q(post_upvotes__lt=20) } return post.objects.filter(threshold[section]) read more q objects: https://docs.djangoproject.com/en/1.8/topics/db/queries/#complex-lookups-with-q-objects

bufferedreader - A Little complicated Java case - What is the fastest way to write calculations data onto a file -

i using bufferedreader (br) , bufferedwriter (bw) read large file, calculations, , write results on output file. output file have same number of lines in input file. what doing getting data input file line line (while br.readline() != null), calculations of line read, write result of single calculation onto output file (br.write) write new line (bw.newline()). loop repeats until reaches end of file. this works not bad.. takes me 1 second process 3500 input lines. have been told 2 code tested larger files. best practice should use (both read , write)? can keep results chunks in buffer until specific limit write actual file? edit: think reading/performing calculation part good, how writing keeping parts in buffer writing output file? there way avoid writing every iteration?

html - Add a row to a nested flex container on media query -

Image
i have 1 primary container holds div s using flex-direction of row. a second container nested holds 2 div s have flex-direction of column, stack 2 div s in 1 row in outer container. using flex-box , media query, attempting change existing 2 row column div 'smaller-container' 3 row column div once browser width less 1000px. i tried doing creating third empty div within smaller-container and swapping order div outside smaller-container once browser width less 1000px. it didn't work. think because 2 div s in question (the empty div , outer div) @ different nesting level. it great if can find solution turn 2 row in 1 column 3 row in 1 column. even better if solution has no need of nested container. javascript solution welcome if doesn't require plugin. image of how should look: /*basic reset*/ * { box-sizing: border-box; margin: 0; padding: 0; } html, body { height: 100%; } body { max-width: 1366px; margin: auto;

uppercase - Convert string to Upper and Lower case Turbo Prolog -

how convert string upper , lower case in turbo prolog. string_upper , string_lower function swi prolog, i found like, tolower([], []). tolower([upper|uppertail], [lower|lowertail]) :- char_type(lower, to_lower(upper)), tolower(uppertail, lowertail). but didn't is. can me solve this. i did using upper_lower(), write("enter string convert\n"), readln(str1), upper_lower(str1,low), write("in lower case "), write(low),nl, write("in upper case "), upper_lower(upp,str1), write(upp). the upper_lower predicate: upper_lower predicate can used convert uppercase characters lowercase, or lowercase letters uppercase. general form of predicate upper_lower(uppercasestring, lowercaseuppercasestring)

multithreading - Python - Multiprocessing Pool Class: Can the Thread Function contain arguments? -

i want know if possible pass arguments threading pool funktion? from multiprocessing.dummy import pool threadpool def mainfunc(): myarray = ["a", "b", "c"] pool = threadpool(8) pool.map(threadfunc, myarray) # how possible give >>threadfunc<< argument >>text1<< pool.close() pool.join() def threadfunc(text2): text1 = "hello " # should given argument of function print text1 + text2 mainfunc() this simple example of want do.. how can give text1 second argument threadfunc function? solved: i solved problem simple global accessible variable ... solution problem had right ... greater idea use multiprocessing.process instead ... import sys multiprocessing.dummy import pool threadpool = sys.modules[__name__] def mainfunc(): myarray = ["a", "b", "c"] this.text1 = "hello " pool = threadpool(8) pool.map(thr

xslt - Use dynamically created xsl:variable in select (Sharepoint 2013) -

This summary is not available. Please click here to view the post.

CSS form not applying -

i have form: <div class="jumbotron" id="jumbotron-6" align="center"> <form action="login.php" method="post"> <input type="text" placeholder="enter email" name="email"> <input type="password" placeholder="and password" name="password"> <input type="submit"> </form> </div> and trying apply css it: input [type="text"], input [type="password"] { outline: none; padding: 10px; display: block; width: 300px; border-radius: 3px; border:1px solid #eee; margin:20px auto; } but not applying. have css linked page too. remove spacing input[....] input[type="text"], input[type="password"] { outline: none; padding: 10px; display: block; width: 300px; border-radius: 3px; border:1px solid #eee; margin:2

shipping - When to use QUOTE on Shippo -

when creating objects on shippo , there's object_purpose attribute allows select either quote or purchase. can see purchase labels meant bought , used in end, when should use quote only? it's fine use purchase objects. remember, complete / address required. you should use quote when don't intend buy label - such getting rates show buyer or doing shipping estimate. benefit of using quote rates can retrieved using less information (such passing zip codes), since the full street address not required.

java - do while loop for text file not functioning -

i need read in text file unknown number of questions. formatting same, number of options not. have taken care of loop. if remove while, code fetches 1 of questions , stores it, need loop. code won't compile loop. have tried many fixes, won't compile. any advice appreciated! filereader filereader = new filereader(f); bufferedreader bufferedreader = new bufferedreader(filereader); string line; { line = bufferedreader.readline(); string question = line; line = bufferedreader.readline(); int numoptions = integer.parseint(line); arraylist<string> options = new arraylist<>(); (int = 0; < numoptions; i++){ line = bufferedreader.readline(); string choice = line; options.add(choice); } line = bufferedreader.readline();

java - How to map Windows API CredWrite/CredRead in JNA? -

i'm trying map credwrite/credread in jna in order store thrid party credential used in java application in windows credential manager (os windows 10). here're original signatures in c: // https://msdn.microsoft.com/en-us/library/aa375187(v=vs.85).aspx bool credwrite( _in_ pcredential credential, _in_ dword flags ); // https://msdn.microsoft.com/en-us/library/aa374804(v=vs.85).aspx bool credread( _in_ lpctstr targetname, _in_ dword type, _in_ dword flags, _out_ pcredential *credential ); typedef struct _credential { dword flags; dword type; lptstr targetname; lptstr comment; filetime lastwritten; dword credentialblobsize; lpbyte credentialblob; dword persist; dword attributecount; pcredential_attribute attributes; lptstr targetalias; lptstr use

c++ - Sounds not playing on my code -

i learning sfml library version 2.2, sounds won't playing. compile, , run program on ubuntu 14.04. here's program #include "sfml/audio.hpp" #include <stdio.h> #include <iostream> using namespace std; using namespace sf; soundbuffer buffer; sound audio; int main(int argc, char* argv[]) { if(buffer.loadfromfile(argv[1])) cout << "sounds loaded" << endl; audio.setbuffer(buffer); audio.setvolume(100); audio.play(); cout << "yay!" << endl; return 0; } and here's compiling code: g++ testaudio.cpp -i <my directory>/sfml-2.2/include/ -l <my directory>/sfml-2.2/lib/ -lsfml-audio -lsfml-system -o testaudio there's no error in compiling when run program, sounds not coming out. checked volume, nothing has change. the sfml sound tutorials sounds , music play in separate thread. what's happening program runs, starts playing sound on separ

mysql - Spring Boot Transactions not working -

if write interface repository , implement crudrepository, there no problem persisting data. but if don't use crudreposity , write own implementation, data fetch works fine when save data below exception.. caused by: javax.persistence.transactionrequiredexception: no transactional entitymanager available @ org.springframework.orm.jpa.sharedentitymanagercreator$sharedentitymanagerinvocationhandler.invoke(sharedentitymanagercreator.java:275) @ com.sun.proxy.$proxy59.persist(unknown source) @ com.eorganiser.commons.repositories.generic.simplejpagenericrepository.persist(simplejpagenericrepository.java:48) @ com.eorganiser.commons.repositories.generic.simplejpagenericrepository$$fastclassbyspringcglib$$12bdea51.invoke(<generated>) @ org.springframework.cglib.proxy.methodproxy.invoke(methodproxy.java:204) @ org.springframework.aop.framework.cglibaopproxy$cglibmethodinvocation.invokejoinpoint(cglibaopproxy.java:717) @ org.springframework.aop.framework.reflectivemethodinvocat

tensorflow - Is it possible to precompile graphs then run in parallel? -

i following cs224d code recursive neural networks (see: http://cs224d.stanford.edu/syllabus.html pset 3 solutions) how code works new graph compiled each training example since each tree has different shape, suboptimal running minibatches, etc. have similar recursive graph larger input, need solution more parallelizable. i have idea precompile graphs , load them asynchronously along data gpu, similar how queue works. offload minibatch of results, compute combined gradients, back-propagate. idea can account variable input, , take advantage of gpu (have cake , eat too). is feasible?

computer science - managed code vs unmanaged code -

i'm trying mind wrapped around concept of managed vs unmanaged code. correct me if i'm wrong managed code gets compiled down bytecode while unmanaged code gets compiled down machine code. is correct? from annakata's answer: managed code not compiled machine code intermediate language interpreted , executed service on machine , therefore operating within (hopefully!) secure framework handles dangerous things memory , threads you. in modern usage means .net not have to. unmanaged code compiled machine code , therefore executed os directly. therefore has ability damaging/powerful things managed code not. how used work, typically it's associated old stuff .dlls now, what's going on under hood? managed vs unmanaged all memory . in managed code, code doesn't directly manipulate memory. gives instructions runtime on code's behalf. way, unsafe or illegal operations can blocked, , code operates in semi-sandbox. managed lan

python - Numpy using smaller 2D array to map with bigger array with more elements -

i have smaller array as: a = np.array([2011, 2014, 2015, 2016, 2017]) aval = np.array([14, 10, 35, 40, 45]) i have array: a2 = np.array([2013, 2014, 2015, 2014, 2015, 2016, 2016, 2016, 2017]) i want create a2val such that: arval = np.array([10, 35, 10, 35, 40, 40, 40, 45]) so, trying use values in array map elements of a2 , generate extended version of a2val please note 2011 present in a, 2013 in a2 not in a2 , respectively. can use following suggested in thread: aval[np.searchsorted(a,a2)] but doesn't produce answer looking for. here 1 way: >>> aval[np.searchsorted(a, a2[np.nonzero(np.in1d(a2, a))[0]])] array([10, 35, 10, 35, 40, 40, 40, 45]) note getting expected indices in default order second array pass searchsorted() should contain common items first array.

android - Accessing an audio file in the RAW folder -

i have created new java file within project , trying access war audio file in raw folder. have idea doing wrong? mediaplayer mediaplayer; context context; public audio() { int resid = context.getresources().getidentifier("morse","raw",context.getpackagename()); context.getresources().openrawresource(resid); mediaplayer = mediaplayer.create(this.context, resid); } you have failed start media player. try following code, mediaplayer mediaplayer; context context; public audio() { int resid = context.getresources().getidentifier("morse","raw",context.getpackagename()); context.getresources().openrawresource(resid); mediaplayer = mediaplayer.create(this.context, resid); //start media player mediaplayer.start(); } hope helps!!!...

csv - How to dissolve polygon in R and transferring original attribute information -

i want dissolve polygons, , doing following: batching in shapefile (da.shp - sensitive information hence first 2 sample records , first 3 columns shown) batching in csv file called zone.csv has information dissolving joining zone.csv da (first 5 records shown due sensitivity) dissolving joined shapefile creating row ids make dissolved shapefile polygondataframe export. it goes smoothly, however, want carry zed , criteria fields in dissolved polygon, 1 can using gis. have tried search in vain, appreciated. library(rgeos) library(rgdal) library(sp) # set working directory wd <- setwd("c:/personal/r") # read da shapefile da <- readogr(wd, "da") plot(da) crs.shp <- proj4string(da) da@data[1:2,1:3] # check first 2 records objectid dauid cduid 0 3 35204831 3520 1 5 35180720 3518 # batchin text file zone numbers zones.csv <- read.csv(file="c:/personal/r/variant1.csv", header=true, sep=",") zones.csv