Posts

Showing posts from July, 2015

java - Installation for a college DBMS Project -

i have created simple database application part of college assignment. have used java (eclipse ide) , mysql (command-line , phpmyadmin) purpose of creating , using database on stand-alone application. thing database stored on localhost . an easy way make application usable on person's computer convert executable jar (since, using java). however there way means of can install database directly other person's computer (on localhost )? something installer or so? i read online simple thing manually install mysql , create database. don't know php , typing mysql commands / using phpmyadmin choice. there better way go doing it? thanks help. edit1: don't know if helps have no previous knowledge regarding creating installers projects. have done until has been exported either executable jar or source code. still studying. edit 2: creating installation java project <- similar question not cause. recommends not using mysql. our college has compulsorily asked u

android - How to allow copy and paste from an ionic webview? -

i using ionic , cordova build hybrid application. however, can't copy text of webviews. android phone or browser, copying text not work. selecting text , dragging pointer nothing. this occurs instance basic app generated ionic start myapp tabs . simply put, how can allow users copy-paste? make ion-content overflow-scroll="true" , add class copyable text .selectable{ -webkit-user-select: auto; } you cannot copy clipboard javascript programmatically. can done native side via plugin cordovaclipboard

java - Is collection synchronizing (via Collections.synchronizedX) necessary when access methods are synchronized? -

there lot of topics when synchronization in java appears. in many of them recommended using invokation of collections.synchronized{collecation, list, map, set, sortedmap, sortedset} instead of collection, list, etc. in case of multithreading work thread-safe access. lets imagine situation when threads exist , of them need access collection via methods have synchronized block in bodies. so then, necessary use: collection collection = collections.synchronizedcollection(new arraylist<t>()); or only collection collection = new arraylist<string>(); need to? maybe can show me example when second attempt instead of first cause evidently incorrect behaviour? to contrary, collections.synchronizedcollection() not sufficient because many operations (like iterating, check add, etc.) need additional, explicit synchronization. if every access collection done through synchronized methods, wrapping collection again syncronized proxy useless.

jquery - Get ID of .selected class without clicking -

i want id of link has been classed .selected. found several solutions don't work or include click function , 'this'. don't want use click functions because when open page, 1 link selected. this list, preferably id of list , not link <ul id="dates"> <li id="all"><a id="all" href="#all">1943-2003</a></li> <li id="li1943" ><a id="a1943" href="#1943">1943</a></li> <li id="li1953" ><a id="a1953" href="#1953">1953</a></li> <li id="li1963" ><a id="a1963" href="#1963">1963</a></li> <li id="li1973" ><a id="a1973" href="#1973">1973</a></li> <li id="li1983" ><a id="a1983" href="#1

javascript - datepicker/moment.js ? displaying wrong date in my locale -

Image
im integrating twitter bootstrap datepicker plugin, im having trouble it. the plugin in question this: http://eonasdan.github.io/bootstrap-datetimepicker/ it works fine default configuration(uses 'en' language default). when try use different localization example 'lv' shows wrong date. day , month flipped(shows current time july 6 not april 4 correct in location). checked other localizations , seems wrong too, in plugins documentation page, 'ru' localization example has same problem. correct wrong for localization plugin uses moment.js, (it support 'lv' localization) included. any idea wrong? thanks help! managed fix providing date format mm-dd-yyyy hh:mm. thanks checked out.

c++ - Having trouble with compiling this code -

i'm working on simple glfw project. find need both <gl/glfw.h> , <gl/glfw3.h> headers able use things. when include both of these headers together, i'm getting error: error: conflicting declaration 'typedef void (*glfwwindowsizefun)(glfwwindow*, int, int)' and points glfw3.h source code there exact typedef above. has ever experienced this? how go fixing it? why think need both glfw.h , glfw3.h ? don't. headers different versions of glfw library. use header library version want use (and 1 link).

javascript - Updating button text with sliding text from top -

Image
i trying update button text on click sliding new text top. "pushes" text , appear. i've managed that, when background darker, can see text appearing outside button . how solve ? , can't lower top value since otherwise text still visible when removed dom. here code: var = 1; $('a').on('click', function (event) { var $el = $(this); $('span').animate({ 'top': '+=20px' }, 250, function () { $el.html(''); i++; $el.prepend('<span class="b" >' + + '</span>'); $('.b').animate({ 'top': '+=20px' }, 250); }); }); css : span { position: relative; } .b { top: -20px; } jsfiddle here is there way cut text when bigger container ? so: use overflow: hidden on tag. http://jsfiddle.net/qg4cx/12/ a { overflow: hidden; }

c# - Reading XML with a colon (:) -

i'm trying views of video following xml document ( https://gdata.youtube.com/feeds/api/videos?q=example ), i'm able link , autor because there no colon in tag. i'm trying yt:statistics i've no idea how. result = e.result.replace("xmlns='http://www.w3.org/2005/atom' ", string.empty); xmldocument doc = new xmldocument(); doc.loadxml(result); xmlnodelist videos = doc.getelementsbytagname("entry"); foreach (xmlnode video in videos) { xmlnode insideauthor = video.selectsinglenode("author"); string videoid = video.selectsinglenode("id").innertext.replace("http://gdata.youtube.com/feeds/api/videos/", string.empty); string author = insideauthor.selectsinglenode("name").innertext; // trying views of video of search results messagebox.show(video.selectsinglenode("yt:statistics").attributes["viewcount"].innertext);

ios - Save CMSampleBufferRef Before Sending it to AVAssetWriter -

i trying save samples in didoutputsamplebuffer delegate before writing album avassetwriter . this code saving samples: .h file @property (nonatomic) nsinteger audioindex; @property (nonatomic) nsinteger videoindex; @property (nonatomic) cmtime starttime; @property (nonatomic) cfmutablearrayref audiosamples; @property (nonatomic) cfmutablearrayref videosamples; .m file cfretain(samplebuffer); if (cmsamplebufferdataisready(samplebuffer)) { if (self.videoindex == 0) { self.starttime = cmsamplebuffergetpresentationtimestamp(samplebuffer); } if (bvideo) { int count = 0; count = (int)cfarraygetcount(self.videosamples); if (count >= 1000) { cfarraysetvalueatindex(self.videosamples, self.videoindex, samplebuffer); } else { cfarrayappendvalue(self.videosamples, samplebuffer); } self.videoindex = (self.videoindex + 1) % 1000; } else { int count; count =

c# - Returning the time of the first activity -

i have table, stores of activities of day. want able pull time of first activity of today. however, query isn't returning values. have checked data , looks stored correctly within table (text field / days , months in right place). ideas doing wrong? select min(activity_start) exprstart tblactivity [activity_start] between date('now') , date('now', '+1 day')" thank you. your activity_start format ' %d/%m/%y %h:%m:%s ' date('now') returns strftime('%y-%m-%d', 'now') . comparatives in wrong format! try below; select min(activity_start) firstactivity tblactivity activity_start >= strftime('%d/%m/%y', date('now'))

algorithm - How to find elements in a 2 dimensional array with the biggest sum? -

i need find elements of 2 dimensional array maximal sum. array have n rows , 13 columns, maximal count of elements in row 4 , count of elements in column must 2. tried use iteration through combinations, there more combinations (10^27) long.max_value , when tried recursion caused stackoverflow. examples of possible solutions: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |x|x|x|x|_|_|_|_|_|_|_|_|_|m=4 |_|x|_|_|_|x|x|_|_|_|_|_|_| m=3 |x|x|x|x|_|_|_|_|_|_|_|_|_|m=4 |_|_|_|x|x|_|_|x|_|_|x|_|_| m=4 |_|_|_|_|x|x|x|x|_|_|_|_|_|m=4 |_|x|x|x|_|_|_|x|_|_|_|_|_| m=4 |_|_|_|_|x|x|x|x|_|_|_|_|_|m=4 or |x|_|_|_|_|_|x|_|_|x|_|x|_| m=4 |_|_|_|_|_|_|_|_|x|x|x|_|x|m=4 |_|_|_|_|x|_|_|_|x|x|_|_|_| m=4 |_|_|_|_|_|_|_|_|x|x|x|x|_|m=4 |x|_|_|_|_|_|_|_|x|_|x|_|x| m=4 |_|_|_|_|_|_|_|_|_|_|_|x|x|m=4 |_|_|x|_|_|x|_|_|_|_|_|_|_| m=3 |_|_|_|_|_|_|_|_|_|_|_|x|x| m=2 m maximal count of elemnts in first

signal processing - How to implement the order analysis in MATLAB -

Image
i have audio file represents sound of motor. i've been reading 'normal' fft doesn't deliver valuable analysis machine, , should use order analysis describe 'behavior' of machine. recorded sound while incrementing speed, , put records , calculated spectogram. here code that: %% read audio file , plot clear, clc , clf; m = 512; k =1 data= 0 ; =100:5:180 filename =['a10_usp0_mic100k_2nd_v_',int2str(i),'.wav'] [x(:,k),fs] = audioread(filename); k = k+1 ; end = 1:length(x(1,:)) data = [data(:);x(:,i)]; end k = length(x(1,:)); while k ~= 2 data = [data(:);x(:,k)]; k = k -1; end spectrogram(data,hamming(m),m/2,0:20:4000,fs,'yaxis'); and result looks like: as might able see, incremented speed of machine 5 each timepoint. question how calculate order analysis system!? help! this more of scientific question question programming. order analysis can done using fourier transform. need looking

ios - Getting UIImage to work from JSON -

i'm having issue getting uiimage work json received. here let's take @ json [ { node_title: "fumi", node_uid: "11", users_node_name: "pae", nid: "7", body: "<p>this fumi restaurant</p> ", enterprise address: "99/9", enterprise email: "fumi@gmail.com", enterprise tel: "08111111", enterprise logo: "<img typeof="foaf:image" src="http://localhost/drupal/sites/default/files/fumi.jpg" width="300" height="300" alt="" />" }, { node_title: "fuji", node_uid: "8", users_node_name: "testent", nid: "1", body: "<p>fuji</p> ", enterprise address: "somwhere belong", enterprise email: "ent1@mail.com", enterprise tel: "02-999-9999", enterprise logo: "<img typeof="foaf:image" src="http://localhost/drupal/sites/default/file

Django template tag to show null date as "still open" -

i have following code in django template: {{date_from|date:"y-m"}} - {{date_to|default_if_none:"still open"|date:"y-m"}} i get: "2012-08 - " "2012-11 - 2012-08" .. rest of values correctly displayed. i this: "2012-08 - still open" "2012-11 - 2012-08" .. rest of values correctly displayed. do have suggestions? think not displayed because date object. change order of filters. use default instead of default_if_none ( date filter return empty string non-date/datetime object) >>> t = template('{{date_to|date:"y-m"|default:"still open"}}') >>> t.render(context({'date_to': none})) u'still open' >>> t.render(context({'date_to': datetime.datetime.now()})) u'2014-04'

how to write a C function and be able to call it from perl -

i have been programming c while. need write c program perl can call. should have same syntax following dummy perl function: take 2 inputs, both strings (may contain binary characters, "\x00"), output new string. of course, algorithm of function more complex, that's why need in c. sub dummy { ($a, $b) = @_; return $a . $b; } i have briefly looked @ swig implementation, taking input/ouput other integer not easy, hope can give concrete example. thanks in advance. update : got great example rob (author of inline::c module in cpan), thanks! ############################## use warnings; use strict; use devel::peek; use inline c => config => build_noisy => 1, ; use inline c => <<'eoc'; sv * foo(sv * in) { sv * ret; strlen len; char *tmp = svpv(in, len); ret = newsvpv(tmp, len); sv_catpvn(ret, tmp, len); return ret; } eoc $in = 'hello' . "\x00" . 'world'; $ret = foo($in); dump($in); prin

javascript - Variable Number of Divs Equally Spaced Vertically in a Container Div -

i looking this vertically instead of horizontally. have tried solution here want child divs equally space on entire height of container div - solution centers divs without expanding space in between them use entire height of container. willing use javascript, prefer html/css solution. i've looked briefly flexbox, scared off backwards compatibility issues. some basic code: <div id="parent"> <div id="1" class="child"></div> <div id="2" class="child"></div> <div id="3" class="child"></div> </div> should render div1 @ extreme top of parent, div 2 @ extreme bottom of parent, , div3 centered in middle, , ideally add variable number of additional child divs , spacing automatically adjust. any suggestions? should use flexbox , not worry supporting older browsers? i have worked javascript. javascript code is function cssfunction(){

virtualbox - Vagrant networking error when following docs -

i'm getting error: there errors in configuration of machine. please fix following errors , try again: vm: * ip required private network. when follow documentation: http://docs.vagrantup.com/v2/networking/private_network.html , specify want dhcp assign ip address so: config.vm.network "private_network", type: "dhcp" anyone know how working? edit: i have tried: config.vm.network :private_network, type: :dhcp which works , assigns ip address of 10.0.2.15 , don't understand dhcp server assigns addresses in 192.168.1.x range? stuff ever work anyone? if want vagrant box pull same dhcp host box does, use line in vagrantfile: config.vm.network :public_network, :auto_config => true this corresponds vbox bridged network, sounds want. edit : added auto_config bit. should ask adapter want use when boots; can specify :bridge => "en1" (or whatever adapter happens named; en1 macbook's usb ethernet) on line hard-cod

python - How to find a root for a mathematical function using Intermediate value theorem? -

accroding intermediate value theorem given function f(x), i'm supposed write function, gets mathematical function, 2 numbers , b , , error range, , gives output number x functions' value close 0 epsilon. examples: >>> find_root(lambda x : x - 1 , -10, 10) 1.0009765625 >>> find_root(lambda x : x**2 , -10, 10) >>> #returned none this code wrote far, think i'm on right way, can't figure out loop over, don't correct answer code. should fix in it? def find_root(f, a, b, eps=0.001): if (f(a)*f(b))<0: in range(a,b): if f(i)<eps: return (i) else: return (none) use dichotomy : def find_root(f, a, b, eps=0.0001): if f(a)==0 : return if f(b)==0 : return b if f(a)*f(b)>0 : return none c=(a+b)/2 while(abs(f(c))>eps) : if f(a)*f(c)<0 : b=c else : a=c c=(a+b)/2 return c

git - I need help resetting my repository -

i have private repository on bitbucket use developing app on laptop , desktop. on laptop started working on new branch called bootstrap . cloned origin/master . unfortunately, forgot publish local master first. not realizing this, made 3 commits remote. made commits origin/master , remote not have bootstrap branch. i tried push local master commits, tells me have 3 incoming commits. didn't realize of until pulled on desktop , mess. have no idea how proceed fix , desperately need help. everything mess then don't touch it. clone again repo in local repo: @ least, reset. add first local repo remote second: git remote add first ../firstrepo git fetch first then: make bootstrap branch in new local repo: git checkout -b bootstrap through nice log : git log --oneline --graph -all --branches , seek new commits in remotes/first , , cherry-pick them current bootstrap branch.

javascript - Slide multiple divs to side as one -

i trying make navigation bar displayed in line. sake of question have created this fiddle. hide red divs 1 div 1 side clicking on black div . put red divs 1 <div class="box"></div> , tried slide box div . messes up. instead of going side train expands multiple rows , hides. slide divs of class slide looks this . not want, because hides each 1 on own. this might work you fiddle js: state = true; $('.clickme').click(function () { if (state) { $("#inner").animate({ left: '-100px' }, "slow"); state = false; } else { $("#inner").animate({ left: '0px' }, "slow"); state = true; } }); html: <div class="clickme"></div> <div id="outer"> <div id="inner"> <div class="slide"></div> <div class="slide

java - SQL Injection and possible attacks -

hi have following query part of java class. want know possible attacks possible sql injection. how attacker can inject queries? sample queries in case can used gain access database? string query = ("select username, password, admin users " + "username='" + username + "' , password='" + password + "'"); resultset rs = st.executequery(query); // entry in result set means query successful , //the user valid user if (rs.next()) { username = rs.getstring(1); isadmin = rs.getboolean(3); i think possible way of attack putting username abc';# since after # considered comment in sql. others think it? i want know attacker entering in username box , password box of html page gain access administrator. assuming job of above java class process request of users's input html page querying database. basically works https://xkcd.com/327/ what assuming, user inputs threat,

mysql - sql syntax error while using top query -

i'm using top query table facing error you have error in sql syntax, chekck manual corresponds mysql server version right sytntax use near '4 * sitemain order siteid desc limit 0,30' @ line 1 here code used select top 4 * sitemain order siteid desc you mixing mysql , tsql syntax together. query mysql (from error message). want is select * sitemain order siteid desc limit 0,4

android - How to set OnPageChangeListener for Multiple ViewPagers -

i using loop define viewpagers: linearlayout llmain; pageradapter[] padapter = new pageradapter[20]; viewpager[] pager = new viewpager[20]; for(int i=0;i<20;i++){ padapter[i] = new awesomepageradapter(); pager[i] = new viewpager(this); pager[i].setadapter(padapter[i]); ifinawesomepager[i].setonpagechangelistener(new onpagechangelistener() { @override public void onpagescrollstatechanged(int arg0) {} @override public void onpagescrolled(int arg0, float arg1, int arg2) {} @override public void onpageselected(int arg0) { //which 1 of viewpagers has been changed here? } }); llmain.addview(pager[i]); } how know 1 of viewpagers changed in onpagechangelistener() ? thanks! i using loop define viewpagers that unusual pattern. how know 1 of viewpagers changed in onpagechangelistener() ? create class implements onpagechangelistener . have class take viewpager in co

match - Comparing/ Matching elements of 2 vectors by MATLAB -

i compare/match elements of 2 vector data, the goal select elements element-wise 2 vectors different not greater 3 . output 2 new vector have same length , elements arranged in order. size of 2 vectors (before processed) arbitrary. ex. = [11 38 49 84 96 117 157 176 200]; b = [10 28 37 48 84 157 175 200]; compare element abs(a(i) - b(j)) <= 3 output should a_new = [11 38 49 84 157 176 200] b_new = [10 37 48 84 157 175 200] can guide me how write matlab code problem? used 2 nested loop got stuck empty set fault. thank you.

keypress - C# check for Vowel -

this question has answer here: listen key press in .net console app 8 answers i want check if user input vowel. if other key pressed, error should shown. here's have far. how can add other keys? current output: "key pressed" a static void main(string[] args) { consolekeyinfo a; while (true) { = console.readkey(); if (a.key == consolekey.a); { console.writeline("a"); } } } you can try this: protected override bool processcmdkey(ref message msg, keys keydata) { if (keydata == keys.f3) { //do something; } if(keydata ==keys.escape) { //do something; } if(keydata ==keys.f

php - MySQL query for two way relationship -

for social web application needed create mysql table in following way, id | user_id | friend_id ------------------------ 0 | 5 | 6 1 | 6 | 5 user 5 , user 6 friends. how can list of friends particular user. point me in right direction please? select f1.user_id, f2.user_id 'friend' friends f1 left join friends f2 on f1.user_id = f2.friend_id for more information please refer post what's difference between inner join, left join, right join , full join?

C++ Create file if argc==2? -

i cannot figure out wrong here... want code create file when type 1 argument in terminal. works fine if argc set 1, not above that. appreciated ! cheers & nice sunday #include <fstream> #include <string> #include <iostream> using namespace std; int main(int argc, char* argv[]) { if (argc==(2)) { ofstream file("myfile.txt"); // creates myfile.txt } else { cout << "type 1 argument !" << endl; } return 0; } if using visual studio answer : go project/properties, select "debugging" tab, , enter arguments in "command arguments" field.

php - How to prevent an error to display to user -

i have simple code sending mails. sometime $host might not available or smtp server might down happens in these cases swiftmailer throws lot of exceptions , $result despite of returning true or false give me complete mess of errors. so how can turn off errors page of code but not whole library ? $transport = swift_smtptransport::newinstance(self::$host, 25) ->setusername(self::$username) ->setpassword(self::$password); //create mailer using created transport $mailer = swift_mailer::newinstance($transport); $message = swift_message::newinstance("custom sheets"); $message->setfrom(array('edb@abc.com.pk' => 'approval of custom duty sheet')); $message->setto($to); $message->setbody($html,'text/html'); //send message $result = $mailer->send($message); you can catch exception , handle it: try { $transport = swift_smtptransport::newinstance(self::$host, 25)

java - Is there a better way to connect two JPanels? -

netbeans project , source code of minimal example is there better way connect jframe jpanel class other making fields of jpanel public? i writing program there going option button, when button pressed custom joptionpane.showoptiondialog brought jpanel inside hold specific options user wants. when user presses joptionpane.ok_option button program closes optiondialog jpanel inside , returns jframe . need whatever inputted in jpanel used in jframe class. did making text fields of jpanel public feel cheap way of doing since netbeans not let me unless opened source in notepad. also totally ok if joptionpane.ok_option saving fields of jpanel in file , separately retrieve them in jframe class. so there better way this? jframe action listener: private void gosettingsactionperformed(java.awt.event.actionevent evt) { settings settings = new settings(); int result = joptionpane.showoptiondialog(null,

linux - Bash - search directory for all scripts -

i need search directory (and subdirectories) scripts , write them out full path , type of script. output should this: /home/student/scripts/find.sh bash /home/student/scripts/bin/server.pl perl /home/student/scripts/bin/client.pl perl i know should use find, head , grep determine type of script, bad @ bash, can please me? this close you're trying get: find /home/student/scripts -type f -name "*.*" -exec file '{}' +

node.js - reading a file and output to http -

how join these scripts 1 have done not work. think callbacks getting messed up. with code able output text browser. var http = require('http'); http.createserver(function (req, res) { res.writehead(200, {'content-type': 'text/plain'}); res.end('hello world\n'); }).listen(1337, '127.0.0.1'); console.log('server running @ http://127.0.0.1:1337/'); with code able read text file , log console. fs = require('fs') fs.readfile('/etc/hosts', 'utf8', function (err,data) { if (err) { return console.log(err); } console.log(data); }); but wont work together, why????????????????? help. var http = require('http'); http.createserver(function (req, res) { fs = require('fs') fs.readfile('/etc/hosts', 'utf8', function (err,data) { if (err) { return console.log(err); } console.log(data); res.writehead

How to create datatable with complex header in R Shiny? -

Image
i have datatable in r shiny , have headers span multiple columns below : how can achieved in r shiny? have @ new package rstudio dt ( https://github.com/rstudio/dt )? here http://rstudio.github.io/dt/ find example of need.

Spring Integration :How to send array as a single payload to a jdbc : outbound gateway -

how send array single payload jdbc : outbound gateway of spring integration ? constructing array of string , sending interface method . sql accepts 1 parameter ":payload" , fails uncategorizedsqlexception. the sql query of outbound gateway below <int-jdbc:outbound-gateway data-source="datasource" request-channel="requestchannel" query="select xmlmsg table seq_id in (:payload)" reply-channel="replychannel" > </int-jdbc:outbound-gateway> serviceinterface.findbysequenceids(sequenceidstringarray); actually substitutenamedparameters in clause parameter has collection not array . source code of namedparameterjdbctemplate.substitutenamedparameters : if (value instanceof collection) { iterator<?> entryiter = ((collection<?>) value).iterator(); int k = 0; while (entryiter.hasnext()) { if

c# - Azure web site deployment throwing. Mislead between DataBaseFirst and CodeFirst -

i'm stuck "dreadful" error message trying deploy mvc web site on azure : code generated using t4 templates database first , model first development may not work correctly if used in code first mode. continue using database first or model first ensure entity framework connection string specified in config file of executing application. use these classes, generated database first or model first, code first add additional configuration using attributes or dbmodelbuilder api , remove code throws exception. database first workflow used scratch (adding ado.net entity data model element , following wizzard connecting azure sql server db). can't figure out why it's besetting me code first. using ef 6.0 t4 templates. generated dbcontext looks : public partial class myappentities : dbcontext { public myappentities() : base("name=myappentities") { } protected override void onmodelcrea

jQuery Duplicates of Appended Elements On Click -

i attempting append content element depending on link clicked. if content exists, should not post duplicate of content. problem having duplicates being posted every link besides first 1 clicked. the links content , ids generated from: <a href='#' id="a">a</a> <a href='#' id="b">b</a> <a href='#' id="c">c</a> this jquery script supposed check if id of link clicked matches id of li element in list. if not, appends new li element same id link clicked. <ul id="list"></ul> <script> $(document).on('click', 'a', function(){ if($('#list').children('li').attr('id') != $(this).attr('id')) { var content = '<li id=' + $(this).attr('id') + '>' + $(this).html() + '</li>'; $('#list').append(content) } }) </script> the ids , content being g

java - Can I use Spring @Autowired in multiple classes? -

my question - can autowire instance of class in multiple classes? my application uses spring mvc communicate between jsp front end pages , mongodb end. using mongodb repository. have created service performs crud methods mongodb. can seen below 1 of crud methods (not shown not needed). uses mongo template. import org.springframework.beans.factory.annotation.autowired; import org.springframework.context.annotation.scope; import org.springframework.data.mongodb.core.mongotemplate; import org.springframework.stereotype.repository; @repository public class sensorreadingservice { @autowired private mongotemplate mongotemplate; /** * create unique mongo id , insert document * collection specified. if collection doesn't exist, * create it. * @param sensor */ public void addsensorreadingintocollection(sensorreading sensor, string collection) { if (!mongotemplate.collectionexists(sensorreading.class)) { mongotemplate.createcollection(sensorreading.class);

actionscript 3 - Objects keep disappearing, even though the HitTest object is removed -

i have been trying create game in actionscript 3, stuck on 1 problem past 4 hours. every time press key block appears, color depends on key press, when enemies hit block dissapear. made enemies removed through removechild , block dissapears after 1 second, problem after block gets removed enemies still die, though block isn;t visible anymore, here am. i use code in vechtblok.as (this block appears kill enemies), add code adding eventlistener timer named sterf, function: public function gaweg(e:timerevent):void { blok.parent.removechild(blok); } in vijand.as (the enemy class) have code them dissapear, give enemies code through adding eventlistener: public function aanval(e:event):void { if(hittestobject(vechtblok.blok)) { teken.removeeventlistener(event.enter_frame, beweeghor); trace(string(watbenik)); teken.parent.removechild(teken); //removechild(vechtblok.blok); } } i think e

actionscript 3 sectioned health bar -

i'm still new actionscript valuable. game involves scottish bag piper being attacked haggis, , each time hit, 1 heart should disappear (there 3 in total) i've gotten work first heart disappear after piper hit haggis piper.addeventlistener(event.enter_frame, piper_damaged); function piper_damaged(event:event):void { if (piper.hittestobject(haggis)) { heart_one.visible = false; piper.gotoandplay(2); } } thank in advance is game using timeline inside of flash pro? you have var holds number of hearts want display , each time there collisions can take away heart until there no hearts left. var numberofhearts:number = 3; piper.addeventlistener(event.enter_frame, piper_damaged); function piper_damaged(event:event):void { if (piper.hittestobject(haggis)) { if(numberofhearts > 0) { numberofhearts--; trace(numberofhearts);

android listview cachecolorhint transparent -

i've made listview multiple item types, each having different background color. i'm using android:cachecolorhint="@android:color/transparent attribute, it's showing white color , not color of bottom-most/top-most row. you might have set attribute onto listview well: android:listselector="@android:color/transparent"

haskell - QuickCheck prop to tasty prop -

im trying go from _prop example write same thing in tasty. (example http://primitive-automaton.logdown.com/posts/142511/tdd-with-quickcheck ) game9_prop :: game9 -> bool game9_prop = (9==) . length . ungame . ungame9 this i'm trying in tasty: qctestgengame9 :: testtree qctestgengame9 = qc.testproperty "better gen rate" $ \ (g :: game9) -> length . ungame . ungame9 g == 9 --error line this conversion gives me following error: test/tasty.hs:53:11: illegal type signature: `game9' perhaps intended use -xscopedtypevariables in pattern type-signature this type game9: -- make generation rate better newtype game9 = game9 { ungame9 :: game } deriving (eq, show) instance arbitrary game9 arbitrary = (game9 . game) `liftm` replicatem 9 arbitrary to fix immediate error, remove type annotation, i.e., use qctestgengame9 :: testtree qctestgengame9 = qc.testproperty "better gen rate" $ \ g -> (length . ungame . ungame9) g

ios - CCRenderTexture anchorPoint or what? -

i need ccrendertexture (white rect) render sprite here (1st picture), render @ lower-left corner (2nd picture). how can change value? first picture second picture rendertextrure.position = ccp(p.x, p.y); rendertexture.sprite.position = ccp(p.x, p.y); rendertexture.sprite.anchorpoint = ccp(0.5, 0.5); edit ccrendertexture initial position ccrendertexture size , position in cocos2d-iphone i found these answers, didn't help. possible change position or not? check if helps you. note uiimage optional incase want use uiimage. ccrendertexture *renderer = [ccrendertexture rendertexturewithwidth:tx height:ty pixelformat:kcctexture2dpixelformat_rgba8888 depthstencilformat:gl_depth24_stencil8]; [renderer beginwithclear:0 g:0 b:0 a:0 depth:1.0f]; [1st_pic_sprite visit]; [renderer end]; uiimage *img = [renderer getuiimage];

php - Accessing the username of a user being edited from the model in CakePHP -

from model, how access username of user being edited in cakephp 2.4? i'm using miles johnson's excellent file uploader userpics in cake 2.4 app, using callback in behavior's actsas config determine name file saved under: 'namecallback' => 'getusername', which calls following function: public function getusername() { return cakesession::read("auth.user.username"); } this works great when it's user editing own picture, comes apart when it's admin editing user: callback returns admin's username, not user's. the file uploader uploads file , saves under filename , location specified actsas config: in case, i'm having save images under /webroot/img/uploads , using getusername() function username filename. uploader saves file's url in user model under field image . you can use authcomponent::user('usernane') value if user. http://book.cakephp.org/2.0/en/core-libraries/components/authen

Java Insertion Sort not sorting -

public static void main(string[] args) { movies2[] movies = new movies2[10]; movies[0] = new movies2("the muppets take manhattan", 2001, "columbia tristar"); movies[1] = new movies2("mulan special edition", 2004, "disney"); movies[2] = new movies2("shrek 2", 2004, "dreamworks"); movies[3] = new movies2("the incredibles", 2004, "pixar"); movies[4] = new movies2("nanny mcphee", 2006, "universal"); movies[5] = new movies2("the curse of were-rabbit", 2006, "aardman"); movies[6] = new movies2("ice age", 2002, "20th century fox"); movies[7] = new movies2("lilo & stitch", 2002, "disney"); movies[8] = new movies2("robots", 2005, "20th century fox"); movies[9] = new movies2("monsters inc.", 2001, "pixar"); printmovies(movies); sorttitle(

prolog - Right linear context free grammar with even difference of 0's and 1's -

i'm trying write right linear context free grammar , in difference between numbers of 0's , 1's should even. example: 010001 = 4 - 2 = 2 (even) i had similar problem . maybe help! i'm trying write on prolog. did other 10 exercises difficult me. ideas on how it? my code s --> []. s --> [1],a. s --> [0],b. --> [1],s. --> [0],c. b --> [1],c. b --> [0],s. c --> []. c --> [1],b. c --> [0],a. it's work many cases i'm not sure if well. the problem can simplified little math. let a number of 0, b - number of 1, n - length of word. want abs(a - b) even. do math: a + b = n b = n - a - b = - n + = 2*a - n 2*a even, abs(a - b) iff n even. so task check if length of word even. solution: s --> []. s --> digit, digit, s. digit --> [0]. digit --> [1].

regex - Mapping c++ string to an enum in order to take user input -

i'm trying design class represent card i've decided use enums represent rank , suit. however, need able take input user and, unfortunately, it's not possible take enum directly cin. for reason, intending take in string , use std::map map each string enum value represents (as described in this question ). didn't want input case sensitive created regex should shift characters lowercase before matching. the code came here: istream& operator>>(istream& is, card& d) { std::map<std::string,card::rank> mr; std::map<std::string,card::suit> ms; mr[std::regex("/two/i")] = card::two; mr[std::regex("/three/i")] = card::three; mr[std::regex("/two/i")] = card::four; mr[std::regex("/two/i")] = card::five; mr[std::regex("/two/i")] = card::six; mr[std::regex("/two/i")] = card::seven; mr[std::regex("/two/i")] = card::eight; mr[std::regex("/two/i")] = card::nine; mr[std

Loop json array in php -

i know it's been asked many times , i've gone through 15 - 20 questions trying figure out how work. json {"menu": { "title":"title one", "link":"link one", "title":"title two", "link":"link two"} } php $string = file_get_contents("test.json"); $json_a = json_decode($string,true); foreach($json_a['menu'] $key => $value) { echo $key . ": " . $value . "<br />"; } this far displays title: title 2 link: link 2 as opposed to title: title 1 link: link 1 title: title 2 link: link 2 also correct in thinking $json_a[menu] not need apostrophes because $json_a not function? works or without. thanks in advance. you can't have multiple entries same key in array. while json might allow it, when it's parsed php, last definition of key,value pair wins. it looks menu should array of objects instea

android - Key from String in Java RSA -

i using in app rsa cryptography. store generated public key convert string , save in database. key publickey=null; key privatekey=null; keypair keypair=rsacrypto.getkeypairrsa(1024); publickey=keypair.getpublic(); privatekey=keypair.getprivate(); string publick=base64.encodetostring(publickey.getencoded(), base64.default); string privatek=base64.encodetostring(privatekey.getencoded(), base64.default); i save strings publick , privatek . problem is, when want encrypt/decrypt text rsa , use saved key in string format don't know how convert key . public static string encrypt(key publickey, string inputtext){ byte[]encodedbytes=null; string encryptedtext=""; try { cipher cipher=cipher.getinstance("rsa"); cipher.init(cipher.encrypt_mode, publickey); encodedbytes=cipher.dofinal(inputtext.getbytes()); } catch (exception e) {log.e("error", "rsa encryption error"); }

apache - How do I find my httpd.conf file? -

* edit: who's using mamp pro on mac running mac os x lion may find helpful know tracked down httpd.conf file in personal library @ application support > appsolute > mamp pro > httpd.conf. reason couldn't find normal search it's hidden directory. access it, open finder, choose go > go folder, type in ~/library after tracking down, may discover it's impossible edit httpd.conf file. ); * this weird one. i'm using mamp on mac , want modify httpd.conf file defaults url's lower case. navigated applications > mamp > conf > apache > httpd.conf , added line of code: rewritemap tolower int:tolower i modified 1 of .htaccess files accordingly, nothing happened. (yes, restarted servers.) i reopened httpd.conf file , added code, understand supposed display "verbose" messages in log file: loglevel trace8 i opened log file @ application > mamp > logs > apache_error.log. there's code associated web pages visited, the