Posts

Showing posts from February, 2012

rust - Store reference of struct in other struct -

i have 2 structs. app , item . what want achieve store item in items vector of app struct passing mutable reference item s constructor. pub struct app<'a> { items: vec<&'a item> } impl<'a> app<'a> { pub fn new() -> app<'a> { app { items: vec::new() } } pub fn register_item(&mut self, item: &'a item) { self.items.push(item); } } pub struct item; impl item { pub fn new(app: &mut app) -> item { let item = item; app.register_item(&item); item } } fn main() { let mut app = app::new(); let item = item::new(&mut app);; } the code thows following error: test.rs:8:28: 8:32 error: `item` not live long enough test.rs:8 app.register_item(&item); is there way this? while rc might correct use case, it's understand why getting error are. please read why can't store value , reference value in...

angularjs - Why does my routing not work in Angular JS for URL? -

i use next configuration routing: .config(['$routeprovider', function($routeprovider) { $routeprovider .when('/appointments', { controller: 'appointmentcontroller' }) }]) and controller: .controller('appointmentcontroller', ['$scope', '$http', '$sce', function ($scope, $http, $sce) { alert('test') }]); url looks as: http://blogapp.com/appointments so, have not error on page, alert() not work when enter url try going http://blogapp.com/#/appointments the hash included default angular.

lenses - Why can't I bind and reuse a haskell lens like a normal variable? -

(i'm using lens-family, not lens) i have deep data structure , need focus on 2 parts have common path. intuitively define _table intention reuse it: let _table = _soutput.at (o.tname table)._just' tp' <- evalcacheable (_table.o._stperm) m.empty ... reuse _table but yields error: could not deduce (functor f0) arising use of ‘_soutput’ context (monadreader (evalconf state all) m, ... yet, directly pasting value of _table argument works: tp' <- evalcacheable (_soutput.at (o.tname table)._just'.o._stperm) m.empty what going on? can give more details types involved, me seems puzzling regardless. under impression that let x = y z <- f x was equivalent to z <- f y in cases. this related monomorphism restriction. try putting {-# language nomonomorphismrestriction #-} @ top of file. – randomusername it worked! on #haskell solved adding explicit type signature _table . according him rank2types messing type inference. – bru...

c# - RESTful api queryString functionality -

i'm building c# web rest api, , trying implement crud methods method filter different fields have in db. the select all, , select id done, i'm curious how go selecting resource string. i'm assuming this: /api/requests?priority=high this search through of requests , return of requests priority set "high" are able combine parameters? such as: /api/requests?priority=high&status=open from understanding these have implemented in own method, seems little excessive. i've seen few different implementations of using lists using getquerynamevaluepairs, i'm not sure if i'm looking for. so, implementation suggestions appreciated.

git - Is it OK to work on a branch that was created by someone else? -

background: i'm working on project using github , supervised senior developers push additional code repository. suppose, added new branch called tests repository. tests branch adding template files have work on. when i'm done, should merge these files master branch. doubts: should i: work on tests branch or create own branch (like my-tests or tests-preparation ) , merge master after work done? the point supervisors might push changes tests branch , want avoid conflicts of code , code. on other hand, don't want create unnecessary branches troublesome names. what best practice in such situation? git there manage conflicts. pushing in same branch isn't supposed real problem. if thing don't want them handle conflicts, maybe work in branch. is necessary branch on server? work in local branch never push origin. , time time merge tests .

javascript - How to set crop box in jquery cropper -

i'm using cropper, it's jquery plugin found @ cropper web site . have image size full hd 1920w on 1080h, , need give user ability crop in fixed box size 675*1080, question how set options of plugin ? i've tried follow no success: var c1 = $('.cropper-example-1 img').cropper({ //aspectratio: 10 / 16, strict: true, background:false, guides: false, highlight: false, dragcrop: false, movable: false, resizable: false, mousewheelzoom: false, touchdragzomm:false, built: function () { //alert(1); // $(this).cropper('setdata', 0, 0, 675, 1080,90); // $(this).cropper('setcropboxdata', 0, 0, 1920, 1080); } }); try add autocroparea: 0.5, , changes built method var $image=$('.cropper-example-1 img'); $image.cropper({ //aspect...

Sorting multiple attributes of lists at a time in python? -

i have tuple represents person contains (id, overall score, days employed, peer score). i have decided put each tuple in list follows: alist = [ atup, btup, ctup.....] i rank people best worst based on rules below. rules follows: 1. people(in case tuples) sorted based on overall score. -->if overall score same, sort number of days employed. -->if days employed same, sort peer score. -->if peer score same, sort id(the smaller id gets preferenced. is there method in python allows me achieve this? close .sort() method? the default sort() tuples. need make sure tuples of form (score, days_employed, peer_score, id) .

osx - Setting environment variables in OS X? -

what proper way modify environment variables path in osx? i've looked on google little bit , found 3 different files edit: /etc/paths ~/.profile ~/.tcshrc i don't have of these files, , i'm pretty sure .tcshrc wrong, since osx uses bash now. have idea these variables, path, defined? edit: i'm running os x 10.5 bruno right on track. i've done extensive research , if want set variables available in gui apps, option /etc/launchd.conf please note environment.plist not work applications launched via spotlight. documented steve sexton here . 1) open terminal prompt 2) type sudo vi /etc/launchd.conf (note: file might not yet exist) 3) put contents following file # set environment variables here available globally apps # (and terminal), including launched via spotlight. # # after editing file run following command terminal update # environment variables globally without needing reboot. # note: still need restart relevant application (in...

java - How to customize json response generated by Spring HttpMessageConverters -

i creating rest webservice using spring @restcontroller , httpmessageconverter. it working fine simple scenario controller method returning pojo , spring converts json using "mappingjackson2httpmessageconverter" below: { "firstname": "john", "lastname": "smith", } however properties name in json same name of getters in pojo. want modify name of properties in json dynamically. actually requirement modify json property names based on logic. e.g if condition x properties name in json should below: { "fname": "john", "lname": "smith", } if y properties name in json output should else like: { "mainname": "john", "secondname": "smith", } so property name cannot tied pojo , cannot use @jsonproperty compile time want change @ runtime. is there way override mappingjackson2httpmessageconverter , put logic decide j...

node.js - How can I do secure SAML with multiple tenants? -

i'm talking in context of idp-initiated workflow. i'm using this passport strategy saml. under " security , signatures " heading, suggests providing idp's cert. this cert inserted when define strategy afaik. in case of multi-tenant application, have no way of knowing cert use until user attempted log in, , @ point late use cert, wouldn't it? how can authenticate saml requests multiple tenants if can't know cert use until saml requests come in? i'm thinking i'd need this: user sends information identifying tenant they're trying login to the saml strategy created correct cert. the saml process starts. or perhaps i'm thinking wrong, , none of necessary having relatively secure login process? if question broad, i'd appreciate if left comments me narrow down, or directed me resources should read. if wasn't clear, i'm storing: the sso url the issuer url the public cert this information linked tena...

php mysql sort result by value of field using position of substring -

i have field name "codehead" values "53/066/10" "54/066/05" "56/066/09" "52/069/15" "53/069/02" "67/069/02" "00/020/80" "00/020/98" i want results in following order "00/020/80" "00/020/98" "53/066/05" "53/066/10" "54/066/09" "52/069/15" "53/069/02" "67/069/02" i have tried query $data= mysql_query("select codehead,sign, sum(amt) amt pm month='$pmmonth' , rc='r' group substr(codehead,4,3) asc,substr(codehead,7,2) asc, sign ") but not complete result. this expression: substr(codehead,7,2) is returning forward slash , digit. looks wanted start @ position 8. but won't satisfy order shown, fifth row has 09 , , come before 10 on preceding row. desired result shown makes result ordered on left(codehead,2) group codehead, `sign` order substr(codehead,4,3...

scoreboard fonts already in iOS? -

i'm writing app , i'm thinking using font scores old dotted numbers scoreboards. saw this question , answer few years ago , wondering if still need embed font app or if has been added list of fonts available? that font not built-in. you'll need embed custom font in app. ios fonts shows fonts bundled (each version of) ios.

php - Export MySQL table rows as individual files (specifically JSON) in one go -

i have on 750 json files need create mysql database table. it wordpress "wp_options" table, mysql question. the wp_options table has following properties. option_id, option_name, option_value, autoload the " option_name " become json file name. i fine if "have to" rename each file name manually. the " option_value " become json data. is there way can more efficiently instead of creating empty json file each row , copying data base option_value json file? my main concern 750 files make little weary miss or double on something, , information has exact. note: i've read stack article (which closest find) @ http://goo.gl/rnv5cf . but, doesn't seem working expected given wordpress wp_options values think. if needed this, , needed once, i'd run little php script locally. assuming have grabbed table array (here i've called $wp_options ), iterate on using fopen , fwrite , fclose make files. i've assum...

d3.js - Append SVG canvas to element other than body using D3 -

is possible append svg canvas element other <body> using d3.js if script not inside element? for example, code below not work: <html> <body> <script src="../../d3.v2.js"></script> <script> var vis = d3.select("#container") .append("svg:svg") .attr("width",w) .attr("height",h); </script> <div id="container"></div> </body> all examples have seen use d3.select("body").append.... don't want append canvas body. i found if <script> inside container div can use d3.select("#container") seems strange me have include script inside of specific container(s) want canvas. you're trying select #container before exists. you'll need put code in onload or move script below #container in page.

NuGet Package Manager Console Command Fails But Search -> Install Works -

i installing new package thats not in local cache. took command directly nuget site. executing command in pmc failed following error: the source @ [(aggregate source)] unreachable. falling nuget local cache @ c:\users\jammer\appdata\local\nuget\cache install-package : unable find package 'xam.plugins.settings'. @ line:1 char:16 + install-package <<<< xam.plugins.settings + categoryinfo : notspecified: (:) [install-package], invalidoperationexception + fullyqualifiederrorid : nugetcmdletunhandledexception,nuget.powershell.commands.installpackagecommand i've confirmed settings correct, usual nuget source urls present , correct expected. have nuget 2.8.5 installed. when searched using "manage packages solution" option within visual studio found package after , installed expected. has seen , have idea going on here? ahhh, ok> solved immediately. i uninstalled package within solution removed package nuget l...

Loading and Viewing a local (in bundle) pdf within Android App -

i have reviewed , tried numerous versions of issue no avail. have seen answers far 2011 , recent mid-year 2014. unfortunately, many partial answers , poorly explained suggestions have created more questions answers. have apple app available in itunes app store performs trying android app. in apple app world viewing pdf file relatively easy perform having difficult time accomplishing in android. admit limited in experience @ creating android apps. the problem have android app main activity has listview lists titles 35 diagrams in pdf format. each of these clickable viewing in full screen activity (view). each pdf half page width , anywhere 1/2 page 2 pages in length. new activity (pdf view) need scrollable. since app phones or pads new activity (pdf view) needs zoomable. after user completes view of pdf need option return main activity. user can select diagram viewing. the things have accomplished are: - listview of diagram titles on main activity - listener enabled...

scala - curry functions using generic type -

i trying use curry function typed class. goal classes extends class have define curried function . last failed attempt : abstract class foo[t: ordering]{ def eval(x: t, y: t)(f:(t,t)=>option[boolean])(implicit ev:ordering[t] = null): option[boolean] = { if(ev == null) none else f(x,y) } } case object bar extends foo{ def xx[t: ordering] = (x:t,y:t)=>some(x>y) eval(xx) } how should done correctly ?

java - Regex to strip out greater than > and less than < characters from HTML string ignoring existing tags -

i have not lot of experience regular expression , have issue need replace instances of > , < &lt; , &gt; leave html tags in tack. for example: string string =" <p class=\"anotherclass\"> here text value h<sub>2</sub>o > 1 , < 100 <p>"; //need converted to: <p class=\"anotherclass\"> here text value h<sub>2</sub>o &gt; 1 , &lt; 100 <p>"; i have tried , ahead , behind expressions can not seem of them work. example: string string =" <p class=\"anotherclass\"> here text value h<sub>2</sub>) > 1 , < 100 <p>"; string reg1="<(?=[^>\\/]*<\\/)"; pattern p1 = pattern.compile(reg1); test = p1.matcher(string).replaceall("&lt;"); does not seem have effect. i wondered if else had come across before or if can give me guidance? using regex alone "parse" html markup ...

python - np.piecewise() acting up with use of math.pow()? -

i've been trying numpy.piecewise convert list of coefficients {a_ij} piecewise cubic polynomial. whenever run following code, import math import numpy np x = np.linspace(0.1,9.9,100) = [[i] * 4 in range(10)] x_i = [0,1,2,3,4,5,6,7,8,9,10] condlist = [(x[i] < x)*(x<x_i[i+1]) in range(len(x_i)-1)] funclist = [lambda y: sum([a[k][j] * math.pow(y - x_i[k],j) j in range(4)]) k in range(len(a))] print np.piecewise(x, condlist, funclist) i error ...line 730, in piecewise y[condlist[k]] = item(vals, *args, **kw) file "test", line 8, in <lambda> funclist = [lambda y: sum([a[k][j] * math.pow(y - x_i[k],j) j in range(4)]) k in range(len(a))] typeerror: length-1 arrays can converted python scalars the error goes away, however, if , if rid of math.pow(). reason, having funclist pass x math.pow() breaks everything. what's going on? how can fix this? the functions in math module expect numeric scalars arguments. don't expect numpy arrays. fun...

java - Using jfreechart, how would I change the color and style of the series -

i'm beginner programmer. project school. lot jfreechart implementation code not specific code, taken other tutorials. import java.awt.basicstroke; import java.awt.color; import org.jfree.chart.chartfactory; import org.jfree.chart.chartframe; import org.jfree.chart.chartpanel; import org.jfree.chart.jfreechart; import org.jfree.chart.axis.numberaxis; import org.jfree.chart.plot.plotorientation; import org.jfree.chart.plot.xyplot; import org.jfree.chart.renderer.xy.xylineandshaperenderer; import org.jfree.data.xy.xydataset; import org.jfree.data.xy.xyseries; import org.jfree.data.xy.xyseriescollection; import org.jfree.ui.applicationframe; import org.jfree.ui.refineryutilities; import java.util.arraylist; /** * resource class */ public class interest { /** * instance variables */ private double interestrate; //the rate of interest earned private int time; //how many of 1 unit of time measurement -- generally, in terms of years private int rate; //how many times during 1 ...

jquery ajax to python GAE -

i have basic google app engine project using python. implement sort of logging on site (i understand google app engine has kind of feature). in future add high scores of games using same idea. logging have basic page.py contains this: from google.appengine.api import users google.appengine.ext import ndb import webapp2 import json class save(ndb.model): time = ndb.datetimeproperty(auto_now_add=true) url=ndb.stringproperty() user=ndb.stringproperty() class mainpage(webapp2.requesthandler): def post(self): data = json.loads() self.stuff.url=(data) self.stuff.put() app = webapp2.wsgiapplication([ ('/page.py', mainpage), ], debug=true) this test before implement entire thing. want save date, user, , page title in logs. know how other things. want jquery in html send page title python file. here jquery. $.ajax({ type: "post", url: "/page.py", datatype: 'json', data: ('index...

png - Create a RGB 565 image from python array -

i've got numpy array represents bunch of rgb values. i'd save them rgb 565 png image, i'll use three.js texture. how can using python? do need write out appropriate 16-bit greyscale image? i.e., convert r, g , b values 5, 6 , 5 bit numbers , add them binary? there better way of doing it? i'v been using pypng far write 8 bit rgb pngs.

php - Wordpress string translation function output blank -

i have done following: wrapped non content managed string translations in __() or _e() functions. added following function.php file: //add localisation load_theme_textdomain('whitelabel', get_template_directory() . '/languages'); //set locale $locale = get_locale(); $locale_file = get_template_directory() ."/languages/$locale.php"; if ( is_readable( $locale_file ) ) require_once( $locale_file ); used poedit create translation file , have test translation see if it's works nothing displayed either. checked php info gettext make sure it's enabled. however see on page blank spaces translations functions are. should defaulting text right? english. what doing wrong? i've spend lot of time looking in this. way i'm not totally sure $locale.php removing makes no difference. me seems problem functions. thanks in advance. turns out had php error on page blocking rest of translations. problem solved. noted few instance...

Align rows in text file with command line -

i have data in text file data rows repeated after several columns , each new block shares first column of row labels. i'd use command line align rows single table. the data text file looks like: values samplea sampleb samplec value1 1.00 2.00 3.00 value2 3.00 2.00 1.00 value3 2.00 1.00 3.00 values sampled samplee samplef value1 1.00 2.00 3.00 value2 3.00 2.00 1.00 value3 2.00 1.00 3.00 and i'd resulting file like: values samplea sampleb samplec sampled samplee samplef value1 1.00 2.00 3.00 1.00 2.00 3.00 value2 3.00 2.00 1.00 3.00 2.00 1.00 value3 2.00 1.00 3.00 2.00 1.00 3.00 this solution creates lots of temp files, cleans after. # put each paragraph it's own file: awk...

multithreading - How is default new thread name given in java? -

when run program public class fabric extends thread { public static void main(string[] args) { thread t1 = new thread(new fabric()); thread t2 = new thread(new fabric()); thread t3 = new thread(new fabric()); t1.start(); t2.start(); t3.start(); } public void run() { for(int = 0; < 2; i++) system.out.print(thread.currentthread().getname() + " "); } } i output thread-1 thread-5 thread-5 thread-3 thread-1 thread-3 is there specific reason why threads given names odd numbers - 1, 3, 5... or unpredictable? new thread(new fabric()); since fabric thread, created 2 threads here :) jdk8 code: /* autonumbering anonymous threads. */ private static int threadinitnumber; private static synchronized int nextthreadnum() { return threadinitnumber++; }

java - J2SE interfaces specifications and implementations of those interfaces -

i looking @ rt.jar reasons , there saw packages java.sql.* among others. in typical jdbc program write (for connection class, example): import java.sql.connection; as per docs, java.sql.connection interface, not concrete implementation, , java.sql.connection in rt.jar. when write jdbc program, need jdbc drivers, , read jdbc drivers implement interfaces (e.g. java.sql.connection). so when write in typical java program: (and load jdbc drivers) import java.sql.connection; --> java.sql.connection come rt.jar or driver classes. from guess, in case java.sql.connection has come rt.jar (as interface), , actual implementation comes driver classes. if assumption correct, in general need include jar's have interface definitions in order include import. for example, consider situation: package com.vipin.myinterface; public interface interface1 { public void print(); } and if package above interface interface1.jar. suppose concrete1.java implements interf...

javascript - alert for not meeting browser requirements - detecting legacy browsers -

in web application want create alert tells user not meet minimum browser requirements. how go this? simple javascript? can done wih angular? update: sorry need better clarify question. need detect legacy browsers in order force user upgrade or let them know features may not work due version of browser using. know how alert() works need detect ie9 or lower, , other browsers. keep reading browser detect , feature detect. looking best practices , easy maintain browser versions change. to detect os, browser , device can use this library call ng-device-detector in plunker can see how works. have object tha contain raw values os, browser , devices indicating true or false. html <script src="https://rawgit.com/srfrnk/ng-device-detector/master/ng-device-detector.js" type="text/javascript"></script> <div device-detector>using classes:</div> <br/> <div device-detector id="os-windows"></div> ...

android - Can a test account be created on the developer's phone? -

in game have inapp purchases. want test game before publishing, uploaded alpha. love test on phone, google refuse, saying developer can't buy own products. google refuse allow emulators purshase items. yesterday added google account phone, , added list of people allowed download app (gmail accounts testing access). my problem can't access game (we're sorry, requested url not found on server). game available (i checked phone , good). can't access test account. what can do? should something, or not able test game on phone no matter what? here android developer testing in-app purchases. second account added should able access game shortly. in experience, takes 24 hours access alpha/beta testing once user has been added. here's specific stuff post: test purchases (in-app billing sandbox) test purchases offer secure, convenient way enable larger-scale testing of in-app billing implementation during development or in preparation launch. let autho...

javascript - How does websocket binary image transport work? -

can please clear misconceptions note: not using faye just, ws node module , browsers support websockets but, based on answer: sending javascript object through websockets faye i have 2 questions: i don't see how html/javascript client side application know 2 put image.. client sent websocket message background image div#div123 (there many locations put requested image). when client receives message server might not original call (for div123) , might response div6 or div158, or might response totaly different call together. normally, when call server; tell query , when sends response sends answer question (so client knows answer for). how sending client raw binary data dealt in same manner? say have image (width: 164px height: 164px) , base64 encode it, remove "data:image/png;base64," before sending client have (roughly) string of 2900 characters in length. whereas if image data rbga array (0-255,0-255,0-255,0-255) each pixel 107584=(164*164)*4 long array...

date - Pig ToDate casting error -

i have date field trying cast 'todate' via dates this 2015-03-28@18:21:18. todate(replace(replace(date_time, '@', ' '),'.',''),'yyyy-mm-dd hh:mm:ss') the job dies , gives me error; backend error : invalid format: "" i have filters take care of null values, size > 0 blanks. return type of todate function datetime object. need not replace @, . characters '' (space). ref : http://pig.apache.org/docs/r0.12.0/func.html#to-date , details input : a.csv 2015-03-28@18:21:18. pig scirpt : = load 'a.csv' (datevalue:chararray); b = foreach generate todate(datevalue,'yyyy-mm-dd@hh:mm:ss.'); dump b; output : (2015-03-28t18:21:18.000-07:00) we have overloaded todate function, can specify timezone. for eg : specifying timezone gmt b = foreach generate todate(datevalue,'yyyy-mm-dd@hh:mm:ss.','gmt'); dump b; output 2: (2015-03-28t18:21:18.000z...

reporting services - SSRS - Display latest value in column group -

Image
tables - can't post images yet, posted link examples. i have 2 tables - 1 sales , 1 inventory. dates in these tables week ending dates - sales totals 1 week , inventory quantity counted @ end of week. i want create ssrs report, using matrix, showing sales , inventory in column group month row grouping product , product/color. i wrote simple sql query joins tables product id , date (see 'dataset' in reference image). the sales information can aggregated normal way - sum. works correctly. however inventory quantity should not sum'ed - quantities end of period; want show final quantity (the qty latest date) month in column , row group. the inventory quantities affected not sales, production values also, can't calculate ending inventory. is there easy way this? perhaps it's better calculate in sql? final report cover year, or more, of data there many column groups. if you're looking can use expression sum(fields!sales.value) sales v...

javascript - Login Pop Up button pops up automatically and won't go directly to login form -

i'm having trouble editing jquery , html make login button pop login form instead of showing login button. reason login button popping on load. http://jsfiddle.net/1s3gycd8/ i'm new jquery , i'm posting question after attempting solve problem no avail. if of have answer question please respond changes in code or better update jsfiddle. thank you! html: <div class="container"> <a id="modal_trigger" href="#modal" class="btn">login</a> <div id="modal" class="popupcontainer" style="display:none;"> <header class="popupheader"> <span class="header_title">login</span> <span class="modal_close"><i class="fa fa-times"></i></span> </header> <section class="popupbody"> <!-- social login --> ...

java - Are static variables initialised from a file initialised only once -

i creating class in java represent string , color, called coloredstring. wanted able create 1 of these objects using color name of color recognized .net framework. such list of colors here: http://www.simplehtmlguide.com/colours.php . since java doesn't have comprehensive list of "known colors", solution have program read file populate list of known colors use. so, made text file following format: aliceblue #f0f8ff antiquewhite #faebd7 aqua #00ffff aquamarine #7fffd4 the first word color name , second in format #rrggbb specify color code. since wouldn't want read file every time call constructor coloredstring, thought might have read static variable, in hopes when program runs, file read once , create single instance of static variable referenced instance of coloredstring. here code wrote this: import java.awt.color; import java.io.file; import java.io.filenotfoundexception; import java.util.arraylist; import java.util.scanner; public class coloredstring {...

javascript - Highcharts Pie Charts Show Outline When Empty -

i have pie chart displaying on reporting dashboard. however, business request made retain chart outline , display 'nodata' message in center when series empty. the business did not of floating label on page when chart empty. using existing chart object, possible fabricate chart outline , display nodata message? it possible add custom shape, e.g. circle, showing in case there no data. using chart's events load , redraw can update shape fit in chart , placed in center or remove when data added chart. api reference renderer.circle: http://api.highcharts.com/highcharts#renderer.circle example: http://jsfiddle.net/v8n1159o/1/ chart: { events: { load: function () { var chart = this; if (!chart.hasdata()) { var r = math.min(chart.plotwidth / 2, chart.plotheight / 2), y = chart.plotheight / 2 + chart.plottop, x = chart.plotwidth / 2 + chart.pl...

mysql - How to control .htaccess with php or how to input php code inside .htaccess file -

i'm not in .htaccess, don't know how work, have site , site link that: mysite.com/pagee.php?menu_id=1 use .htaccess code: <ifmodule mod_rewrite.c> rewriteengine on # 1-level rewriterule ^home/{0,1}$ pagee.php?menu_id=1 [qsa,l] </ifmodule> and work that: mysite.com/home/ but problem have lot of page like: mysite.com/pagee.php?menu_id=2, mysite.com/pagee.php?menu_id=3, mysite.com/pagee.php?menu_id=4, mysite.com/pagee.php?menu_id=5, mysite.com/pagee.php?menu_id=6, and pagee.php code is: <?php require_once('config2.php'); $menu_id = intval($_get['menu_id']); $query = "select * menu `menu_id`=$menu_id"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo '<h1>'.$row['mname'].'</h1>'; } ?> pagee.php work mysql so how while code work inside .htaccess that: <ifmodule mod_rewrite.c> rewriteengine on # 1-level <?php $...

mysql - Rename and add prefix to all tables with phpMyAdmin -

Image
i want add prefix , rename tables in database phpmyadmin. i’ve tried these 2 scripts : 1) select concat('rename table', table_name, ' ', 'prefix_',table_name,';') information_schema.tables table_schema='db_name'; 2) select concat('alter table ', table_name, ' rename osc_', table_name, ';') information_schema.tables table_schema='db_name'; phpmyadmin says script ok (see screen shot) nothing change. missing phpmyadmin ? finally, found easy way : 1) select tables want add prefix 2) choose in select option : replace prefix table 3) fill field prefix. screenshot :

Html5 form validation with required and disabled element -

i realize should never disable element , require it, because how user make valid if it's disabled? however, have <select> of products want users choose from. when select 1 of products <select> product's models populated, enabled, , required only if product has 1 or more models . otherwise, model select disabled , emptied. while think code perfect , can make model dropdown never disabled , required @ same time, i'm not perfect. so, form able submitted <select> disabled , required? update taken w3.org: constraint validation: if element required, , value idl attribute applies , in mode value, and element mutable , , element's value empty string, element suffering being missing. looked specific of means "mutable". a form control can designated mutable. note: determines (by means of definitions , requirements in specification rely on whether element designated) whether or not user can modify value or checkedness ...

java - Parsing JSON with google-gson -

from server comes answer { "error":false, "lessons":[ { "id":1, "discipline":"??????????", "type":"lecture", "comment":"no comments" }, { "id":2, "discipline":"???. ??", "type":"lecture", "comment":"no comments" } ] } how correctly read object "lessons", , add list ? use wrapper object , directly read wrapper obj = new gson().fromjson(data, wrapper.class); import java.util.list; import com.google.gson.gson; class wrapper { boolean error; list<lesson> lessons; //getters & setters } class lesson { string id; string discipline; string type; string comment; //getters & setters } public class gsonsample { public static void main(string[] args) { string data = "{\"error\":false,\"lessons\...

pdf - PDFClown image extraction images inverted -

i'm working pdfclown , i'm trying extract images pdf file. use example code provided source code can found @ http://pdfclown.org . imageextractionsample.java. the problem images negative , flipped horizontally. know how resolve problem? check other pdf files see if other pdf files giving rotated or flipped images. imageextractionsample.java not checking rotation or matrix defined transformations image object writes content file (so work jpg images not ccit encoded images example). so there things consider when extract image pdf: image can rotated using attached transformation matrix (ctm); image can rotated/transformed part of form transformed; image can placed without transformation on page page rotated; image may contain overlaid mask on top of (and mask can rotated , transformed); jpg image stored pretty there other formats supported pdf ccit compression, lzw compressed images etc; but general suggestion when extract jpg image pdf using pdfclown...

javascript - How to find an element within another element without an id -

i trying change values of input element when value of select dropdown changes. when select dropdown changes, want change hidden textbox , normal textbox td class="owner" . within td tag there multiple elements type="hidden" , 1 input type= text. want change values of element type="hidden" , id ending _lkid , _lkold , element within td of type="text" , within span tag i don't have id of elements within td generated automatically nor can assign class elements. can assign class td . i able change values of hidden text, unsure of how change type="text" field. pointers helpful. jsfiddle : https://jsfiddle.net/4honph7n/3/ this js not best/effective code written, taking baby steps jquery html <select class="selectclass"> <option>option 1</option> <option>option 2</option> </select> <table> <tr> <td class="owner"> ...

java - Select/mark specific word in SWT Textfield -

Image
i've got swt textfield text added automatically. want select specific phrase in text automatically, user replace without manual selection. i've found in api selectall() method, works selects text, not specific part. is there way so? text#setselection(int start, int end) need. example: text text = new text(shell, swt.border); text.settext("this random text"); text.setselection(5, 7); looks this:

java - Color of setPixel -

Image
found example: raster.setpixel( pf, jj, clr ); but clr has 4 elements: static int[] clr = {0, 0, 0, 255}; why? 4th element mean? doesn't work without it, throws arrayindexoutofboundsexception. as per comment, confirmed raster if of type writableraster . first, exception it doesn't work without it, throws arrayindexoutofboundsexception. from documentation, aioobe thrown if coordinates not in bounds, or if given array small hold input. now represent 4 input given in array, the input array define sample each bands of raster. if call example, writableraster#getnumbands should return 4. but whare bands ? here visual representation of array of 3 samples represent : now fourth band, i'm pretty sure alpha sample. well, @ least 1 of them alpha can't confirm 1 can modify order of bands when creating raster.

openid - Open ID 2.0 and Open ID Connect -

we relying party uses oauth 1.0. we're looking develop endpoints openid , openid connect. question is: if develop single endpoint openid connect, compatible openid, or other way around? the reason need both because have identity providers use each of these. thanks! no, openid connect not backwards compatible openid 2.0. in fact openid 2.0 deprecated.

jquery - Saving date from datepicker -

in form i'm using datepicker plugin. works fine, , form code looks this: = simple_form_for @person |f| = f.input :born, input_html: {class: "datepicker"}, as: :string = f.input :died, input_html: {class: "datepicker"}, as: :string = f.submit however, params in form of string, "2015/02/04" , not saved in database. classic input params competely different. how can make these params save database? your date string looks 2015/02/04 default format of datepicker plugin, save database need change 2015-02-04 format. need in action params[:born] = params[:born].gsub("/", "-") or you need pass option when initializing datepicker plugin, give below $( ".datepicker" ).datepicker({ dateformat: 'dd-mm-yyyy' }); hope helps!

How to scanf to just one dimension of a multidimensional array in C? -

suppose have c code this, declares small multidimensional array: #include <stdio.h> #include <conio.h> int main(void) { int mat[5][2] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} } scanf("%i", &mat[][]); while (getchar() != '\n'); return 0; } and want change do scanf("%i", &mat[][]); , , possibly line below it, allow me read user-supplied integers 2nd column of 5-by-2 multidimensional array. i trying find simplest possible solution, without concern software security , without unnecessarily calling libraries. you want this. int i=0; do{ scanf("%d", &mat[i][1]); i++; }while (getchar() != '\n');

accelerometer - Android: Magnetometer data deviates -

Image
i trying estimate heading accelerometer, gyro , magnetometer data. have implemented complementary filter here . what trying holding phone in hand , walked 15 steps in straight line , trying estimate euler angles given in link above. when plot raw data, observe magnetometer data deviates. here images of raw sensor data. my question is: how estimate euler angles indicate walking in straight line. were walking indoors, or somewhere there might electrical or magnetic fields? judging magnetometer graph, that's what's happening. if so, i'm afraid there's no solution problem. try running compass app, or carrying toy compass, , walk same path. bet you'll see compass swing walk. i've been environments moving compass 3 feet down table can cause swing 180 degrees. as aside: never want euler angles. have degenerate cases. try use transformation matrices or quaternions if can.

aleagpu - atomicCAS and __shfl_xor -

i cannot find these 2 apis (atomiccas , __shfl_xor) in aleagpu framework. there special problem using them or supported in future ? we support atomiccas , __shfl_xor in upcoming version 2.1 of alea gpu, released soon.

css - What's the best way to not display default input styles? -

does know nice way of hiding default styles inputs, such text, textarea, range, radio buttons / checkboxes etc? i include following code projects: css input[type="text"], input[type="email"], input[type="url"], textarea, select { -webkit-appearance: none; -moz-appearance: none; -ms-appearance: none; -o-appearance: none; appearance: none; } which works greats inputs such text, teaxtarea , select, others? i use following code radio , checkboxes: css -webkit-transform: translatey(-50%); -moz-transform: translatey(-50%); -ms-transform: translatey(-50%); -o-transform: translatey(-50%); transform: translatey(-50%); appearence: none; but best way? finally onto range, use: css input[type=range] { -webkit-appearance: none; /* hides slider custom slider can made */ width: 100%; /* specific width required firefox. */ } input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; } input[type=range]:focu...

phpexcel - figuring out how to get row id column id with php excel -

im trying find way rowid , columnid of excel sheet using php, if($date == $row){ $rowid = 'something} ive seen $row = $objphpexcel->getactivesheet()->getrowiterator($searchvalue)- >current(); $celliterator = $row->getcelliterator(); $celliterator->setiterateonlyexistingcells(false); foreach ($celliterator $cell) { echo $cell->getvalue(); } but $searchvalue refers row, not actual search term, need find current date in sheet , current date on column named date, , if find date rowid/colid, can write row , columns, know using 6 cols of given row, ideas on ? or pointers maybe $row = $objphpexcel->getactivesheet() ->getrowiterator($searchvalue)->current(); $celliterator = $row->getcelliterator(); $celliterator->setiterateonlyexistingcells(false); foreach ($celliterator $cell) { echo 'row: ', $cell->getrow(), php_eol; echo 'column: ', $cell->getcolumn(), php_eol; echo 'coordinate: ', $ce...

css3 - CSS 3D Effect doesn't work in Mozilla FireFox -

when visit google drive document @ https://goo.gl/u6p82y google chrome or opera browser link's hover effect works fine. in mozilla firefox browser hover effect doesn't work. must change? .flip3d { width: 200px; height: 120px; margin: auto; float: left; } .flip3d > .front { position: absolute; -webkit-transform: perspective(600px) rotatey(0deg); -moz-transform: perspective(600px) rotatey(0deg); width: 200px; height: 120px; backface-visibility: hidden; -webkit-transition: transform .5s linear 0s; -moz-transition: transform .5s linear 0s; } .flip3d > .back { position: absolute; -webkit-transform: perspective(600px) rotatey(180deg); -moz-transform: perspective(600px) rotatey(180deg); width: 200px; height: 120px; backface-visibility: hidden; -webkit-transition: transform .5s linear 0s; -moz-transition: transform .5s linear 0s; } .flip3d:hover >.front { -webkit-transform: perspective(600px) rotatey(-180deg); -moz-transform: perspective(600px) rotatey(0deg); }...