Posts

Showing posts from August, 2015

angularjs - Angular - getting data with a factory -

i'm modifying way app gets it's data. the app got data on page load this <script> var entries = <?php echo $this->entriesdata; ?>; </script> and in angular controller $scope.entries = entries; requirements changed user able go forward or backward 1 week added factory app supposed load data when page loads , refresh data when changeweek() fired. according console factory (loaddata) fires when page loads , again on changeweek() , data comes down server expected. problem view doesn't display data. i'm assuming i'm not returning data $scope.entries correctly. please! var timeentry = angular.module('timeentry', ['ui.select2']); timeentry.factory('loaddata', function($http){ var url = 'index/getentries'; var returndata = ''; var factory = {}; factory.getdata = function(sdate, edate){ $.post(url, {week_start: sdate, week_end: edate}) .done(function(json, textst

Convert date time to below format SQL Server -

i tried obtain date in format: '05-31-2014 01:20:25 am' i used below code: sql fiddle here , output date strangely changed different date: 30-26-2011 01:30:38 am select format(cast('2011-11-26 01:30:38.000' datetime), 'mm-dd-yyyy hh:mm:ss tt') sql fiddle here when using format() function, mm minutes, mm month, change to: select format(cast('2011-11-26 01:30:38.000' datetime), 'mm-dd-yyyy hh:mm:ss tt') if there's appropriate format available via convert() , preferable performs better format() function.

java - Show the line numbers when the JScrollBar is moved -

Image
in linux text editor, kate, there nice functionality when click , drag scroll bar shows current line numbers in view in text component. question how can add function in java scroll pane containing jtextarea. component can use show notification? apparently can jpopupmenu : i tried class because knew had method show(component, x, y) . might possible other classes, or trying implement whatever method yourself. i put couple of mouse listeners scrollbar , toyed little values x, y in show() call until satisfied position being drawn at. full code: import java.awt.dimension; import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import java.awt.event.mousemotionadapter; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jpopupmenu; import javax.swing.jscrollbar; import javax.swing.jscrollpane; import javax.swing.jtextarea; import javax.swing.swingutilities; public class scrollbartest { private jscrollpane scrollpane; privat

jquery - javascript not working to create divs inside of another div -

i trying create 10 divs when button clicked, nothing happening. think issue javascript, nothing shown in console. doing wrong? , can fix it? appreciated. html <!doctype html> <html> <head> <title> space invaders </title> <script type = 'text/javascript' src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script> <link href="style.css" rel="stylesheet" type="text/css" /> <script src="script.js" type="text/javascript"> </script> </head> <body> <div> <div id="startbtn"><br />start game </div> <br /> <center> <div id="game" onclick = 'buttonclick'> </div> <div id="game2"> </div> &l

xml - Android: Screen Layout looks different on 2 phones of the same model -

Image
i'm alpha testing app , first time people looking @ on multiple devices. 1 person told me buttons on screen getting cut off. the weird thing - we're using same device. we're both using samsung galaxy s3, our screen resolutions should same. is there setting on (or my) phone might have changed resolution see things larger? (like ctrl + in browser) what else cause this?? screenshots , xml included below. differences on right: text bigger, homemade ellipses missing, settings button cut off <scrollview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context="com.farmsoft.lunchguru.app.pick_restaurant" android:layout_height="match_parent" android:layout_width="match_parent"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@di

corona - Shifting display groups around in a lua table -

i working on camera module game. designing work large amounts of randomly generated data. data in form of 2d chunks. labeled , referenced actual x, y coordinates. each chunk has group attached in order contain images associated it. have group contains chunks on screen ( simple simple attempt @ culling ). when player moves in direction width of chunk, current chunks need shift in table 1 element , new row ( or column ) of chunks needs loaded in edge row ( or column ). problem comes when shifting. getting error says have either removed image group or parent group. problem haven't done this. following code section having issues in ( think whole code large post @ once ): note: @ end section removal of elements occurs. have marked asterisks. if( changebottom == true ) = 1, newview.numviewchunksy - 1 j = 1, newview.numviewchunksx newview.imagechunktable[i][j] = newview.imagechunktable[i + 1][j] end end j = 1, newview.numviewchunksx local = newview.numviewch

Getting error while printing jasper report from java Caused by: java.awt.print.PrinterException: No print service found -

caused by: java.awt.print.printerexception: no print service found. @ sun.print.rasterprinterjob.print(rasterprinterjob.java:1305) @ sun.print.rasterprinterjob.print(rasterprinterjob.java:1277) @ net.sf.jasperreports.engine.print.jrprinterawt.printpages(jrprinterawt.java:205) error getting when trying print jasperreports report java code below code tried, works in os problem in window7 try { string report = args[0]; string printtext = args[1]; string expirydate = args[2]; string printername = args[3]; hashmap hm = new hashmap(); hm.put("printtext", printtext); hm.put("expirydate", expirydate); inputstream templateasstream = classloader.getsystemresourceasstream(report); system.out.println(" \n compile report"); jasperreport jasperreport = jaspercompilemanager.compilereport(templateasstream); // submit parameters map parameters = new hashmap(); parameters.put("param1&

html - PHP - FPDF Multicell function does not make a new line -

i'm trying make newline inside multicell. i've done is: $pdf->multicell(90,10,'test'.'\n'.'test',1,0,'c',1); according manual multicell should parse '\n' character , render newline not (it prints 2 byte string '\n' alongside actual text) try use "\n" instead of '\n' (or php_eol predefined constant). use double quotes. related: what difference between single-quoted , double-quoted strings in php? fpdf multicell alignment not working

angularjs - Limiting http interceptor to specific domain -

i'm busy in building little backoffice web client in angular.js directly talks api. authentication use oauth2 use http interceptor include access token request. but, interceptor global, not requests/responses api checked, other http call, static html , templates. i bind interceptor api calls only. would possible without nasty domain-string-comparing-if-statement in interceptor? you can create service-wrapper around $http takes care of oauth specific stuff (e.g. adding header etc) , use service (instead of $http ) oauth related requests. sample implementation: app.factory('httpoauth', function ($http) { // augments request configuration object // oauth specific stuff (e.g. header) function getaugmentedconfig(cfg) { var config = cfg || {}; config.headers = config.headers || {}; config.headers.someheadername = 'some-header-value'; return config; } // service object returned (`$http` wrapper)

c# - having a check box in message box -

this question has answer here: how show messagebox checkbox? 3 answers in message box there 2 buttons, yes , no . want have checkbox inside of message box says do items , if button yes selected , true items , if no selected , true items. is possible in messagebox? the answer question no. cannot create messagebox checkbox. have create custom dialog box. need create form looks way wish , use showdialog() method display form. display modal dialog box in application. code after showdialog method not executed until dialog box closed. using (form2 frm = new form2()) { frm.showdialog(); if (frm.dialogresult == dialogresult.yes) { } else if (frm.dialogresult == dialogresult.no) { } } on clicking yes or no within dialog b

CouchDB for event sourcing -

i've been playing couchdb week , love it; it's convenient nosql db i've seen far. now i'm considering using (cloudant, actually) manage entities in event sourcing fashion, have doubts couchdb suitable such case... let's want manage "type" "projection" like: { "field1":"some-string", "field2":["an","array","of","strings"] } i insert events like: { "type":"set-field1", "value":"another-string" } { "type":"remove-field2", "value":"strings" } { "type":"add-field2", "value":"bugs" } and guess, expect "projection" become: { "field1":"another-string", "field2":["an","array","of","bugs"] } now i'm still noob in map/reduce, intuition that: the redu

javascript - How to upload image in Node.js -

i complete newbie node.js.i want learn upload , showing images using ajax in php.i found of tutorials tough me.to started have tried using code var express = require("express"); var app = express() var bodyparser = require('body-parser') //all environment app.use(bodyparser()) var form = "<!doctype html><html><body>" + "<form method='post' action='/upload' enctype='multipart/form-data'>" + "<input type='file' name='image'/>" + "<input type='submit' /></form>" + "</body></html>"; app.get('/', function (req, res){ res.writehead(200, {'content-type': 'text/html' }); res.end(form); }); /// post files app.post('/upload', function(req, res) { console.log('hello world'); console.log(req.files); }); app.listen(8080) but getting undefined req.files.can

c# - User data outside aspnet database -

i want store user data outside aspnet db (on top of whatever aspnet db requires). i don't want extend aspnet db new properties, i'm happy default implementation , i'm using user guid pivot point between user , aspnet db user. i activated social connections (facebook google & twitter) , i'm wondering when time "link" user guid on aspnet db user i'd create in own db. in case of registering without social buttons it's easy, can in register action, should social buttons? or better yet there form of event subsribe when user created regardless of how created? goal "whenever new user created, create default initialized user in db same guid". doing wrong way doing in register action?

c - Opengl make "AI" paddle move up and down -

i'm bit of opengl/programming noobie i'm trying make "ai" right paddle. know isnt proper way of doing it, should doing making follow ball. right i'm trying make perpetually move , down. can't figure out how it, trying use if loops like if (paddle.pos[1] > 1){ paddle.pos[1] = paddle.pos[1] - delta} i set delta 0.01, 1 top of screen. isnt right because goes down below 1 goes again, i'm trying it. 2nd question - how move ball 0,0 when starts? kind of same problem, using if statements x values thats not right. this using c way. try make pos repeatedly go 0 1 , 0: // initialize. float pos = 0.0f; float delta = 0.01f; // on every update. pos += delta; if (pos > 1.0f) { pos = 1.0f; delta = -delta; } else if (pos < 0.0f) { pos = 0.0f; delta = -delta; } the key here invert sign of increment each time reach 1 of end positions.

jquery - How to show struts2 tags in javascript as string -

i using struts2 tags , want create <tr></tr> dynamically add new row in table. problem inside "" struts2 tags not treated simple string. function add_table_row() { var t = $('#item-table .row:last').attr('id'); var num = t.substring(4); var num1 = parseint(num) + 1; $("#item-table .row:last").after(" <tr class=\"row\" id=\"item" + num1 + "\">" + "<td><s:textfield name="billproductlist[0].productdetails.barcode" value="%{billproductlist[0].productdetails.barcode}" cssclass="barcode" cssstyle="width:50px"/></td>" + "<td><s:textfield name="billproductlist[0].productdetails.producttypes.producttype" value="%{billproductlist[0].productdetails.producttypes.producttype}" cssclass="producttype" cssstyle="width:250px"/>"); }; how

Twilio delivers long SMS messages in random order -

when twilio numbers receive sms longer 160 chars, call server each 160 char fragment. each server call separate sms. order in receive them random. does have solution other manually assemble these fragments? does know of replacement twilio?. should support: sending , receiving sms world wide. sending , receiving smss longer 160 chars. (i.e. deliver multiple messages in right order) easy python/django integration. checked out plivo's api. did not find solution there receiving long smss apparently nexmo need. works on globe. solves problem of long inbound smss

sql - How do I generate a (dummy) column of arbitrary length with MonetDB? -

i run equivalent of postgresql's select * generate_series(1, 10000000) i've read this: http://blog.jooq.org/2013/11/19/how-to-create-a-range-from-1-to-10-in-sql/ but suggestions there don't take arbitrary length - query depends on length otherwise replacing number. also, suggestions not apply in monetdb. so, what's best course of action (if any)? notes: - i'm using version february 2013. answers more recent features welcome, i'm looking for. - assume existing tables don't have enough lines; , not assume that, say, cartesian product of longest table sufficient (or alternatively, maybe that's costly perform). try with: select value sys.generate_series(initial_value, end_value, offset); i have report function quite unstable on jul2015 release causing server process crash. hope have better luck. if wants generate arbitrary numeric value can use: select rand();

javascript - How to make records favorites -

i have list of stores on website.i want users make stores favorite.i not asking them login & not saving in database. i want save store ids in cookie year. have code. function setcookie(cname, cvalue, exdays) { var d = new date(); d.settime(d.gettime() + (exdays*24*60*60*1000)); var expires = "expires="+d.togmtstring(); document.cookie = cname + "=" + cvalue + "; " + expires; } function getcookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for(var i=0; i<ca.length; i++) { var c = ca[i].trim(); if (c.indexof(name) == 0) return c.substring(name.length,c.length); } return ""; } i want save each store id , retrieve them.my questions are is use cookie? how save multiple ids? how retrieve ids saved/stored in cookie? do need append existing cookie? this code give me cookies,i need store ids saved in cookie. print_r($_cookie);

regex - Using command line, how do I get m out n possible results of each type? -

lets have shelves in store , each shelf has 0-9 boxes of specific kind. want select no more 4 boxes each shelf , till have 15 in total. how write command line code input file like aa123 small aa124 small aa122 small bb345 medium .. .. 100s of such where first 2 letters define shelf , number tell box number on shelf. for finding unique shelves, use cat filename | awk '{print $1}' | cut -c 1-2 | sort | uniq | xargs then trying use input in for/while loop got stuck. i think awk right tool this. the following 1 liner prints first 4 occurrences of shelves, , 15 in total: awk 'a[substr($1,1,2)]++ < 4 {if (t++>14) exit; print}' file

php - Show product options as a grid/matrix in product detail page -

i have develop feature in product details page shown in screenshot. https://www.dropbox.com/s/k7ntplkxf3qrvo8/details.png the options in grid selectable , change according paper or color selected. don't understand should configurable options or custom options. and if know magento extension make grid ( matrix ) of options. i don't believe it's viable on magento, but, can create custom js function predesigned table programming example: 1 day = price + 15% 3 day = price + 7% 6 day = price does make cence, if approach not clear send me message , i'll try in case.

audio - Sox resample and convert -

i trying figure out how combine 2 commands in sox. master file 44.1khz. first want resample file 22khz , convert mp3/opus/ogg. how can single command? sox determines files type looking @ extension. adjust rate of output file, add -r option output files formatting options. manual synopsis: sox [global-options] [format-options] infile1 [[format-options] infile2] ... [format-options] outfile [effect [effect-options]] ... here example of how perform both actions 1 command: sox master.wav -r 22050 out.ogg alternatively, add rate manipulation effects chain: sox master out.ogg rate 22050

sql server - sql count statement with multiple date ranges -

i have 2 table different appointment dates. table 1 id start date 1 5/1/14 2 3/2/14 3 4/5/14 4 9/6/14 5 10/7/14 table 2 id start date 1 4/7/14 1 4/10/14 1 7/11/13 2 2/6/14 2 2/7/14 3 1/1/14 3 1/2/14 3 1/3/14 if had set date ranges can count each appointment date fine need change date ranges. each id in table 1 need add distinct appointment dates table 2 6 months prior start date table 1. example: count distinct appointment dates id 1 (in table 2) appointment dates between 12/1/13 , 5/1/14 (6 months prior). result 2...4/7/14 , 4/10/14 within , 7/1/13 outside of 6 months. so issue range changes each record , can not seem figure out how code this.for id 2 date range 9/1/14-3/2/14 , on. thanks in advance! try out: select id, ( select count(*) table2 id = table1.id , table2.start_date >= dateadd(mm,-6,table1.start_date) ) table2records table1 the datead

node.js - Is server-side EJS safe to expose to end-users? -

i'd let end-users edit own website templates using ejs, since seems use evals , runs on server, i'm not sure if exposes major security problem. if i'm correct it's problem, there templating engine safe expose end-users? yeah, ejs security issue. the vm module helpful here. handlebars or mustache pretty popular, , might bit easier not-developer understand. jade awesome has eval issue , different html. i recommend using handlebars or mustache in node "vm", careful considerations , execution time limit.

Android: create TextView at the bottom of a LinearLayout dynamically -

i created app clicking button create textview inside linearlayout(hosted inside scrollview). when click button textviews displayed starting top example: first image http://imgur.com/8fhtyzs (sorry don't have reputation display in post inserted link) but task create textviews @ bottom of linearlayout , make textviews created scroll new one. (sorry bad english) show example more comprehensible. second image http://imgur.com/rlhooah this code: public class messaggi2 extends actionbaractivity implements onclicklistener { linearlayout mlayout; scrollview scroll; button invia; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.messaggi2); mlayout = (linearlayout) findviewbyid(r.id.linearscrolllayout); scroll = (scrollview) findviewbyid(r.id.scrollview2); invia = (button) findviewbyid(r.id.invia); invia.setonclicklistener(this); } @override public void onclick(vie

java - UnsupportedException whenever I call save(entity) method in Hibernate and SQL Server -

i'm trying save , entity hibernate in sql server database, , got following exception: java.lang.unsupportedoperationexception @ sun.jdbc.odbc.jdbcodbcconnection.preparestatement(jdbcodbcconnection.java:1750) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.hibernate.engine.jdbc.internal.proxy.connectionproxyhandler.continueinvocation(connectionproxyhandler.java:138) @ org.hibernate.engine.jdbc.internal.proxy.abstractproxyhandler.invoke(abstractproxyhandler.java:81) @ $proxy4.preparestatement(unknown source) @ org.hibernate.engine.jdbc.internal.statementpreparerimpl$2.doprepare(statementpreparerimpl.java:105) @ org.hibernate.engine.jdbc.internal.statementpreparerimpl$statementpreparationtemplate.prepares

mysql - SQL not returning expected rows -

my sql select statement not returning correct rows. have table named activities , statement should output rows column 'approved' = yes , of cells have text 'test'. statement still outputting of rows approved = no, not of them. this sql statement: select * activities approved = 'yes' , title '%test%' or subject '%test%' or industry '%test%' or description '%test%' order date_added desc move or conditions within () as select * activities approved = 'yes' , ( title '%test%' or subject '%test%' or industry '%test%' or description '%test%' ) order date_added desc so filter as if approved = 'yes' and title or subject ....

ios - Is applicationDidBecomeActive called in every app? -

i'm making jailbreak tweak ios device , have run problem regarding application bundleids , multitasking. i have set when application icon tapped, grabs application id , stores later. needed multitasking tried applicationdidbecomeactive no luck never called when thought be. there way tell when application loads multitasking and/or app switching? you can register notification in viewdidload: [[nsnotificationcenter defaultcenter]addobserver:self selector:@selector(selectoryouwant) name:uiapplicationdidbecomeactivenotification object:nil];

javascript - Testing URL schemes with try/catch -

i'm trying test url schemes via javascript try/catch blocks catch blocks not being executed. safari skips them entirely , don't understand why?! function open_twitter() { if (!is_ios){ //made unequal ios test on macbook try { window.location = "twitter://"; //fails , should go catch block } catch (e) { //skipped try { //skipped window.location = twitterrific_url_scheme; //skipped } catch (e) { //skipped null; //skipped } //skipped } //skipped } else { window.open(twitter_url, "_blank"); } } does have idea why happening? i want code test first url scheme. if isn't successful should (in theory) go catch block , run code inside in case try block again next url scheme test , on , forth. doesn't happen?! i'm confused... try catch doesn't work wrote, you'll need provide catch except

sqlite3 - how to display chinese character properly in sqlite console? -

Image
here sample csv file in utf-8 format can opened in win7's notepad , chinese character displayed ,please download . http://pan.baidu.com/s/1sj0ia4h open cmd ,and set chcp 650001. c:\users\pengsir>sqlite3 e:\\test.db sqlite version 3.8.4.3 2014-04-03 16:53:12 enter ".help" usage hints. sqlite> create table ipo(name text,method text); sqlite> .separator "," sqlite> .import "e:\\tmp.csv" ipo sqlite> select * ipo; 000001,Ã¥…¬Ã¥¼€Ã¦‹›Ã¥‹Å¸ 000002,申请表抽签é™Ã©¢Ã¨®¤Ã¨´­ 000004,Ã¥®Å¡Ã¥‘Ã¥‘è¡Å’ 000005,银è¡Å’Ã¥‚¨Ã¨“„Ã¥­˜Ã¥•Ã¦–¹Ã¥¼ 000006,申请表抽签é™Ã©¢Ã¨®¤Ã¨´­ 000007,è‡ÂªÃ¥Å Å¾Ã¥‘è¡Å’ 000008,è‡ÂªÃ¥Å Å¾Ã¥‘è¡Å’ 000009,Ã¥®Å¡Ã¥‘Ã¥‘è¡Å’ 000010,Ã¥®Å¡Ã¥‘Ã¥‘è¡Å’ 000011,申请表抽签等é¢Ã¨®¤Ã¨´­ sqlite> why same sqlite command can proper display in sqlitemanager? , how can set display chinese character in sqlite console? in pysqlite3 , can right display in python console. >>> import sqlite3 >>> con=sqlite3.connect("e:\\test.db

c# - Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common in WCF -

i trying use enterpriselibrary version=5.0.414.0,in wcf service.but throwing run time error while executing logger.write(log) method.error detailed is could not load file or assembly 'microsoft.practices.enterpriselibrary.common, version=5.0.414.0 anyone have idea? yes. application built make use of microsoft enterprise library version 5.0. normally, should installed installation installed dependent software. you can manually download , install microsoft enterprise library @ link: download microsoft enterprise library . once done, software should function nominally.

javascript - Passing values between view and controller query in grails -

i have grails controller(tablev1classcontroller.groovy) sql query looks like: class tablev1classcontroller { def datasource def listjson = { def sql = new sql(datasource) def rows = sql.rows("select date_hour, total_revenue sales, visits, marketing, organic, single_page_visits , total_units tablev1 si_flag ='serialized' ") sql.close() render rows json } } in views,i have dropdown following: <select id="si_flag" class="wrapper-dropdown"> <option value ="serialized">serialized</option> <option value ="non-serialized">non-serialized</option> </select> var si_flag = document.getelementbyid('si_flag'); how can value stored in variable 'si_flag' passed parameter query defined in controller(in condition). nisha first thing have make sure varible si_flag posted controller , since can't see post or ajax call in c

ruby on rails - Cant find the error in Heroku Logs -

i doing 1 month rails course , stucked in 1 point. i have app in heroku: http://arcane-shelf-3404.herokuapp.com/ but when upload image, give me error. help me find error. thanks! here log: ←[36m2014-06-02t06:19:47.681565+00:00 app[web.1]:←[0m command :: convert '/tmp/f 85a2368337734c012dda7e3c61bfb8920140602-2-1s8hujo.png[0]' -auto-orient -resize " 100x100>" '/tmp/f85a2368337734c012dda7e3c61bfb8920140602-2-1s8hujo20140602-2-1rj ixun' ←[36m2014-06-02t06:19:47.955359+00:00 app[web.1]:←[0m command :: file -b --mime '/tmp/f85a2368337734c012dda7e3c61bfb8920140602-2-1s8hujo20140602-2-1rjixun' ←[36m2014-06-02t06:19:48.191298+00:00 app[web.1]:←[0m completed 500 internal ser ver error in 2818ms ←[33m2014-06-02t06:19:48.276690+00:00 heroku[router]:←[0m at=info method=post pa th=/pins host=arcane-shelf-3404.herokuapp.com request_id=aa625159-c846-4e33-b931 -be0ed643437a fwd="190.114.248.109" dyno=web.1 connect=1ms service=3937ms status =

mysqli - Do multiple (query) check (optimze) in PHP -

i want ask, there how short script first check, if uid , second , third check $result = mysqli_fetch_row(mysqli_query($con, "select max(`uid`) `pvpgn_bnet`")); if($result) { second , first check(); } second check $result = mysqli_fetch_row(mysqli_query($con, "select * `pvpgn_bnet` acct_email = '" . $email . "'")); if($result) { errormsg(); } third check $result = mysqli_fetch_array(mysqli_query($con, "select `uid` `pvpgn_bnet` acct_username = '" . $username . "'"), mysqli_both); if($result) { errormsg(); } i dont know first filter (it doesnt make sense), second , third can combined. consider example: $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); $stmt = $mysqli->prepare("select * pvpgn_bnet acct_email=? or acct_username=?") $stmt->bind_param("ss", $email, $username); $stmt->execu

java - Need context in non-activity -

i have mainactivity, class called failedpasswordhandler , camerahandler. failedpasswordhandler implements deviceadminreceiver. want create camerahandler object in failedpasswordhandler class, requires context argument. how context failedpasswordhandler class? this have in mainactivity: intent intent = new intent(devicepolicymanager.action_add_device_admin); componentname deviceadmin = new componentname(mainactivity.this, failedpasswordhandler.class); intent.putextra(devicepolicymanager.extra_device_admin, deviceadmin); startactivityforresult(intent, 1); and want create camerahandler object this, in failedpasswordhandler class started intent above: ch = new camerahandler(this); ch.initializecamera(); the 'this' argument being mainactivity. i handle using custom application class. example: public class helper extends application { private context mcontext; public void oncreate() { super.oncreate(); mcontext = this; } pu

android - Eclipse - build only java part and native part I will build with ndk-build tool -

how ask eclipse not build native part of android project? mean when press 'run as->android application' eclipse rebuilds native part, whereas wanted build command line using 'ndk-build' each time different options. how can achieve this? i just: right click on project select "properties" select "c/c++ build" uncheck "use default build command" clear build command (so there's no text @ all) click "apply" the result build run, won't actual building , faster.

c# - Reflection on enum extension method located in separate assembly -

this question has answer here: reflection identify extension methods 6 answers code have: public enum activitystatus { = 0, active = 1, inactive = 2 } public static class myclass { public static string test(this activitystatus _value) { return _value + "111"; } } and typeof(activitystatus).getmethods() doesn't contain test method. tried put in same assembly, still no success. wrong? extension methods static methods, compiler translates call yourenum.test(); to: myclass.test(yourenum); so in order test method info via reflection, need inspect myclass , activitystatus parameter there. var testmethodinfo = typeof(myclass).getmethod("test"); var firstparameter = testmethodinfo.getparameters()[0]; console.writeline (firstparameter.parametertype + " " + firstparameter.name); prints: activity

hyperlink - make temporal link with PHP -

i won make vip download script not show main download link , make temporal link fake address downloads. use below class , not show file size , download can't resume. class hidden_download{ switch ($ext) { case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "doc": $ctype="application/msword"; break; case "xls": $ctype="application/vnd.ms-excel"; break; case "ppt": $ctype="application/vnd.ms-powerpoint"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; default: $ctype="application/force-download"; } header("pragma: public"); header("expires: 0&quo

Android open .docx file via ContentResolver in QuickOffice crashes -

for reason code opening downloaded file, , in instance .docx not work quickoffice, exception i'm getting this: 06-02 22:04:05.356: e/androidruntime(2889): fatal exception: main 06-02 22:04:05.356: e/androidruntime(2889): process: com.quickoffice.android, pid: 2889 06-02 22:04:05.356: e/androidruntime(2889): java.lang.nullpointerexception 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.quickoffice.a.g.a(abstractsaveaction.java:14) 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.editors.menu.d.a(abstractmenuitemcontroller.java:28) 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.editors.menu.c.a(abstractbuttonmenuitemcontroller.java:24) 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.editors.menu.y.a(menucontroller.java:59) 06-02 22:04:05.356: e/androidruntime(2889): @ com.google.android.apps.docs.editors.menu.y.a(menucontroller.java:59) 06-02 22:04:05.

r - Read and rbind multiple csv files -

i have series of csv files (one per anum) same column headers , different number of rows. reading them in , merging them so; setwd <- ("n:/ring data cruise/shetland") lengthheight2013 <- read.csv("n:/ring data cruise/shetland/r_0113a_s2013_wd.csv",sep=",",header=true) lengthheight2012 <- read.csv("n:/ring data cruise/shetland/r_0212a_s2012_wd.csv",sep=",",header=true) lengthheight2011 <- read.csv("n:/ring data cruise/shetland/r_0211a_s2011_wod.csv",sep=",",header=true) lengthheight2010 <- read.csv("n:/ring data cruise/shetland/r_0310a_s2010_wod.csv",sep=",",header=true) lengthheight2009 <- read.csv("n:/ring data cruise/shetland/r_0309a_s2009_wod.csv",sep=",",header=true) lengthheight <- merge(lengthheight2013,lengthheight2012,all=true) lengthheight <- merge(lengthheight,lengthheight2011,all=true) lengthheight <- merge(lengthheight,lengthhe

postgresql - How to SELECT parts from a comma-separated field with a LIKE statement -

i have field in database filled this: 1,4,8,14,16 now, i'd query field parameter - or similar. is, receive parameter via form, , looking row in table has in above mentioned field number. that parameter example "14". , can query select * my_table my_field '14' that works fine. but if value "4", have problem, because result being returned "4" , "14". using comma additional separator isn't useful either... i guess either flaw in (the simple) database layout. or missing simple approach query... advice!

c - I get an error with fopen -

when go , compile lab, 1 error. if tell me doing wrong awesome, because right stuck. error seems fopen statement, our teacher hasn't taught really, told use it. lot in advance lab1.c: in function ‘read_file’: lab1.c:65: warning: passing argument 1 of ‘fopen’ incompatible pointer type /usr/include/stdio.h:271: note: expected ‘const char * __restrict__’ argument of type 'struct file *' here code: //libraries #include<stdio.h> #include<stdlib.h> #include<string.h> #define max_name_length 20 #define max_array_length 25 //structure typedef struct student_{ char name[max_name_length]; int num_a; int num_b; int num_c; int num_d; int num_f; float gpa; }student; student class[max_array_length]; //prototypes int read_file(file *input); void print_grade_distribution(int num_students); void calculate_gpa(int *index); void write_to_file(file *output, int num_students); int main(int argc, char* argv[]){ if(argc != 2)

css - Align all divs to center in HTML5 -

Image
i have dashboard has many div's. i need position divs center when user re sizes page below: the html divs below: <div style="min-height: 1000px;text-align:center; position: relative;"> <div style="position: relative; min-height: 1000px;"> <div id="steps" class="chartcontainer"></div> <div id="distance" class="chartcontainer"></div> <div id="floors" class="chartcontainer"></div> <div id="activityminutes" class="chartcontainer"></div> <div id="calories" class="chartcontainer"></div> <div id="weights" class="chartcontainer"></div> <div id="bmi" class=&q

php - Breakdown MYSQL Results -

i getting data database using php , echoing data out using: $data[0] this displays full list of account numbers, wanting put href around when click on each 1 of account numbers runs mysql query breaks down more information based on account number has been clicked. how can done? the href point script evaluates $_get parameters , builds query it, in <a href="details.php?id=12345">12345</a> and <?php // details.php ... mysql_query( "select * mydata id=$_get['id']" ); this pointer, , example prone sql injection etc.

java ee - Stateful sessions Beans CMT -

good afternoon in timezone. i preparing ejb 3.0 certification exam , reading "ejb3 in action" book. in pros , cons of using bmt transaction type section , says "if using stateful session bean , need maintain transaction across method calls,bmt our option". can not understand sentence. imagine have following psedo class @stateful @transactionmanagement(transactionmanagementtype.container) @transactionattribute(transactionattributetype.required) public class testbean implements test{ public void method1(...){...} public void method2(...){...} public void method2(...){ method1(); method2(); } } because defined @ class level methods have required transactionattribute value, when method3 calls method1 , method2 , methods join transaction created when calling method3, correct ? can clarify me in doubt ? in advance best regards "maintain transaction across method calls" - referri

asp.net - Pointing Simple Membership provider to use MongoDB Connection -

in mvc4 application pointed simple membership provider mongodb connection. throwing error connection string. here code web.config <add name="defaultconnection" connectionstring="server=127.0.0.1;database=user" /> <membership defaultprovider="defaultmembershipprovider"> <providers> <add name="defaultmembershipprovider" type="webmatrix.webdata.simplemembershipprovider, webmatrix.webdata" connectionstringname="defaultconnection" applicationname="/" /> </providers> </membership> <rolemanager enabled="true" defaultprovider="defaultroleprovider"> <providers> <add name="defaultroleprovider" type="webmatrix.webdata.simpleroleprovider, webmatrix.webdata" connectionstringname="defaultconnection" applicationname="/" /> </providers> </rolemanager> global.asax websecurity.in