Posts

Showing posts from January, 2014

Manipulating individual tiles in an SVG pattern -

i'm trying create interactive grid web game (html, js, etc.), in every cell should change it's fill on hover/click. need both regular square grid, , triangular grid. want vector based scale nicely fit different screen sizes. thought easiest way create pattern , fill on rectangle. code have far: <pattern id="basetile" width="10" height="10" patternunits="userspaceonuse"> <path id="tile" d="m 0,0 l 0,10 10,10 10,0 z" fill="none" stroke="gray" stroke-width="1"/> </pattern> for square, , triangular grid: <pattern id="basetile" width="10" height="10" patternunits="userspaceonuse"> <path d="m 5,0 l 10,2.5 10,7.5 5,10 0,7.5 0,2.5 z" fill="none" stroke="gray" stroke-width=".1" /> <path d="m 5,0 l 5,10" fill="none" stroke="gray" stroke-width="

mysql - Handling SQL reserved table and column names -

is there way handle reserved table & column names in app can work through kinds of databases oracle, mysql, sql server, postgresql etc. currently, have following : oracle - use double quotes. mysql - use backtick or double quotes (depends if ansi_quotes mode enabled) sql server - use brackets postgresql - use double quotes. i aware ansi standard states use double quotes unfortunately not dbms seem support them. use double quotes. that's standard says, , surprisingly, works on platforms. require mysql have ansi_quotes enabled, or set @ session level : set session sql_mode = 'ansi' (i used ansi not ansi_quotes here because makes mysql bit saner). postgresql doesn't require special settings identifiers (though old versions need standard_conforming_strings = on handle literals sensibly). neither oracle. modern ms-sql shouldn't require special settings support double quoted identifiers : when set quoted_identifier on (default)

java - How to optimize pagination on a SELECT DISTINCT sql? -

my query select distinct on large database, , in pgadmin sql tool query lasts 12 sec. select distinct on (city, airport, zip, country, name) city, airport, price, id mytable; the spring-batch reader definition: jpapagingitemreader<myentity> reader; reader.setpagesize(page_size); if define page_size large database columns, performance equal 12 sec. if set size lower value (eg pagesize = 100.000 on 1.000.000 datarows db), performance bad (~ 10x long). spring-batch applies specific pagination on queries in background. does: query.setfirstresult(); query.setmaxresult(); if page size 10, den queries executed follows: firstresult, maxresult 0, 10 10, 10 20, 10 30, 10... this again translates limit , offset in sql. question: select distinct on not combinable pagination limit/offset? me seems if full select distinct query executed again on each "pagination" run, , lasts long. so, if database must anyhow make full distinct select be

c++ - Adding a 1 bit flag in a 64 bit pointer -

if define union traversing data structure squentially ( start , end offset) or via pointer tree structure depending on number of data elements on 64 bit system these unions aligned cache lines, there possibility of both adding 1 bit flag @ 1 of 64 bits in order know traversal must used , still allowing reconstruct right pointer? union { uint32_t offsets[2]; tree<nodedata> * tree; }; it's system dependent, don't think 64-bit system uses full pointer-length yet. also, if know data 2 n -aligned, chances n bits sitting idle there (on old systems not exist. don't think of 64-bit systems, , anyway no longer of interest). as example, x86_64 uses 48bits, upper 16 must same bit47. (sign-extended) example, arm64 uses 49bits (2 mappings of 48bit @ same time), there have 15 bits left. just remember corect pilfered bits. (you might want use uintptr_t instead of pointer, , convert after correction.) using mis-aligned or impossible pointer causes be

ruby on rails - Acts as taggable not migrating because I have another tags model -

i'm trying migrate acts_as_taggable install it, but, since have table called "tags", photo tagging, collapse , wont migrate. how can change name table acts_as_table creates? possible? thanks lot! you can take docs @ http://rubydoc.info/gems/acts-as-taggable-on/3.4.1/frames class user < activerecord::base acts_as_taggable # alias acts_as_taggable_on :tags acts_as_taggable_on :skills end just use second line new tag model name

android - Drive Api auth suddenly fails -

my android apps , running half year , on 1 year. 1 can cast movies google drive chromecast other can stream music google drive device. since 2 days this: drive.files().listfiles() throws this: w/system.err﹕ com.google.api.client.googleapis.json.googlejsonresponseexception: 403 forbidden w/system.err﹕ { w/system.err﹕ "code": 403, w/system.err﹕ "errors": [ w/system.err﹕ { w/system.err﹕ "domain": "usagelimits", w/system.err﹕ "message": "access not configured. please use google developers console activate api project.", w/system.err﹕ "reason": "accessnotconfigured" w/system.err﹕ } w/system.err﹕ ], w/system.err﹕ "message": "access not configured. please use google developers console activate api project." w/system.err﹕ } w/system.err﹕ @ com.google.api.client.googleapis.services.json.abstractgooglejsonclientrequest.newexceptiononerror(abstractgooglejsonclientrequest.java:113) w/sys

Tibco EMS - File to Database Configuration issue with JVM -

i configuring tibco ems 7.0 server on solaris 10 default file based store database store (oracle rac). starting instance log shows following jvm error: 2014-09-18 14:34:36.729 logging file '/lcl/dev/logs/tibco/jmspm2.log' 2014-09-18 14:34:36.729 error: error loading jvm: ld.so.1: tibemsd64: fatal: /lcl/dev /apps/tibco/components/eclipse/_jvm/lib/sparc/libjvm.so/lib/sparcv9/server/libjvm.so: not directory i have installed hibernate 3.2.5.001 tibco uses eclipse jvm , files. istalled recommended instantclient_11_2 includes ojdbc5. below modified tibemsd.conf dbstore_classpath, dbstore_driver_name, dbstore_driver_dialect, jre_library as: dbstore_classpath = /lcl/dev/apps/tibco/components/eclipse/plugins/com.tibco.tpcl.org.hibernate_3.2.5.001/hibernate3.jar;/lcl/dev/apps/tibco/ems/7.0/bin/dom4j-1.6.1.jar;/lcl/dev/apps/tibco/ems/7.0/bin/commons-collections-2.1.1.jar;/lcl/dev/apps/tibco/ems/7.0/bin/commons-logging-1.0.4.jar;/lcl/dev/apps/tibco/ems/7.0/bin/ehcache-1.2.3.

PHP array_combine & range VS foreach loop to get array of numbers -

i have been thinking this, code readability tend use php built in functions range & array_combine generate array of numbers this: array( 5 => 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, ... 60 => 60 ); so use generate above: $nums = range(5, 60, 5); $nums = array_combine($nums, $nums); i wondering if there speed or memory difference between above approach , using loop this: for ($i = 5; $i <= 60; $i++) { $nums[$i] = $i; $i += 5; } i want know if approach practice or if @ code try find out live? the following method seems fast small numbers: $tmp = range(5,$limit,5); $tmp = array_combine($tmp, $tmp); however, loop faster bigger numbers: for($i =5; $i<=$limit; $i += 5) $tmp[$i] = $i; try following code here : <?php $limit = 200; $time_start = microtime(true); $tmp = range(5,$limit,5); $tmp = array_combine($tmp, $tmp); $time_end = microtime(true); echo $time_end - $time_start; echo "

c# - Completely stuck at this XML Deserialization -

i cannot life of me figure out why unable deserialize xml class instances. please see 2 approaches have tried (and respective error messages), below. method one: public static skillcollection deserialize(string path) { using (memorystream memorystream = new memorystream(encoding.utf8.getbytes(path.combine(path, "skills.xml")))) { skillcollection skills = null; try { var serializer = new datacontractserializer(typeof(skillcollection)); var reader = xmldictionaryreader.createtextreader(memorystream, encoding.utf8, new xmldictionaryreaderquotas(), null); skills = (skillcollection)serializer.readobject(memorystream); } catch (serializationexception ex) { globals.instance.applicationlogger.log("the object graph not deserialized binary stream because of following error: " + ex); } re

c++ - GTK 3 How to connect one signal to multiple widgets? (part 2) -

this continuation of question: gtk 3 how connect 1 signal multiple widgets? i have code in c++ using gtk3. it creates 2 text entries , 1 button. want action done text entered when button pressed. (in case want text printed.) code following: #include <iostream> #include <gtk/gtk.h> using namespace std; gtkwidget *wventana; gtkwidget *wgrid; typedef struct { gtkwidget *entrada1, *entrada2; } widgets; void on_procesar (gtkbutton *procesar, widgets *w) { const char * texto = gtk_entry_get_text(entrada1); cout << texto << endl; } void ventana(string titulo, int margen) { const char * tituloc = titulo.c_str(); wventana = gtk_window_new (gtk_window_toplevel); } void grid() { wgrid = gtk_grid_new(); gtk_container_add(gtk_container(wventana), wgrid); } gtkwidget *boton(string texto, int x, int y, int lx, int ly) { const char * wtexto = texto.c_str(); gtkwidget *wboton; wboton = gtk_button_new_with_label (wtexto);

java - JTable will set to editable after converting ResultSet to TableModel with DbUtils. How to make it non-editable again? -

here code doing this` public static void addsong(string[] filedetail, jtable songdata_table) { try { con = dbconnection.getcon(); stmt = con.createstatement(); stmt.executeupdate("insert songs values (null,'" + filedetail[0] + "', '" + filedetail[1] + "',null,null)"); resultset rs = stmt.executequery("select * songs"); tablemodel model = dbutils.resultsettotablemodel(rs); songdata_table.setmodel(model); if (con != null) { stmt.close(); con.close(); } } catch (sqlexception e) { system.out.println("error in stmt " + e); } } variable names should not start upper case character. songdata_table should songdatatable . override iscelleditable(...) method of jtable, instead of tablemodel. jtable songdatatable = new jtable() { @override boolean iscelleditatable(int row, int column) {

java - how to send instruction to server every five second -

i have written part of code server receive instruction client , send request client. want send instruction(json message) client every 5 second. how that? public static void main(string[] args) throws ioexception, interruptedexception, parseexception { synchronisedfile fromfile = null; fromfile=new synchronisedfile("file.txt"); fromfile.checkfilestate(); int counter = 1; int receivedcounter = 1; string receivedtype=null; datagramsocket clientsocket = new datagramsocket(); inetaddress ipaddress = inetaddress.getbyname("localhost"); byte[] senddata = new byte[1024]; byte[] receivedata = new byte[1024]; while(true){ instruction inst = fromfile.nextinstruction(); //system.out.println(inst.tojson()); jsonobject jo = new jsonobject(); jo.put("type", "inst"); jo.put("inst", inst.tojson()); jo.put("counter", counter); //syst

python - Modifying a group within Regular Expression Match -

so have function apart of django (v 1.5) model takes body of text , finds of tags, such , converts correct ones user , removes of others. the below function works requires me use note_tags = '.*?\r\n' because tag group 0 finds of tags regardless of whether user's nickname in there. curious how use groups can remove of un-useful tags without having modify regex. def format_for_user(self, user): body = self.body note_tags = '<note .*?>.*?</note>\r\n' user_msg = false if not user none: user_tags = '(<note %s>).*?</note>' % user.nickname user_tags = re.compile(user_tags) tag in user_tags.finditer(body): if tag.groups(1): replacement = str(tag.groups(1)[0]) body = body.replace(replacement, '<span>') replacement = str(tag.group(0)[-7:]) body = body.replace(replacement, '</span>')

Modifying strings in Java practice -

this question has answer here: indexof in string array 6 answers public static void displaywords(string line) { // while line has length greater 0 // find index of space. // if there one, // print substring 0 space // change line substring space end // else // print line , set equal empty string } line = "i love you"; system.out.printf("\n\n\"%s\" contains words:\n", line ); displaywords(line); hi, i'm having trouble above code, it;s practice problem "change line substring space end" confuses me. know how find index of space , printing string beginning index. expected output: i love slaks recommending in comment use substring() method. checking api documentation string : public string substring(int beginindex, int endindex) returns new string substring of string.

java - Setting Wrong Application Name -

i have application named umall replaced slash first activity stuck small problem don't know how handle it.. gave application name directly in application lable manifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ef.umall" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="15" android:targetsdkversion="19" /> <uses-permission android:name="android.permission.internet" /> <application android:allowbackup="true" android:icon="@drawable/app_logo" android:label="umall" android:theme="@style/apptheme" > <activity android:name=".mainactivity" android:label="" > </activity> <

php - undefined index (opencart) -

i'm trying add new input text in opencart, view payment_method.tpl added <label><?php echo $text_comments; ?></label> <textarea name="comment" rows="8" style="width: 98%;"><?php echo $comment; ?></textarea> <label><?php echo $text_referred; ?></label> // code <input type="text" name="referred" value="<?php echo $referred; ?>" /> in controller payment_method.tpl added if (!$json) { $this->session->data['payment_method'] = $this->session->data['payment_methods'][$this->request->post['payment_method']]; $this->session->data['comment'] = strip_tags($this->request->post['comment']); $this->session->data['referred'] = $this->request->post['referred']; //my code } and if (isset($this->

css - bootstrap progressbar thickness over 40px -

i want use progress bar of bootstrap fancy looking barricade tape. works quite nice, want want make bar thicker. changed background-size of active progress-bar 40px 60: div.progress.active .progress-bar { background-size: 60px 60px; } that worked far bar thicker animation not loop correctly anymore. what have change loop occurs after 60 instead of 40 pixel? see yourself: http://jsfiddle.net/ok94vqoa/1/ you need update keyframes progress-bar-stripes animation 60px well. jsfiddle @-webkit-keyframes progress-bar-stripes { { background-position: 60px 0; } { background-position: 0 0; } } @-o-keyframes progress-bar-stripes { { background-position: 60px 0; } { background-position: 0 0; } } @keyframes progress-bar-stripes { { background-position: 60px 0; } { background-position: 0 0; } }

matlab - improfile output length doesn't comply with input vectors length -

i have code draws circle consisted of 50 points. want calculate intensity of each point, used improfile. theta=linspace(0,2*pi,50); rho=ones(1,50)*radius; [x,y] = pol2cart(theta,rho); x=x+center(1); y=y+center(2); c = improfile(bw4,x,y); % bw4 binary thinned image i know c must vector containing intensity of 50 points produced when write size(c) in work space this: >> size(c) ans = 142 1 i can't understand problem code? idea why it's working way? thanks improfile follow path defined coordinates x,y provided not give results @ these exact coordinates. use syntax c=improfile(i,xi,yi,n) n=50 . in case: c = improfile(bw4,x,y,50); this force output [50x1] vector.

Scala pickling case class versioning -

i able use scala pickling in order store binary representation of case class. i know if there way manage versioning of case class (the way protocol buffer allows do) here example i make program @ date, following case class case class messagetest(a:string,b:string) then serialize instance of class import scala.pickling._ import binary._ val bytes=messagetest("1","2").pickle and store result file later on, might have make evolution on case class, add new optional field case class messagetest (a:string,b:string,c:option[string]=none) i able reuse data stored in file , deserialize , able recover instance of case class (with default value new parameter) but when use following code import scala.pickling._ import binary._ val messageback=bytes.unpickle[messagetest] i got following error : java.lang.arrayindexoutofboundsexception: 26 @ scala.pickling.binary.binarypicklereader$$anonfun$2.apply(binarypickleformat.scala:446)

c - How possibly can a unary +/- operator cause integral promotion in "-a" or "+a", 'a' being an arithmetic data type constant/variable? -

Image
this seemingly trivial line taken c book mike banahan & brady (section 2.8.8.2) . i can understand how implicit promotion comes play in expressions c=a+b depending on types of operands, unable grasp how , in case same can figure in -b , b legitimate operand. can explain , give proper example? extracted text follows: the usual arithmetic conversions applied both of operands of binary forms of operators. integral promotions performed on operands of unary forms of operators. update: lest goes unnoticed, here adding asked based on ouah's answer in comment– book says ' only integral promotions performed '...does mean in expression x=-y , 'x' long double , 'y' float, 'y' won't promoted long double if explicitly use unary operator? know be, asking nevertheless clearer idea "only integeral promotions..." part. update: can explain example how promotion comes play following bit-wise operators? last three, should as

hadoop - MapReduce Old API - Passing Command Line Argument to Map -

i coding mapreduce job finding occurrence of search string (passed through command line argument) in input file stored in hdfs using old api. below driver class - public class stringsearchdriver { public static void main(string[] args) throws ioexception { jobconf jc = new jobconf(stringsearchdriver.class); jc.set("searchword", args[2]); jc.setjobname("string search"); fileinputformat.addinputpath(jc, new path(args[0])); fileoutputformat.setoutputpath(jc, new path(args[1])); jc.setmapperclass(stringsearchmap.class); jc.setreducerclass(stringsearchreduce.class); jc.setoutputkeyclass(text.class); jc.setoutputvalueclass(intwritable.class); jobclient.runjob(jc); } } below mapper class - public class stringsearchmap extends mapreducebase implements mapper<longwritable, text, text, intwritable> { string searchword; public void configure(jobconf j

java - Is it possible to append text in the textfield while typing? -

i trying build task manager. trying let user edit task, , program respond command without user pressing enter button. for example, if have list of tasks: go school good day if user types "edit 2" in text field, program append content of 2nd task @ of input without having press enter button i.e. text field should change edit 2 day . user can modify content. is possible? if yes, necessary things need learn? you can done using textproperty() of textfield , playing around it. i have created demo : input edit 1 output edit 1 go school code import java.util.hashmap; import java.util.map; import javafx.application.application; import javafx.beans.value.changelistener; import javafx.beans.value.observablevalue; import javafx.scene.scene; import javafx.scene.control.textfield; import javafx.scene.layout.pane; import javafx.stage.stage; public class textfieldautoappend extends application { @override public void start(stage primaryst

objective c - UITableView iOS 8 Xcode 6.0.1 Unrecognised Selector Send To Instance -

i have simple uitableview. works fine on ios 7 on ios 8 not. have custom uitableviewcell contains text labels, buttons, images. when press button inside tableview cell got error. here code: -(ibaction)addtofavorites:(id)sender { uibutton *editbutton = (uibutton*)sender; getmoretableviewcell *editcell = (getmoretableviewcell*)[[[editbutton superview] superview] superview]; int editindex = (int)[[_chapters indexpathforcell:editcell] row]; [self readtopscoreplist]; if([[[[_data valueforkey:key] valueforkey:[nsstring stringwithformat:@"%i",editindex]] valueforkey:@"isdefault"] boolvalue] == yes) { [editcell.addbutton setimage:[uiimage imagenamed:@"fav_0.png"] forstate:uicontrolstatenormal]; [self savetoplist:no sender:sender]; nslog(@"new %@",[[[_data valueforkey:key] valueforkey:[nsstring stringwithformat:@"%i",editindex]] valueforkey:@"isdefault"]); } else { [e

javascript - Use minute(of the day) for showing hours in dc js x axis -

i have minutes of day i.e., form 0 1440. currently showing these minutes is, how show hours. example: 3:am ......... 4:am.........5:am i tried several others things no luck till now. here doing currently: .x(d3.scale.linear().range(1, chartwidth).domain([1, 1440])) and here have tried: d3.time.scale().domain([new date(2013,0,2), new date(2013, 0, 3)]) this show time how want graph doesn't show up. sounds may not have set .xunits correctly. want .xunits(d3.time.hours) doing. https://github.com/dc-js/dc.js/blob/master/web/docs/api-latest.md#xunitsxunits-function basically, .xunits has match scale. this common gotcha dc.js , we'd eliminate xunits, don't know how to. used determine number of points/bars.

java - How to hide the Jtable column data? -

i want hide data of column of jtable, not hide column view,just data. column contain data profit , customer doesn't want show profit in code use values of column , when user select specified row. how achieve customer need , still able values of column when selecting after hiding data(displaying column empty still has values)? you need remove tablecolumn tablecolumnmodel of jtable . example: table.removecolumn( table.getcolumn(...) ); now column not display in table, data still available in tablemodel . access data use: table.getmodel().getvalueat(...);

android - Camera Activity returns null URI -

i testing app on samsung note, here how used call camera intent captureintent = new intent(mediastore.action_image_capture); startactivityforresult(captureintent, camera_capture); then in activity result: protected void onactivityresult(int requestcode, int resultcode, intent data) { if (resultcode == result_ok) { if(requestcode == camera_capture) { picuri = data.getdata(); //continue code } } } but changed testing galaxy nexus , noticed data.getdata() returns null rather temp image uri. read couple of recommendations , mentioned passing file camera activity location of new iamge. changed code to: .... file photofile = createimagefile(); //photofile = new file(environment.getexternalstoragedirectory(), "pic.jpg"); captureintent.putextra(mediastore.extra_output, uri.fromfile(photofile)); startactivityforresult(captureintent, camera_capture); .... using method private file createimagefile() throws i

python load csv file with quoted fields where commas are used as 1000s separator -

is there simple way in python load csv file may contain lines ones listed below dataframe? 1.0, 2.0, 3.0, "123,456,789.999" 1000.0, 2000.0, 3000.0, "123,456,789.123" obviously type of of columns should numeric (float64, int64, etc.) . additionally, countries use (space)" " 1000 separator rather than comma . there way specify that? pandas.io.parsers.read_table can handle comma separated numbers provided give converters argument handles commas: converters : dict. optional dict of functions converting values in columns. keys can either integers or column labels here solution in vanilla python: import csv def try_convert_number(s): val = s.replace(',', '') try: return int(val) except valueerror: try: return float(val) except valueerror: return s result = [] # in python 2 use: open('file.csv', 'rb') f: open('file.csv', newline=&

PHP Codeigniter - Handle multiple databases on the same server -

if write $db1 = $this->load->database('data1',true); $db2 = $this->load->database('data2',true); and both databases on same server, codeigniter switch without re-connect server? if not, there way make that? thanks! well, codeigniter core take care of multiconnectivities. gets , remembers connection ids , call them on database interactions. allow "auto connect" feature load , instantiate database class every page load. enable "auto connecting", add word database library array, indicated in following file: application/config/autoload.php for more info database connection in codeigniter visit ellislab.com

php - Best practice linking back to source view -

i have several views show detail edit button. when user clicks on edit button, go edit view item. edit view want link original view. best practice people use edit view knows take user to? i using php laravel framework. example: user on /invoice/1/detail, click on edit /contact/9/edit, click on save or cancel, go /invoice/1/detail or user on /task/2/detail, click on edit /contact/9/edit, click on save or cancel, go /task/2/detail or user on /report/3/detail, click on edit /contact/9/edit, click on save or cancel, go /report/3/detail you benefit resource controllers ( http://laravel.com/docs/4.2/controllers#restful-resource-controllers ) if you're willing take plunge. after adopting those, detail views look public function show($id) {...} and edit views like public function edit($id) {...} and routing more or less handle itself. assuming you've adopted convention, can put common logic in base controller , have individual controllers extend the

javascript - Bootstrap button text color -

i using bootstrap 3 custom buttons cant reason change brand text colour nor dropdown triangles. i've tried couple of things, still no luck... <div class="container"> <div class="row" style="margin-top: -30px;"> <ul class="nav nav-tabs" role="tablist"> <li class="dropdown" style="margin-right: 70px; margin-left: 60px;" > <a class="btn btn-inverse :active" data-toggle="dropdown" href="#"> wristbands <span class="caret"></span> </a> <ul class="dropdown-menu" role="menu"> ... </ul> </li> <li class="dropdown" style="margin-right: 70px;"> <a class="dropdown-toggle" data-toggle="dropdown" href="#"> hawaii <span class="caret"></span> </a

c# - Should a Presenter in the Model-View-Presenter pattern handle multiple 'UI' elements on a View? -

Image
i implementing diagram/flow-chart type designer using model-view-presenter (mvp) pattern in wpf. i have though of pattern (and of others such passive view , mvvm) high level architectures fail address of complexity involved in rich uis (here come trolls). in particular instance, have ui resembles following mockup: i have made choice use presenter objects each element requires presentation logic on designer. has left me following designers far. designerpresenter controlpresenter controloverlaypresenter connectionpresenter connectionpointpresenter overlaypresenter the reason have implemented each of these because each of them needs handle presentation logic , communicate actions business/domain tier separately in order avoid bloat (imo). the other way see doing if there 1 presenter handles presentation logic seems out of control quickly. my question(s) follows: is common see presenter provided each ui element on screen such doing in order allow separ

javascript - How to show hidden content according to clicked value jquery? -

sorry midunderstanding. meant index, not value. sorry. i wondering if there way use value of shown content ".wbox" of jsfiddle example coincide hidden value, when clicked show hidden content? for example, when cont 1 clicked, hidden box 1 shows. when cont2 clicked, hidden box 2 shows... , forth. here fiddle: http://jsfiddle.net/kqbltn8b/1/ html: <div class="box"> <div class="content one"> <h1>cont 1</h1> </div> <div class="content two"> <h1>cont 2</h1> </div> <div class="content three"> <h1>cont 3</h1> </div> </div> <div class="hidden-content"> <div class="hidden-box b-one">one</div> <div class="hidden-box b-two">two</div> <div class="hidden-box b-three">three</div> </div> jquery: var b

haskell - How to add a (Vector v a) constraint to an instance declaration? -

given: newtype matrix (w :: nat) (h :: nat) v matrix :: v -> matrix w h v (where v data.vector.generic.vector v a , how this?) and: instance foldable (matrix w h v) foldmap = foldmaptree foldmaptree :: (vector v a, monoid m) => (a -> m) -> matrix w h v -> m ghc complains about: matrix.hs:55:15: not deduce (vector v a) arising use of ‘foldmaptree’ context (monoid m) changing to: instance vector v => foldable (matrix w h v) foldmap = foldmaptree gives: matrix.hs:54:10: variable ‘a’ occurs more in instance head in constraint: vector v (use undecidableinstances permit this) using undecidableinstances doesn't breaks else ... there simple solution problem ... other answers suggest undecidableinstances not "bad" per se. apparently can't work ... as pointed out in comments, want not possible. foldable class expresses idea given type constructor, matrix w h v in case, can things any

Unable to install activerecord in Ruby on Rails 4.1.4 -

i unable install activerecord in ruby on rails 4.1.4. i've added gem 'activeadmin', github: 'activeadmin' end of gemfile , run bundle install . returns 0, i've tried run rails g active_admin:install command, returns following error: nameerror: undefined local variable or method install' main:object (irb):3 e:/software/ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/console.rb:90:in start' e:/software/ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/console.rb:9:in start' e:/software/ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:69:in console' e:/software/ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in run_command!' e:/software/ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands.rb:17:in ' e:/work/projects/src/technical_support_tim

numpy - Fastest way to create an array in Python -

this question has answer here: numpy array initialization (fill identical values) 6 answers i want create 3d array in python, filled -1. i tested these methods: import numpy np l = 200 b = 100 h = 30 %timeit grid = [[[-1 x in range(l)] y in range(b)] z in range(h)] 1 loops, best of 3: 458 ms per loop %timeit grid = -1 * np.ones((l, b, h), dtype=np.int) 10 loops, best of 3: 35.5 ms per loop %timeit grid = np.zeros((l, b, h), dtype=np.int) - 1 10 loops, best of 3: 31.7 ms per loop %timeit grid = -1.0 * np.ones((l, b, h), dtype=np.float32) 10 loops, best of 3: 42.1 ms per loop %%timeit grid = np.empty((l,b,h)) grid.fill(-1.0) 100 loops, best of 3: 13.7 ms per loop so obviously, last 1 fastest. has faster method or @ least less memory intensive? because runs on raspberrypi. the thing can think add of these methods faster dtype argument chosen take li

c# - Replace backslash(\) with empty string -

hi having problem while replacing string have backslash() string sregex = "2004\01".replace("\\", ""); response.write(sregex); // giving me 20041 but same when include 2 backslashes giving me output expected string sregex = "2004\\01".replace("\\", ""); response.write(sregex); // giving me 200401 string sreplace = "2004\01"; string sregex = sreplace.replace("\\", ""); so there possibility on come first case? should display same result \0 null character need use verbatim string compiler treat first back-slash instead of escape sequence string sregex = @"2004\01".replace("\\", "");

php - Increment Index in $_POST Array -

i have section of php code need $_post index increment 1 each time goes through "do while" loop. in other words, first occurrence $_post['tableserver1'] , next 1 $_post['tableserver2'] , etc. loops 6 times , stops. i have tried using variables index, trying them increment. found example in php manual http://php.net/manual/en/language.operators.increment.php increments number @ end of string, i'm not having luck getting work inside $_post index. this section of code creates set of 6 select lists contain names database. trying select lists populate $_post value if set, other wise zero. here code: <?php $x = 1; { ?> <blockquote> <p><?php echo $x . "."; ?> <select name="tableserver<?php echo $x; ?>" id="tableserver<?php echo $x; ?>"> <option selected value="0" <?php if (!(strcmp(0, '$table

html - Android Deep linking -

i trying add deep linking on android , in web page replace iframe <iframe scrolling="no" width="1" height="1" style="display: none;" src="myscheme://post/5002"></iframe> and in manifest.xml (android app) <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme"> <activity android:name=".myactivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.view"></action> <category android:name=&quo

javascript - How to select object in dropdown -

i have city class public class city { public int id { get; set; } public string name { get; set; } public string countrycode { get; set; } } and ride class. public class ride { public guid id { get; set; } public city { get; set; } public list<city> { get; set; } public datetime dateandtime { get; set; } } what best way load cities, pass view, show them in dropdownlists , post data controller? best if add more 1 city to column. have found selectize.js have no experience javascript. can pass options json etc or list of cities database. thank time. you'll need view model, if want select multiple cities @ once. example: public class rideviewmodel { public guid id { get; set; } public datetime dateandtime { get; set; } public int fromcityid { get; set; } public list<int> tocityids { get; set; } public ienumerable<selectlistitem> citychoices { get; set; } } notice there's no list<ci

android - Google maps api v2 customize location marker -

Image
is possible customize location marker? i've googled lot , find lot manuals markers, nothing default location marker. i'm trying make this: thx in advace yeah, possible. achieve this, first create marker, longitude , latitude position. next, can change default marker doing like: marker.icon(bitmapdescriptorfactory.fromresource(r.drawable.my_marker_icon))); this allow marker customization. enjoy!

javascript - Why does my code always end with undefined? -

i wrote javascript code, ends **undefined**mycode? have done wrong/ how can prevent in future. running code through chrome javascript console. here code //reverse string //-------------------------// //input string var string = prompt("please enter string"); //console.log(string); //find length of string var stringlength = string.length; //console.log(stringlength); //creating empty string outputting answer var reversedstring = ""; //start length of string , work backwards, inputting letter 1 @ time. (var = stringlength; >= 0; i--){ reversedstring += string[i]; //console.log(string[i]); } //outputting reversed string; alert(reversedstring); thanks answers in advance change loop for (var = stringlength; >= 0; i--){ to for (var = stringlength-1; >= 0; i--){ the problem is, array indices in javascript 0 based. lets string entered in prompt "abc", length of string 3. i

php echo line causes 500 internal server error -

$dt1 = datetime::createfromformat('m ds, y', $checkin); echo($dt1); when add echo line receive 500 internal server error. $dt1 object ..so cant echo it.it raise error.you need like.. echo $dt1->format('d.m.y');

spring - log4j configurations for non web application -

i've create simple maven application , using log4j logger. application not web application. i've tried copy log4j.properties everywhere in java folder , everywhere across project still getting following error. suggest how can fix it? log4j:warn no appenders found logger (org.springframework.web.client.resttemplate). log4j:warn please initialize log4j system properly. log4j:warn see http://logging.apache.org/log4j/1.2/faq.html#noconfig more info. log4j.properties # root logger option log4j.rootlogger=info, file, stdout # direct log messages log file log4j.appender.file=org.apache.log4j.rollingfileappender log4j.appender.file.file=c:\\logging.log log4j.appender.file.maxfilesize=10mb log4j.appender.file.maxbackupindex=10 log4j.appender.file.layout=org.apache.log4j.patternlayout log4j.appender.file.layout.conversionpattern=%d{yyyy-mm-dd hh:mm:ss} %-5p %c{1}:%l - %m%n # direct log messages stdout log4j.appender.stdout=org.apache.log4j.consoleappender log4j.appender.stdou

PHP Post Working with Fields -

i have simple form: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <form method="post" action=""> <label>filter zip code: <input maxlength="5" name="zipcode" size="6" type="text" /></label> <label>filter products: <select name="products"> <option value="">select product</option> <option value="jewelry">jewelry</option> <option value="homedecor">home decor</option> <option value="kitchen">kitchen</option> </select> </label> <label>filter materials: <select name="materials"> <option value="">select material</option> <option value="abs">abs</option> <option value="gold">gold</op