Posts

Showing posts from April, 2015

unity3d - Using Parallaxing for a 2D game in unity Understanding the Z axis -

i'm using parallaxing 2d game in unity , basically, i'm moving position of backgrounds on x axis whenever camera moves (the camera moves right or left following character). i'm having trouble understanding line means parallaxscales[i] = backgrounds[i].position.z * -1; doesn't z position have depth? mean when position.z * -1 or position.z * 5. not affecting actual depth of backgrounds ive been using in game (since moving left , right). mean. why use z axis? using unityengine; using system.collections; public class parallaxing : monobehaviour { public transform [] backgrounds; private float [] parallaxscales; public float smoothing = 1f; private transform cam; private vector3 previouscampos; void awake () { cam = camera.main.transform; } void start () { previouscampos = cam.position; parallaxscales = new float[backgrounds.length]; (int = 0; < backgrounds.length; i++) { parallaxscales[i] = b

javascript - How to load the data from .json file in httplistener -

i'm new on webservice/javascript development environment. got task - current our httplistener code serves localhost request .js file. need capable of putting json objects around in httplistener. receiving value types, objects , list (or array) json file (.json) , converts json string javascript object sending value types, objects , list javascript outputting above json data console it great if can share ideas/solution how implement on this. here's our code works .js - httplistener.cs: private static void main() { var server = new httplistener(); server.prefixes.add("http://localhost:80/"); server.start(); console.writeline("listening..."); while (true) { httplistenercontext context = server.getcontext(); httplistenerresponse response = context.response; string fileid = string.empty; try { string page = path.combine(directory.getcurrentdirectory(), context.request.url.localpath.replace("/", @"\").substr

delphi - How do I use JCL after installing -

i have installed jcl v2.4.1.4571 in d2009 (using install.bat file) http://wiki.delphi-jedi.org/wiki/jedi_code_library there lot of 'progress activity' in installation screen guess went well. my question how use newly installed jcl? i found .pas files in ..\source\common folder used expanding downloaded jcl-2.4.1.4571.zip file into. 1 .pas file jcldatetime.pas , contains 'dates , times' routines. guess can search through file routine may want, maybe there more streamlined way of finding routines? also hints on using jcl in ide itself? did not asking google. cheers posting answer because it's big comments. http://wiki.delphi-jedi.org/wiki/jedi_code_library - "the jedi code library (jcl) consists of set of thoroughly tested , documented utility functions , non-visual classes". it's code library. there couple of things plug ide jcldebug. won't google because don't use in ide. include jcl.... files in source code , can use

ios7 - How do I simulate collision(s) using a gesture, like a pan/drag? -

i've got simple things setup, sknode updated property (checking showsphysics) during touches* events. what's happening player node simple pushing other nodes out of way -- not "bouncing" them. an example might simulating cue ball being driven through break. user controlling cue ball directly. i have ideas, seem clumsy way task done. because player node doesn't have velocity perhaps?

android - Edit Text to String Not Saving What's Typed -

after extensively trying figure out why sharedpreferences blank, or never created. have concluded because edit text string isn't doing anything, yet have no idea why isn't doing anything. here code import android.content.context; import android.content.intent; import android.content.sharedpreferences; import android.os.bundle; import android.support.v4.app.fragment; import android.text.editable; import android.text.textwatcher; import android.view.layoutinflater; import android.view.menu; import android.view.menuinflater; import android.view.view; import android.view.viewgroup; import android.widget.edittext; import android.widget.textview; public class friday extends fragment{ private string gband, bband, adv1band, adv2band, cband, fband; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { sethasoptionsmenu(true); view view = inflater.inflate(r.layout.friday, contai

java - using regex to split string -

i want string "initial: at(forest), monsterat(chimera,forest), alive(chimera)" parsed into: "at(forest)" , "monsterat(chimera, forest)" , , "alive(chimera)" (i don't need "initial:"). i used code ( java - split string using regular expression ): string[] splitarray = subjectstring.split( "(?x), # verbose regex: match comma\n" + "(?! # unless it's followed by...\n" + " [^(]* # number of characters except (\n" + " \\) # , )\n" + ") # end of lookahead assertion"); this output (the underscore space): initial: at(forest) _monsterat(chimera,forest) _alive(chimera) but don't want have space before string ("_alive(chimera)"), , want remove "initial: " after splitting. if removed spaces (except "initial") original string output this: initial: at(forest),monsterat(chimera,forest),aliv

Ruby on Rails First argument in form cannot contain nil or be empty -

i used standard ruby on rails generate scaffolding. need find out how move form "new" view "posts" view (main page). keep on getting error "first argument in form cannot contain nil or empty". here "posts" view code. works fine in "new" view not "posts" view. posts view: <%= form_for(@post) |f| %> new view: <h1>new post</h1> <%= render 'form' %> <%= link_to 'back', posts_path %> form view: <%= form_for(@post) |f| %> <% if @post.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@post.errors.count, "error") %> prohibited post being saved:</h2> <ul> <% @post.errors.full_messages.each |message| %> <li><%= message %></li> <% end %> </ul> </div> <% end %> </div> <div class="fiel

f# - MathNet.Numerics not utilizing the Mkl native provider -

i have f# project uses mathnet.numerics linear algebra routines. i have placed following code in f# module: module linearalgebra open mathnet.numerics open mathnet.numerics.linearalgebra.double open mathnet.numerics.linearalgebra.generic control.linearalgebraprovider <- new algorithms.linearalgebra.mkl.mkllinearalgebraprovider() but times seeing matrix multiplication remain same whether have line of code enabled or commented out. i have installed mkl provider nuget package described here: http://christoph.ruegg.name/blog/mathnet-numerics-with-native-linear-algebra.html and have ensured these 2 dlls copied bin directory: libiomp5md.dll mathnet.numerics.mkl.dll any ideas how can detect if native provider being used? the docs bit more date mentioned blog post, seems required steps have been done. how large matrices? are involved matrices dense? is module module linear algebra code in? if not, have made sure module executed - before linear algebra code?

sqlite - Clear Cash in android application -

i have android application, use sqlite data base in application, have question data base in setting -> application manager if select clear data or clear cash, our data base deletes, need data base. example user remove data base after program not work, program related data base, how do, how can resolve problem? you need find way backup database sd card. dump csv-type file, mimic structure of database, or else create other kind of format work better you. , in case database cleared, need parse text file created backup, , put database.

html5 - How to close open html tags in an php foreach loop -

i have code produces horizontal menu in wordpress. however, produces invalid code because html tags aren't closed. have tried adding closing tags in loop seems mess menu bad. foreach ( (array) $menu_items $key => $menu_item ) { $tiny_menu_list .= '<option value="'. $menu_item->url .'">'. $menu_item->title .'</option>'; if( !$menu_item->menu_item_parent ){ $menu_list .= '<li><div><a href="' . $menu_item->url . '">' . $menu_item->title . '</a>'; if( count($menu_items) > 1 ) $menu_list .= '<span>'; continue; } $menu_list .= '|<a href="' . $menu_item->url . '">' . $menu_item->title . '</a>'; } if( count($menu_items) > 1 ) $menu_list .= '</span>'; $menu_list .= '</div></li></ul>';

scala - Found Unit: Required [SomethingElse] -

i have following scala function , won't compile because finds unit tough requires [somethingelse] def combine(trees: list[codetree]): list[codetree] = { if(trees.length < 2) trees else isortfortrees(trees.+:(new fork(trees.head, trees.tail.head, chars(trees.head).:::(chars(trees.tail.head)), weight(trees.head) + weight(trees.tail.head)))) def isortfortrees(mylist: list[codetree]): list[codetree] = { if(mylist.isempty) nil else insertfortrees(mylist.head, isortfortrees(mylist.tail)) } def insertfortrees(tobeinserted: codetree, listobe: list[codetree]): list[codetree] = { if(listobe.isempty || weight(tobeinserted) < weight(listobe.head)) tobeinserted :: listobe else listobe.head :: insertfortrees(tobeinserted, listobe.tail) } } i cannot understand why unit returned ? both ends of if statement return list[codetree]. silly mistake made cannot find it. missing here? the last expression in method method definition returns unit . mov

ios - Adding views in the negative way of a uiscrollview and changing contentsize -

i have uiscrollview calendarview in it. want 2 next months , 2 previous months loaded inside scroll view. i have 2 following methods. -(void)addcalendartoend{ iphonemonthview *phonecal = [[iphonemonthview alloc] init]; phonecal.delegate = self; phonecal.datasource = self; [phonecal selectdate:[self samedatebyaddingmonths:1 anddate:scrolldate]]; float xvalue = phonecal.frame.size.width * numberofcalendarsaftertoday; phonecal.frame = cgrectmake(xvalue, 0, phonecal.frame.size.width, phonecal.frame.size.height); [self.calendarscroll addsubview:phonecal]; int numberscroll = numberofcalendarsbeforetoday + numberofcalendarsaftertoday + 1; calendarscroll.contentsize = cgsizemake(numberscroll*phonecal.bounds.size.width,calendarscroll.bounds.size.height); [calendarscroll addsubview:phonecal]; nslog(@"content size %f",calendarscroll.contentsize.width); numberofcalendarsaftertoday++; } -(void)addcalendertobeginning{ iphonem

visual studio 2010 - c# textbox to datagridview -

Image
i want add exact value of textbox datagridview problem if add item last item add change. here print screen of sample problem.. 1st try 2nd try this code. int n = datagridview3.rows.add(); (int j = 0; j < datagridview3.rowcount; j++) { if (datagridview3.rows[j].cells[1].value != null && (textbox4.text == datagridview3.rows[j].cells[4].value.tostring())) { messagebox.show("item on list!"); datagridview3.rows.remove(datagridview3.rows[n]); return; } else { datagridview3.rows[j].cells[1].value = textbox43.text; datagridview3.rows[j].cells[4].value = textbox4.text; datagridview3.rows[j].cells[2].value = datetime.now.toshortdatestring(); datagridview3.rows[j].cells[3].value = datetimepicker3.text; datagridview3.firstdisplayedscrollingrowindex = n; datagridview3.currentcell = datagridview3.rows[n].cells[0]; datagridview3.rows[n].selected =

mysql: joining 2 tables and compute multiple counts & sort results -

i beginner mysql , have problem can't solve myself. hope guys know how me. i have 2 tables. first table x maps users license plates: user_id | license_id 1 | 1 | b 1 | c 2 | d 2 | e ... the second table y maps license plates insurances: license_id | insurance_id | year | i1 | 2001 | i2 | 2002 | i3 | 2003 | i2 | 2004 b | i2 | 2002 b | i2 | 2003 d | i2 | 2003 d | i2 | 2004 d | i2 | 2005 e | i3 | 2004 ... and want answer following questions in efficient way, because tables rather large: given set of insurances (i1, i2), show me users, registered @ least 1 of them. sort number of matching insurances, count multiple registrations of same user same insurance (because of different license ids) once. further, each user, show me license id, sh

excel - average of corresponding cells for sectioning -

i have excel workbook paired data sets of type [columna=distance:columnb=data] there thousands of data points. what i'm looking this: have sectioning column . want find average of corresponding cells in data column (column b) sectioning. you have couple of simple options: autofilter filter on column a, highlight column b , have @ average value in bottom right corner in excel status bar or create formula =subtotal(1, b:b) somewhere in sheet ignores hidden cells , works autofilter excel table same autofilter, comes built-in total row feature can set display average =averageifs() or similar formula - see e.g.: average of filter of multiple columns in excel , calculating average of specific values

java - Android: GridView resetting position in getView -

i'm populating gridview list of stages, 4. when calling getview(...) 0, 1 , 2 load fine, showing correct position number. however, on position 3 number reset 0, giving me list: 0, 1, 2, 0 . public class examplegrid extends baseadapter{ private context mcontext; public examplegrid(context c){ mcontext = c; } @override public int getcount() { return 20; } @override public object getitem(int pos) { return null; } @override public long getitemid(int pos) { return 0; } @override public view getview(int position, view convertview, viewgroup parent) { final button levelbutton; if (convertview == null) { string positiontext = position + ""; levelbutton = new button(mcontext); levelbutton.settext(mcontext.getresources().getstring(r.string.mm_stage) + positiontext); levelbutton.setlayoutparams(new gridview.layou

python - Django Rest Framework: Permissions based on Object Attributes/Ownership -

i'd allow users create , view resources, if: they staff or they 'owner' of object they're trying create/view i've got read-only permissions worked out fine, since users have permission lists of objects when primary key used generate viewset. example: /api/users/1/notes returns notes user pk=1. however, in testing, discovered users can create object 'owned' user posting own list endpoint. example user 1 can send post /api/users/1/notes, specify note data {user: " http://host.tld/users/2/ ", text: "look! created note in person's account!"} i've got fix below seems work fine, though feeling i'm swimming against current. right now, within custom permission, create instance of object created , check owner user making request. is there cleaner way of doing this? current fix: def has_permission(self, request, view): if request.user.is_staff: return true elif request.method in permissions.safe_m

PHP+MySQL Printing a MySQL array into table -

Image
i have query function (code below) use read db , know how loop print output -all- results table this: i used it: $visa=$db->query("select fname,lname,email users"); echo '<table bordercolor=black>'; ?> <tr> <th>name</th><th>lastname</th><th>e-mail</th> </tr> <?php echo "<td>"; echo $visa[0]['fname']; echo "</td>"; echo "<td>"; echo $visa[0]['lname']; echo "</td>"; echo "<td>"; echo $visa[0]['email']; echo "</td>"; the query function: function query($querytext) { $rs = mysql_query($querytext, $this->_link); if($this->_debug) { $this->adddebugmessage("\t<tr>\n\t\t<td class=\"debug_nr\">".$this->_querycount++."</td>\n\t\t<td class

matlab - Crash Dump 3564 -

i'm using gui , playing sound through psychotoolbox , have error: *matlab crash ...\matlab_crash_dump.3564-1: segmentation violation detected > @ sat may ... configuration: crash decoding : disabled default encoding: windows-1252 matlab root : c:\program files\matlab12a\r2012a matlab version : 7.14.0.739 (r2012a) operating system: microsoft windows xp processor id : x86 family 6 model 23 stepping 10, genuineintel virtual machine : java 1.6.0_17-b04 sun microsystems inc. java hotspot(tm) client vm mixed mode window system : version 5.1 (build 2600: service pack 3) fault count: 1 abnormal termination: segmentation violation register state (from fault): ... stack trace (from fault): if problem reproducible, please submit service request via:* any way avoid error? thanks!

list - Python Dictionary Type -

i'm trying figure out why type error. possible put integers inside of dictionaries? math_questions = [ {'question1':'1*1', 'answer1':1, 'quote1' :'what are,you accident of birth; am,i myself.\n there , thousand princes; there 1 beethoven.'}, {'question2':'2*1', 'answer2':2, 'quote2': 'two company, 3 crowd'}, {'question3': '3*1', 'answer3': 3, 'quote3': 'there 3 types of people, can count , cannot'} ] # read txt file later??? print math_questions[0]['question1'] math_answer = int(raw_input("what answer " + math_questions["question1"] +"? : ")) if math_answer == math_questions['answer1']: print math_questions['quote'] else: print "try again" print math_questions['answer1'] this error message get. ps c:\python27\math_game> python m

eclipse - How can I add an attribute to java annotation to all methods at once -

i working on java project (eclipse ide) , have custom annotation @customannotation. has several attributes. added new attribute part of project-improvement , need add new attribute methods (and classes). there easier way other manually adding attribute java methods? may via eclipse? as example: <code> // current classannotation public @interface customannotation{ boolean enabletest; } // current methodannotation public @interface methodannotation{ boolean enabletest; } //my current class , method @classannotation(enabletest = fasle) classs myclass { @methodanotation(enabletest = false) public void mymethod() {} } //my new classannotation public @interface customannotation{ boolean enabletest; string[] testnames; } // new methodannotation public @interface methodannotation{ boolean enabletest; string[] testnames; } // new class , method looks @classannotation(enabletest = fasle, testnames = { test1, test2}) classs myclass { @methodan

java - What am I doing wrong in this code? It's supposed to run indefinitely, but only loops twice -

i have final string array @ top labeled jokes. program ask if user wants hear joke, tell user joke, , ask if hear another. of right now, program ask if user wants hear joke, tell them joke, ask them if hear another, tell them second joke, , stop. program indefinitely opposed twice. or advice appreciated, i'm still beginner java. random generator = new random(); input = new scanner(system.in); system.out.println("want hear joke?"); string response = "yes"; while (response.equalsignorecase("yes")) { response = input.nextline(); int yourjoke = generator.nextint(jokes.length); system.out.println(jokes[yourjoke]); system.out.println("pretty funny! want hear another?"); response = input.nextline(); } } } you should call input.nextline() once inside of while loop. why ask input before while loop if you're going ignore it, if you're going force respons

Emacs 23 - How to prevent from backtrace buffer to pop-up -

each time scroll top down / top buffer backtrace buffer pops-up , takes half size of window, quit annoying. don't use @ buffer, know how prevent bracktrace pop-up? i grateful. :) lawlist correct; consequence of debug-on-error variable being set. if you're not setting yourself, must third-party library. use m-x rgrep ret debug-on-error ret (or maybe debug-on-error t ) on site-lisp , custom lisp directories, track down library responsible. if happen use nxhtml , it's @ fault (i'm don't think it's been updated anytime recently, , last version saw still had issue in code). in nxhtml-base.el , comment out offending line (or in autostart.el if don't have nxhtml-base.el file).

c++ - embed resource to native exe from c# -

i want embed resource in exe file using c#. if use c++ code works : updateresource(hresource,rt_rcdata,makeintresource(104), makelangid(lang_neutral, sublang_default),(lpvoid)text,filesize); c# code use : intptr handle = beginupdateresource(this.nomefilecryptato, false); intptr fileptr = toptr(encrypted); bool res = updateresource(handle, "rt_rcdata", "104", 1040, fileptr, convert.touint32(encrypted.length)); endupdateresource(handle, false); actualy, c# code embed resource in exe file (let's call a.exe) if embed resource c++, a.exe can read , extract, if embed c#, a.exe cannot. any ideas? this declaration update resource in c# : [dllimport("kernel32.dll", setlasterror = true)] static extern bool updateresource(intptr hupdate, string lptype, string lpname, ushort wlanguage, intptr lpdata, uint cbdata); lptype , lpname both strings , if use updateresource(handle, "rt_rcdata", "104", 1040, fi

linear algebra - MKL dtrsv wrong output -

i trying use 'cblas_dtrsv' not right output , not know why. here example(dtrsv_example.c) #include <stdio.h> #include <stdlib.h> #include "mkl.h" int main() { double *a, *b, *x; int m, n, k, i, j; m = 4, k = 4, n = 4; printf (" allocating memory matrices aligned on 64-byte boundary better \n" " performance \n\n"); = (double *)mkl_malloc( m*k*sizeof( double ), 64 ); b = (double *)mkl_malloc( n*sizeof( double ), 64 ); x = (double *)mkl_malloc( n*sizeof( double ), 64 ); if (a == null || b == null || x == null) { printf( "\n error: can't allocate memory matrices. aborting... \n\n"); mkl_free(a); mkl_free(b); mkl_free(x); return 1; } a[0] = 11; (i = 0; < m; i++) { (j = 0; j <= i; j++) { a[j + i*m] = (double)(j+i*m); } } (i = 0; < n; i++) { x[i] = (i+1)*5.0; } printf ("\n computations completed.\n\n"); printf ("\n resu

jquery - Make single table row red (MVC 5/Bootstrap 3) -

Image
i making delete method index view , first part of confirmation trying make way turn current table row red (just user can see selected right row) here current view looks so when click delete, need way temporarily change row's color red. also: background current content displaying on odd rows, if click item next row appear display additional content, not sure if interfere anything. the way have delete working, without confirmation, follows... (all buttons shown context) view snippet <td class="col-lg-3 col-lg-offset-1"> <span style="visibility:hidden" class="id col-lg-1">@html.displayfor(modelitem => item.id)</span> <span class="item-edit-button"> <button type="button" onclick="editfunction(this)" class=" btn btn-warning col-lg-3 col-lg-offset-0"><span style="margin-right: 5px" class="glyphicon glyphicon-pencil"></span>

Get Custom Property from Dynamic Module in Sitefinity -

how can custom property title module created in module builder? i using method retreive module instance public static dynamiccontent retrievepollquestionbyid(string guidid) { dynamicmodulemanager dynamicmodulemanager = dynamicmodulemanager.getmanager(); type pollquestiontype = typeresolutionservice.resolvetype("telerik.sitefinity.dynamictypes.model.poll.pollquestion"); guid pollquestionid = new guid(guidid); dynamiccontent pollquestionitem = dynamicmodulemanager.getdataitem(pollquestiontype, pollquestionid); return pollquestionitem; i want retreive title property of dynamiccontent. thanks. add using telerik.sitefinity.model; reference , able use , set methods. example pollquestionitem.getvalue("title") , pollquestionitem.setvalue("title", "yourtitle") hope helps!

Execute permission in maven-dependency-plugin during copying and unpacking -

i've got strange behavior using maven-dependency-plugin. when use ' copy ' goal of maven-dependency-plugin , unzip dependency archive manually have -rwx permissions on files. but when ' unpack ' goal, have -rw permissions files dependency.

extracting nodes values with xmlstarlet -

i have xml schema , want how extract values of nodes 1 one, using xmlstarlet , in shell script <service> <imagescroll> <imagename>photo_gallerie_1.jpg</imagename> </imagescroll> <imagescroll> <imagename>photo_gallerie_2.jpg</imagename> </imagescroll> <imagescroll> <imagename>photo_gallerie_3.jpg</imagename> </imagescroll> </service> xmlstarlet sel -t -m "//imagename" -v . -n your.xml output: photo_gallerie_1.jpg photo_gallerie_2.jpg photo_gallerie_3.jpg is needed? sel(sel mode) -t (output template(this pretty required) -m ( for each match of following value) "//(the double slash means anywhere in tree) imagename(name of node want)" -v (requests value of element in current path) , "." represents current element in iteration (you put name of node there it

ZXing android use front camera -

i'm trying build qr code reader following tutorial http://code.tutsplus.com/tutorials/android-sdk-create-a-barcode-reader--mobile-17162 i managed working, except need camera front camera of device instead of rear camera. can't find place in tutorial allows me change this. tried following this answer, still not work. mainly, issue importing library. following error. operator not allowed source level below 1.7 when set compiler settings 1.7, this android requires compiler compliance level 5.0 or 6.0. found '1.7' instead i'm not proficient android , apologize if might not question. so, way me use zxing front camera in app? links? thank much. the source code uses java 7. android not require java <= 6. can see build provided in project happily feeds java 7 bytecode dex , produces working app. not sure tool using suggests otherwise. maybe old. you should not need copy , compile project's code though. why necessary? use core.jar fi

actionscript 3 - How do I enable end-users to run multiple instances of an AIR desktop application? -

i have been told not possible run multiple air instances, unfortunately not until after have incorporated lot of air api's app. i have attempted 'wrap' application in outer app, , instantiate native windows each instance, singleton classes returning same information. there way load windows separate domains getinstance() call returns instance unique particular window only?

javascript - jquery ui datepicker, reverse format date -

i have datepicker displays months , years.. months in literal form (march, april etc). when click on date picker , value in text field "march 2014" datepicker displays current month (june) instead. datepicker cant parse date in literal format. i'm trying reverse parse before datepicker shows.. not working. example: var monthselect = $('#monthselect').datepicker({ changemonth: true, changeyear: true, showbuttonpanel: true, dateformat: 'mm yy', beforeshow: function(){ var months = { 'january' : '01', 'february' : '02', 'march' : '03', 'april' : '04', 'may' : '05', 'june' : '06', 'july' : '07', 'august' : '08', 'september' : '09', 'october' : '10', 'november' : '11', 'december' : '12'}; var thisval = $(this).val().split('

java - Hibernate + JodaTime mapping different types -

i using hibernate reverse engineering , trying timestamps map jodatime type. i have setup hibernate.reveng.xml file properly <sql-type jdbc-type="timestamp" hibernate-type="org.joda.time.contrib.hibernate.persistentdatetime" not-null="true"></sql-type> the issue when run rev-eng process java classes members created persistentdatetime objects, don't want because not usable. need java objects org.joda.time.datetime so tried creating custom engineering strategy public class c3customrevengstrategy extends delegatingreverseengineeringstrategy { public c3customrevengstrategy(reverseengineeringstrategy res) { super(res); } public string columntohibernatetypename(tableidentifier table, string columnname, int sqltype, int length, int precision, int scale, boolean nullable, boolean generatedidentifier) { if(sqltype==types.timestamp) { return "org.joda.time.datetime"; } else { return super.colu

performance - The more organized your code, the more slow your website or programme will run? -

just wondering that, more keep code organized, using mvc, or keeping separate files functions, constants, using external sheets styles, js, etc. more slow website becomes, because value in code has follow longer path, comparatively. true?? it's true in sense page take 0.02 seconds instead of 0.01 seconds process. long-term maintainability of code more important raw performance 99% of time.

arrays - Ruby - Graph adjacency matrix into variable -

i trying edit algorithm found here . i want adjacency matrix loaded file (formatting of file doesn't matter me, can either [0,1,1,0] or 0110 ) g = file.read().split("\n") however, error no implicit conversion of fixnum string (typeerror) , know need convert string ints, how not lose formatting required dfs method? i guess it's pretty easy, i'm begginer in ruby (and graphs :v) , can't work... edit: code i'm using read file array of arrays is: def read_array(file_path) file.foreach(file_path).with_object([]) |line, result| result << line.split.map(&:to_i) end end and result file (for example) 01101010 01010101 01010110 10101011 01011111 is this: => [[[1101010], [1010101], [1010110], [10101011], [1011111]]] what need, however, is: => [[[1,1,0,1,0,1,0], [1,0,1,0,1,0,1], [1,0,1,0,1,1,0], [1,0,1,0,1,0,1,1], [1,0,1,1,1,1,1]]] so work algorithm mentioned in first line of post (i'll copy here, if takes place

html - Space between DIV and Top -

Image
i have space between top of website , top div, have set both have no margins still has space. can tell me doing wrong here? thought setting margins 0 fix apparently not. html <div class="toppanel"> <p>title</p> </div> css .toppanel { background-color:#ffffff; width:100%; height:auto; font-family: copperplate, "copperplate gothic light", fantasy; color:#000000; font-weight:100; font-size:36px; text-align:center; margin: 0; padding: 0; } body { background-color:#e3e3e3; margin: 0; padding: 0; } sample image the issue margin on p tag pushing div down. the possible solutions are: 1) change p style have 0 top margin or 2) add padding-top: 1px div or 3) add border-top div. if p tag has margin, nothing "push off of" within div, entire div move down accomodate margin-top of p tag.

google places api - Invalid API key error when new IP address is added -

we trying add new ip address our api key used google places api. existing ips have associated key work. however, addition or changing ip address our original list of ip addresses causing google places api call fail following error message: { "error_message": "the provided api key invalid.", "html_attributions": [], "results": , "status": "request_denied" } what should doing resolve this? there additional setting/configuration needs done in google places api account? use ** browser api ** key instead of server api key.. had same problem.

unix - bash: assign punctuation to variable -

when assign this: rmall="\,\.\?\!\:\;\(\)\[\]\{\}\"\'" then echo $rmall, got this: \,\.\?\!\:\;\(\)\[\]\{\}\"\' but want , how can do? ,.?!:;()[]{}"' as later need remove those. thank you you double quoting using quotes and backslashes. use 1 or other. note: need use backslash escaping quote character otherwise not needed.

app engine cloud sql backup disabled -

i using google cloud sql , able setup replication , has been running fine month. lately, replication has failed , when check instance saying backups , binary log disabled. when try enable in developer console, doesn't let me enable backups , binary log. form doesn't give me errors when change backup , binary log setting, doesn't change them. the out-of-the-ordinary change think of might have caused changing character set tables utf8 (they in latin1 before). didn't errors that. sorry inconvenience. you unfortunately hit bug. fixing in progress. update thread once fix rolled out.

shell - using gnuplot for drawing multiple graphs -

i have data date instance 1, 2, 3, 4, 5, 6 03-09-2013 0 0 1 0 0 1 03-09-2013 0 0 6 0 0 6 03-09-2013 0 0 2 0 0 6 03-09-2013 0 0 3 0 0 6 03-09-2013 0 0 1 0 0 6 03-09-2013 0 0 2 0 0 6 04-09-2013 0 0 4 0 0 4 04-09-2013 0 0 8 0 0 8 04-09-2013 0 0 2 0 0 8 04-09-2013 0 0 3 0 0 4 04-09-2013 0 0 1 0 0 8 04-09-2013 0 0 5 0 0 8 it sample of huge data. every day there 6 columns, shows 6 difference process instances. i have pick maximum number of instances each day , plot on graph. like on 03 sep process 3 there 6 instances, on 4 sept there 8 instances have pick maximum number of instances each date , plot graph 6 different lines depicting instances each process. problem: writing code in shell script, how maximum number of instances each process each day. there way build data structure , find out. or need use python or perl? if so, please guide. these scripting languages new me. 2) how plot using gnuplot. example 03-09-2013 2 0 2 3 0 7 04-09-2013 6 0 4 2 0 12 05-09-2013 7 0

node.js - How to use aggregation framework to search text with nodejs -

as mentioned in release notes of mongodb 2.6, can text search in aggregation framework. can in shell db.products.aggregate([{ $match: { $text: { $search: 'keyword' } } }]); everything works alright here. want same thing nodejs with: var aggrconditions = [{ $match: { $text: { $search: 'keyword' } } }]; db.collection(product_coll_name).aggregate(aggrconditions, function(err, result) { if (err) throw err; // }); it complains about: exception: invalid operator: $search i'm using node native client 1.4.5. i'm doing wrong?

asp.net c# event handler not working second time -

i have asp.net web page contain panel filled on run time protected void page_load(object sender, eventargs e) { buildstructure(1); } and method public void buildstructure(int level_id) { pmain.controls.clear(); //response.write(@"<script language='javascript'>alert('" + level_id + "');</script>"); datautility du = new datautility(@"****"); datatable dt = du.getdatatable("select * dbo.prstructure_main level_id = "+level_id); int curr_level = 1; int curr_child = 1; int totalchild = 0; if (dt.rows.count > 0) { panel plevel = new panel(); plevel.cssclass = "level"; panel pitem = new panel(); pitem.cssclass = "item-ceo"; label litem = new label(); litem.text = dt.rows[0].itemarray[2].tostring(); pitem.controls.add(litem); plevel.controls.add(pitem); pmain.controls.add(plevel)

Best practice for loading different themes or css files for different users in ASP.NET MVC -

there 2 questions: how routing different customers under same domain e.g. customer url looks like: http://cusa.mydomain.com customer b url looks like: http://cusb.mydomain.com and according different url(the above urls) load different themes. for question 1: know have sub-domain concept talking more : www.mydomain.com/cusa , www.mydomain.com/cusb. don't know whether capable of doing sub-domain in front of mydomain for question 2: if question 1 gets solved, think read , parse url , loading different themes according cusa or cusb part using asp.net mvc theme stuff. could provide thoughts , technologies use in case? thank you. update: tried use "request.applicationpath" doesn't work. here code <h2>site 2 home page</h2> <a href="/home/contact">go contact</a> <label>the application path @request.applicationpath.substring(1)</label> my answer not best practice, rather how have approached

c# - How to stop creating database again in the windows phone when the emulator is closed -

i working on windows phone. problem facing whenever emulator closed database created me destroyed , next time emulator starts again, new database created. what want database should created once , data not erased when re-open emulator. please me. thank you. here code creating database in windows phone public class personaldatacontext : datacontext { public static string dbconnectionstring = "data source=isostore:/personalreminderdatabase.sdf"; public personaldatacontext(string connectionstring) : base(connectionstring) { if (this.databaseexists() == false) { this.createdatabase(); } } when ever closed emulator, application have deployed on emulator gets uninstalled & on restarting emulator gets re-installed, database create doesn't stay on emulator if close , reopen. , there no way can database restarting emulator. best possible way test application on external database or on device. h

html - Refresing an image in jsp without reloading the whole page -

<c:if test="${commandobject.function.functioncode =='elog welcome'}"> <td align="left" width="28"> <img src="assets/images/welcome/kewill_logo_new.jpg" width="100" height="28" alt="logo" position = "center"/> </td> </c:if> i using above condition put image on jsp, image should removed if above condition not satisfied. problem image not removing, remains there when condition not satisfied when jsp loads next time. but once refresh page image goes. want image disappear whenever condition not true without having refresh whole page. how can that? working solution!!! use following line of code : <%timeunit.seconds.sleep(5); %> it reloads page once 5 seconds i.e. provide time delay of 5 seconds on action performed.. used solve similar kind of problem in project..difference removing image , forming image on action of button cl

php - How to load models in Laravel? -

i started studying laravel , ran problem using models. how load them? example in codeigniter used $model = $this->load->model('some_model') . in laravel when call controller sites::ofuser() work fine, when call sites::getid() says method should static... possible call method without static or need create facades each model? my model looks this: namespace models; use eloquent; class sites extends eloquent { public function scopeofuser($query) {} public function getid($name) {} } for static method-- $type = sites ::scopeofuser($query); and if want normal codeingiter use-- $model = new sites (); $type = $model->scopeofuser($query);

.htaccess - Expression Engine Decryption of form settings failed -

i having problem in submitting channel form frontend of website. getting below error the form submitted contained following errors *decryption of form settings failed.* when force query string in website url .everything works fine. please suggest fix this

javascript - Jquery Checkbox custom event does not return stable result -

hi i'm working on custom blogsite have working script here checkbox. checkbox not have attrib checked default because page displays first actual article checkbox labeled "edit" when user clicks on article loaded on textarea(it has tinymce plugin editing purpose) user can edit article.. used check if editing fyi here script: $("#edit").on('change', function(e){ $("#viewmode").toggle(function(){ $.ajax({ type: 'get', url: 'includes/edittyp.php', data: "flag="+0, success: function (status) { } }); }); $("#viewmode").toggleclass('display: none' ); $("#editmode").toggle(function(){ $.ajax({ type: 'get', url: 'includes/edittyp.php', data: "flag="+1, success: function (s

c# - ConfigurationManager is not refreshing the AppSettings after a new execution -

in web application (c# + asp.net) can use new values on config file (install.properties) when try values using "configurationmanager". string pathjava = configurationmanager.appsettings["filepathjava"]; i have got in install.properties <add key="filepathjava" value="c:\program files\java\jre7\bin\java.exe"></add> i rode can refresh values: configurationmanager.refreshsection("appsettings"); i did this: configurationmanager.openmachineconfiguration() but value not change. also tried add new key, configurationmanager returns me null value. you have potential problem... if change value in web.config , while site running, reset web site. modification whatsoever files causes iis reset occur. a solution want, without resetting web site move application settings out of web.config altogether: <?xml version="1.0"?> <configuration> <appsettings configsource="app

caching - Apache - Add Cache-Control header if not already added -

in apache, how can set response header if not set cgi application? i need way automatically add cache-control header static content on website, want cgi application able specify own cache-control header too. setenvif not work purpose because matches request headers. is there way conditionally / optionally set header if not set? 1) configure apache append value of empty string cache-control header ensure included in response. 2) configure apache set cache-control header if it's still set empty string. <filesmatch "\.(css|ico|flv|gif|jpeg|jpg|js|pdf|png|swf)$"> header append cache-control "" header edit cache-control "^[, ]*$" "max-age=1800, public" </filesmatch>

SWIG: Warning 453: Can't apply (char *STRING,size_t LENGTH). No typemaps are defined -

i have small .i file information: %module (directors="1") tu %include "typemaps.i" %include "enums.swg" %header %{ #include <my_header.h> %} %apply (char *string, size_t length) { (char* msg_buf, int buf_len) }; when generating java bindings there no warnings when generating c# bindings this: swig: warning 453: can't apply (char *string,size_t length). no typemaps defined can advise on might problem. .i file identical java , c#.

Share Laravel session with custom PHP -

i have laravel 4 application custom login on example.com , , session driver database . on subdomain example custom.example.com have custom php application should use same user base , share login. also have subdomain l4.example.com laravel 4 application sharing same user base , login, , here can use same session, custom application on custom.example.com when try var_dump($_session); i undefined variable: _session . so there way share laravel 4 session custom php application on subdomain

c# - Load and web performance test in Visual studio, localhost not starting -

i have 1 web project , added new "web performande , load test"- project. when start recordding can't go localhost since not started web project. have missed here? how must cinfigure web load test-project?? my goal here run test locally on machine. i'm running windows 7 home premium , vs ultimate 2013. or work if have web in 1 project, start in debug mode (f5) , create load test in project start after web app , running??

javascript - jQuery Datatables - Table with Subtable or Expandable Rows -

my code works in big data lack of usability... table should work 500-600 rows (updated in every 5 seconds)... therefore want make similar: http://i.stack.imgur.com/npktu.png //buttons added via photoshop. i can't find functionality @jquery. so want group data under 20/25 group header. each ip has 60-70 row. 2 column: ip , fps same each group. this how recent application looks like: http://www11.pic-upload.de/03.06.14/rv6w1tboi1ip.png so main question is: how add expand/collapse functionality group of rows under 1 main table. and main part of js code: //მაგიდის ახლიდან დახატვა function redrawtable(){ "use strict"; $("table#content").datatable({ "destroy" : true, "ajax": "/json", "tabletools": true, "columndefs": [ { "render": function (data) { var labeltype, labeltitle; if (data === 1) { labeltitle =