Posts

Showing posts from February, 2012

jscript - "Unspecified Error" 80004005 when creating new Access database, only on another workstation -

what have jscript file gets called cscript , , script proof-of-concept creates new access 2007 format database, imports set of vba modules database, , runs subroutine imported modules. this script works flawlessly on own computer. have office 2013 installed. however, brought script on coworker's machine , had him attempt running it. on machine, error looked like, createdb.js (22, 1): unspecified error , error code 80004005. code, below: 'use strict'; /** * acnewdatabaseformat enumeration * used newcurrentdatabase method specify database format of newly created database. */ var acmodule = 5, dbtext = 10, acnewdatabaseformat = { userdefault: 0, access2000: 9, access2002: 10, access12: 12 }; var fs = new activexobject('scripting.filesystemobject'); var access = new activexobject('access.application'); var basepath = fs.getparentfoldername(wscript.scriptfullname); var db, prop, vcsfolder, fcur, module; /...

javascript - Slide out element to right, then back in from left -

consider following piece of html: <div id="outer"> <div id="inner"> <p id="content"> content </p> </div> </div> i can make #inner slide out right screen using following jquery: $("#slide").animate( { 'marginleft':'100%' },400, function(){ $(this).slideup('fast'); $(this).css("margin-right","100%"); $(this).css("margin-left","0"); } ); however, how can make same element, new content (from ajax response), slide in from left? i thinking resetting margins (from margin-left:100% margin-left:0; margin-right:100% ) while out of view , use animation slide in left: $("#slide").animate( { 'marginright':'0' ...

c# - How to incrementally iterate through all possible values of a byte array of size n? -

for question n=16, generic answer appreciated too. so have byte array: byte[] key; my problem want iterate through possible values of each element in array, combined. know take ages, , i'm not looking complete loop, make loop @ least attempt this. so e.g.: first iteration: //math.pow(2,128) max no. of iterations right? byte[] key; for(int = 0; < math.pow(2,128); i++) { key = new byte[16] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; } second iteration: //math.pow(2,128) max no. of iterations right? byte[] key; for(int = 0; < math.pow(2,128); i++) { key = new byte[16] {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; } third iteration: //math.pow(2,128) max no. of iterations right? byte[] key; for(int = 0; < math.pow(2,128); i++) { key = new byte[16] {2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; } final iteration: //math.pow(2,128) max no. of iterations right? byte[] key; for(int = 0; < math.pow(2,128); i++) { key = new byt...

html - A href links not clickable or highlightable -

i'm not sure why href links aren't working...at 1 point in time working, did research on z-index doesn't seem problem, nor have overlapping div. please visit jsfiddle.net demo . <nav class="navbar-default"> <div class="util-bar-content"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"><img src="images/util-bar-logo.png" /></a> </div> <div ...

bash - Using git as part of an automated script - pausing the script for a rebase -

i'm using git part of script automating file patch. goes this: cd "$gitdir" git checkout original monodis "$original_dll" > "$ilfname" git add "$ilfname" git commit -m "$(date +"%s")" git checkout modded git rebase original # more code here as can guess - disassembles .net dll , applies few patches way of git. but happens if there's merge conflict? there way "pause" script until rebase completed? you split script in two, first part calling second 1 upon conflict-less rebase. in case of manual intervention needed operator call second part after completing merge.

ruby on rails - Customising Devise registration edit/update routes and views -

i've started using devise , i've made customisations: i've generated views , customised views (signup form etc) i've generated controllers can make changes there i've customised routes, per post: http://iampedantic.com/post/41170460234/fully-customizing-devise-routes everything works great except edit_user_registration stuff (the view users can change email , password or delete account). this have registrations in config/routes.rb (parts not related registrations controller omitted): devise_for :users, skip: [:registrations] :user # joining '/register' => 'users/registrations#new', as: 'new_user_registration' post '/register' => 'users/registrations#create', as: 'user_registration' scope '/user' # settings & cancellation '/cancel' => 'users/registrations#cancel', as: 'cancel_user_registration' '/settings' => 'users/regi...

ajax - Pass coordinates parameters to geoserver pgrouting service from Leaflet wms tile layer -

i've configurated pgrouting service in geoserver, following steps on documentation it's easy accomplish. reading documentation, existing examples, etc.. i've come undestand how call must made javascript code: var mylayer = l.tilelayer.wms("http://192.168.0.34:8080/geoserver/pgroutingtest/wms", { layers: 'pgroutingtest:pgroutingtest', format: 'image/png', transparent: true, version: '1.0.0', tiled:true }); map.addlayer(mylayer); the call ok, no errors returned, no image added map. my doubt is, how can pass origin , destination coordinates(x1,y1,x2,y2) parameters pgrouting service in order calculate route? in example pgrouting documentation give us, done follow: var viewparams = [ 'x1:' + startcoord[0], 'y1:' + startcoord[1], 'x2:' + destcoord[0], 'y2:' + destcoord[1] ]; params.viewparams = viewparams.join(...

r - Plotting multiple graphs in one page using loop -

i trying plot multiple graphs on same page. works fine when write code 1 one this: old.par <- par(mfrow = c(3,4)) plot(na.omit(aus.yield), xlab = "date", ylab = "log_return", main = "aus.yield") plot(na.omit(bra.yield), xlab = "date", ylab = "log_return", main = "bra.yield") plot(na.omit(can.yield), xlab = "date", ylab = "log_return", main = "can.yield") plot(na.omit(chi.yield), xlab = "date", ylab = "log_return", main = "chi.yield") plot(na.omit(ger.yield), xlab = "date", ylab = "log_return", main = "ger.yield") plot(na.omit(jap.yield), xlab = "date", ylab = "log_return", main = "jap.yield") plot(na.omit(soa.yield), xlab = "date", ylab = "log_return", main = "soa.yield") plot(na.omit(swi.yield), xlab = "date", ylab = "log_return", main = "swi.yi...

ember.js - Set parent controller property from child controller -

i have flyers route has template called flyers.hbs <div class="button-wrap"> <button {{action 'back'}}>go back</button> {{#if isprintable}} <button {{action 'print'}} class="float-right">print flyer</button> {{/if}} </div> {{outlet}} in flyers route have view , new . new should show button , view should show button , print button. in view controller specified property so. import ember 'ember'; export default ember.controller.extend({ isprintable: true, }); but parent controller flyers not see property when navigate view route print button not showing. what proper way this? as understand you'd have {{isprintable}} in flyers template value dependent of active child route. may looks you. //flyers controller import ember 'ember'; export default ember.controller.extend({ isprintable: true, }); //child route import ember 'ember'...

asp.net mvc - MVC5 Login to custom Database -

what if have own database , bal (business access layer) , don't want use defaultconnection , template aspnet database tables own user tables? how can use custom database? connectionstring: public class appdbcontext : identitydbcontext<appuser> { public appdbcontext() : base("defaultconnection") { } } web.config <add name="defaultconnection" connectionstring="data source=(localdb)\v11.0; attachdbfilename=|datadirectory|\nakedidentity-mvc.mdf; initial catalog=nakedidentity-mvc;integrated security=true" providername="system.data.sqlclient" /> you can customize tables, storage , classes. process not straightforward little bit of work can that. i've answered similar question few days ago. can find here . you can find project on github i've tried customize tables involved in authentication/authorization pro...

php - PHPExcel - .xlsx file downloads unreadable content -

i trying export data spread sheet , working fine in localhost , when uploaded server , downloads files unreadable content . writing code here. there php_xml, php_zip , gd installed in server. file downloaded readonly. error_reporting(e_all); ini_set('display_errors', true); ini_set('display_startup_errors', true); date_default_timezone_set('europe/london'); if (php_sapi == 'cli') die('this example should run web browser'); /** include phpexcel */ require_once dirname(__file__) . '/lib/phpexcel.php'; // create new phpexcel object $objphpexcel = new phpexcel(); // set document properties $objphpexcel->getproperties()->setcreator("test") ->setlastmodifiedby("test") ->settitle("test report") ->setsubject("test report") ->s...

I pass data from database in array form, then I want to show this array in php -

Image
how use $objects in function? pass data database in array form, want show array in php page, it's printing word "array". i want print in format--> [ ['trident','internet explorer 4.0','win 95+','4','x'], ['trident','internet explorer 5.0','win 95+','5','c'], ['trident','internet explorer 5.5','win 95+','5.5','a'] ] code: function showing_daily_basket(){ $connect_mysql= @mysql_connect($server,$username,$passwor) or die ("connection failed!"); $mysql_db=mysql_select_db("gp15",$connect_mysql) or die ("could not connect database"); $query = "select * basket_daily_work"; $result=mysql_query($query) or die("query failed : ".mysql_error()); $objects= array(); while($rows=mysql_fetch_array($result)) { $objects[]= $rows; } exit($ob...

Multiple antMatchers in Spring security -

i work on content management system, has 5 antmatchers following: http.authorizerequests() .antmatchers("/", "/*.html").permitall() .antmatchers("/user/**").hasrole("user") .antmatchers("/admin/**").hasrole("admin") .antmatchers("/admin/login").permitall() .antmatchers("/user/login").permitall() .anyrequest().authenticated() .and() .csrf().disable(); which suppose mean visitors can see site @ root path (/*), , users can see (/user), admin can see (/admin), , there 2 login pages 1 users , admin. the code seems work fine, except admin section - doesn't work return access denied exception. i believe problem in order of rules: .antmatchers("/admin/**").hasrole("admin") .antmatchers("/admin/login").permitall() the order of rules matters , more specific rules should go first. starts /admin ...

c# - What does ToolStripProfessionalRenderer.OnRenderItemBackground do? -

i writing custom toolstripprofessionalrenderer component , working through of onrender... overrides. this 1 in particular has stumped me: onrenderitembackground i can't see drawing anything, force draw i've done this: protected override void onrenderitembackground(toolstripitemrendereventargs e) { e.graphics.fillrectangle(brushes.red, e.item.contentrectangle); } ...but don't see red rectangles, not sure it's doing!? all stock toolstripitems can add designer render own background. draw onrenderitembackground() override over-painted again. professionaltoolstriprender doesn't override method since nothing needs done. base class method, toolstriprender.onrenderitembackground(), doesn't either. note onrenderbuttonbackground(), onrenderdropdownbuttonbackground(), onrenderlabelbackground(), etcetera.

php - echoing webpage title from the defined list -

i got way display custom page titles using include fuction. header: <title><?php echo $pagetitle ?></title> include: <?php $pagetitle = "pets:"; include '../header.php'; ?> so handle titles easier i'd name come predefined list: <?php define('animal', 'dog'); ?> how add 'animal' $pagetitle = "pets:"? to answer question: <?php $pagetitle = "pets:"; define("animal", "dog"); $pagetitle .= animal; echo $pagetitle; // yields "pets:dog"; ?> but fair, arrays, not constants in case. something this: <?php $pagetitle = "pets:"; $animals = array('dog', 'cat', 'bird', 'super cow'); echo $pagetitle . $animals[0]; // yields "pets:dog"; ?>

java - how to use BlockingQueues -

i having problem blockingqueues. size of queue comes 1 first loop , 0 after there there. variables 'as' null. public class board extends jpanel { private myclass mc; private thread combatthread; final blockingqueue<myclass> queue = new linkedblockingqueue<myclass>(); public board() { mc = new myclass(); mc.add(1); mc.add(2); combatthread = new thread(new cthread(queue)); test(); } public void test() { try { queue.add(mc); } catch(exception e1) {} combatthread.start(); } public class cthread implements runnable { private myclass as; public cthread(blockingqueue queue) { } public void run() { while( true ){ try { = queue.poll(); //as null } catch (exception e) {} } } } } in constructor public board() you create 1 ...

sql - Connect by clause output not coming as desired -

i have following query against emp table select empno,mgr,ename,level emp start ename = 'king' connect prior empno = mgr; desired output should show ename of manager , without using self join. add alias in clause , use nested correlated subquery in select clause. select empno,mgr,ename,level, (select ename emp empno=e.mgr) mgrname emp e start ename = 'king' connect prior empno = mgr;

c# - Assigning Roles in AspNetUserRoles table made by Identity -

i don't understand how work identity thing, below tried best, don't have errors doing nothing , wonder why. checked this: adding role dynamically in new vs 2013 identity usermanager add user role asp.net identity table in database modified have: id (auto-increment, primary key), roleid, userid - both default , without primary key. protected void createuserwizard1_createduser(object sender, eventargs e) { // default userstore constructor uses default connection string named: defaultconnection var userstore = new userstore<identityuser>(); var rolestore = new rolestore<identityrole>(); var manager = new usermanager<identityuser>(userstore); var rolemanager = new rolemanager<identityrole>(rolestore); var user = new identityuser { username = createuserwizard1.username }; var role = new identityrole { id = radiobuttonlist1.selectedvalue}; //create new user , try store in db...

c# - How to Start Windows Service As Administrator Privileges -

i have own application server windows service communicates sql server, in cases sql server service stop stating via code servicecontroller sc = new servicecontroller("mssql$sqlexpress"); sc.start(); sc.waitforstatus(servicecontrollerstatus.running); but requires administrator privileges start service how can start window service administrator i add tag in app.manifest file <requestedexecutionlevel level="requireadministrator" uiaccess="false" /> works ...

javascript - Webpack: Create a bundle with each file in directory -

i trying bundle every angular module in webpack. target have 1 app.js bundled webpack configuration: entry: { app: "./app/app.js" }, output: { path: "./build/clientbin", filename: "bundle.js" }, i place bundle script in index.html entry point of app. have many modules in ./app/components folder. folder structure in like: app |--components | | | |--home | | | | | |--home.html | | |--home.js |--app.js |--appcontroller.js i have required home.html in home.js when load home.js of needed files load. problem have several components home , want tell webpack bundle each component separately , name containing folder home . how can config webpack create these bundles , put them in ./build/components ? a simpler way: use globs in webpack.config.js : here's example: var glob = require("glob"); module.exports = { entry: { js: glob.sync("./app/components/**/*.js"), } } ...

java - Printing backslashes issue -

this question has answer here: what backslash character (\\)? 6 answers i'm facing problem code system.out.println("\\---------------------//"); it not print this \\---------------------// but this \---------------------// \ has escaped. therefore, print 2 \ need : system.out.println("\\\\---------------------//");

javascript - QtQuick2 - QML reusable item focus changes when selecting/clicking outside/inside of root item -

Image
how can implement focus changing state reusable qml component when clicked or selected item outside component body call event (highlight text, show/hide rectangle , etc). there code trying implement highlight line under checkbox text when item have focus, , hide when focus lost. please me understand more effective way implement it. here source of element: breezequickcheckbox.qml import qtquick 2.4 item { id: root property breezequickpalette palette: breezequickpalette property bool checked: false property string caption: "checkbox" property int fontsize: 18 implicitheight: 48 implicitwidth: bodytext.width + 48 rectangle{ id: body width: 32 height: 32 anchors { verticalcenter: parent.verticalcenter left: parent.left leftmargin: 8 rightmargin: 8 } radius: 2 border{ width: 1 color: palette.icongrey } ...

c# - Edit two models -

in event controllers edit parameter of event model on user model. the value in controllers corrects. value of event model save in event model have among other things : public guid? userid { get; set; } public virtual user user_ss { get; set; } [httppost] [validateantiforgerytoken] public actionresult achat( event @event) { if (modelstate.isvalid) { db.entry(@event).state = entitystate.unchanged; @event.nbpartid = @event.nbpartid - @event.nbformid; var c = (@event.budget * (@event.nbformid)); var userprofiluser = (from s in db.users s.personemail.contains(user.identity.name) select s).tolist(); db.entry(db.users.find(userprofiluser[0].userid)).state = entitystate.unchanged; var p = (userprofiluser[0].wallet) - c; db.entry(db.users.find(userprofiluser[0].userid)).state = entitystate.modified; ...

Using query with variables in c# and mysql -

i need following set of statements executed , gives fatal error need query output of following query uses 2 variables database mysql , language c# trying use in c# code using myreader=new mysqlcommand(this query ,connection object).executereader() set @lastitem := 0, @lastvalue := 0; select concat ( date (t5.inventorydate) ,t5.skuoritem ) pk, t5.customerid, t5.entityid, t5.inventorydate, t5.skuoritem, t5.category, t5.inventory ( select '3' customerid, '90' entityid, t1.inventorydate inventorydate, t1.iditem skuoritem, t4.categoryinventary category, ifnull(t1.itemqty,0) sales, ifnull(t2.buyqty,0) stockmove, @lastvalue := if( @lastitem = t1.iditem, @lastvalue + ifnull(t2.buyqty,0) - ifnull(t1.itemqty,0), ifnull(t2.buyqty,0) - ifnull(t1.itemqty,0) ) inventory, @lastitem := t1.iditem ( select date(date) inventorydate, iditem, sum(quantity) itemqty subway.saleitem group iditem, date(date) ) t1 left outer join ( select date(date) inv...

javascript - Chart.js. Values in a big range. The smallest values are not available -

i use chart.js ( http://www.chartjs.org ) show traffic usage different units using bar chart. if have big range of usage (1 unit 2.5gb, 2 unit 2.5mb, 3 unit 2.5kb, 4 unit 0b) smallest values not available (i cannot hover on or click on them) when bring them 1 value, gb (2.5,0.0024,2.38e-6,...,0) or mb (2560,2.5,0.0024,...,0). please ideas how display them on 1 chart maintain proportions , ability click , hover on over each bar (even 0) thanks in advance ability click , hover on over each bar unfortunately, bars don't have pointhitdetectionradius equivalent. can override inrange function chart.rectangle give little more vertical detection range. chart.rectangle.prototype.inrange = function (chartx, charty) { return (chartx >= this.x - this.width / 2 && chartx <= this.x + this.width / 2) && (charty >= this.y && charty <= (this.base + 5)); }; i've extended vertical area 5 units downward x axis, change above axis (jus...

doctrine2 - Add annotation with bundled entity in Symfony -

i have entities in symfony bundle has own field configuration in bundle. for example: fosuserbundle . now, want add more configuration through annotation or xml. for example: want apply serialization parameters or assert validation or gedmo parameters. how can achieve without rewriting whole entity?

How to select JSF components using jQuery? -

i trying implement jquery primefaces , jsf components, it's not working properly. when tried same html tags it;s working properly. here code html tags works jquery: <input type="checkbox" id="check2"></input> <h:outputtext value="check box, if permanent address same current address."></h:outputtext> <h:message for="checkbox" style="color:red" /> with $("#check2").change(function() { if ($("#check2").is(":checked")) { $("#p2").hide(); } else { $("#p2").show(); } }); here code primefaces/jsf doesn't work jquery: <p:selectmanycheckbox > <f:selectitem itemlabel="1" value="one" id="rad" ></f:selectitem> </p:selectmanycheckbox> with $("#rad").change(function() { if ($("#rad:checked").val() == "one") { $("...

symfony - Include a method when object is serialized in JMS -

i have method returns value: /** * @orm\table() * @orm\entity(repositoryclass="personrepository") */ class person { /** * @var integer * * @orm\column(name="id", type="integer") * @orm\id * @orm\generatedvalue(strategy="auto") */ private $id; public function getfoo(){ return $this->id + 1; } //setters & getters } i include value getfoo() returns when serialize person object this: { 'id' : 25 'foo' : 26 } you need set @virtualproperty , @serializedname . use jms\serializer\annotation\virtualproperty; use jms\serializer\annotation\serializedname; class person { .... .... .... /** * @virtualproperty * @serializedname("foo") */ public function getfoo(){ return $this->id + 1; } .... .... .... } you can read more here: http://jmsyst.com/libs/serializer/master/reference/annotations ...

ssl - How to set up a meteor server on https connection? -

i have local meteor server running on port 3000.then want add ssl certificate project.i have generate ssl files, should next? deploy app using meteor up have built in ssl support . or use common web server nginx or apache, setup ssl , reverse proxy meteor app. example: nginx configuration server { listen 80; server_name www.example.com; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 443 ssl ; server_name www.example.com; ssl on; ssl_certificate /etc/nginx/ssl/ssl.crt; ssl_certificate_key /etc/nginx/ssl/ssl.key; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header upgrade $http_upgrade; proxy_set_header connection 'upgrade'; proxy_set_header x-forwarded-for $remote_addr; } }

Why are my meteor settings not being passed to the application? -

set meteor_settings={"public": {"stage": "development"}} meteor then line: console.log(meteor.settings.public.stage); causes error: w20150612-20:45:38.338(-7)? (stderr) typeerror: cannot read property 'stage' of undefined what doing wrong? from understand environment variable deployment mode (running bundle). in development, i.e., when running meteor , need use --settings command line parameter specify file containing settings.

c# - No overload for '...' matches delegate 'System.Windows.Forms.ItemCheckEventHandler' -

after reading this question, has become apparent me writing event incorrectly. however, have no idea how going able re-write have written using object sender. event adds text selected checkboxes two-dimensional list ( report ), , order in report must same order of selected checkboxes. also, no more 2 checkboxes can selected @ time. here event: void checkedlistbox_itemcheck(checkedlistbox chkdlstbx, itemcheckeventargs e) { int index = convert.toint32(chkdlstbx.tag); if ((chkdlstbx.checkeditems.count == 0) && (e.currentvalue == checkstate.unchecked)) { var.report[index].add(chkdlstbx.text); } if ((chkdlstbx.checkeditems.count == 1) && (e.currentvalue == checkstate.checked)) { var.report[index].removeat(0); } if ((chkdlstbx.checkeditems.count == 1) && (e.currentvalue == checkstate.unchecked)) { if (chkdlstbx.selectedindex < chkdlstbx.checkedin...

DKIM, Gmail and emails sent from both code and outlook -

i have business email address: orders@mybusiness.com. i use send order confirmation emails thru variety of different systems, 1 of .net web app sends emails thru aws ses. there 2 other systems send out emails automatically using same email address via smtp.gmail.com. i use email address locally outlook manually send emails, , allow people reply directly order notification emails. i notice aws ses emails come gmail little tag - 'sent via amazonses'. more or less understand why there , how rid of setting dkim stuff. what don't understand how adding dkim record thru aws effects local setup outlook , smtp.gmail.com. create multiple dkim records? 1 thru aws ses, , 1 thru gmail? dkim keys have notion of 'selector'. selector identifier particular dkim key domain used sign message. allows multiple dkim keys defined domain, , hence allows multiple independent senders sign messages using dkim. the corresponding dkim key record in dns can found at ...

c# - basic graph data structure -

i trying write simple text-based game in unity player must navigate bed 'let's say, 'a'' exit, 'g' moving across 'nodes' directly attached. here's example of information trying elegantly capture: a directly connected b, c, , d b directly connected , c c directly connected , b d directly connected , e e directly connected f , g f directly connected nothing (let's say, game over?) g directly connected e so need able following: 1) store bank of nodes 2) store connections between nodes may one-way 3) track current position 4) (icing on cake) alter these connections things happen in-game any implementation can create off top of head not scale to, let's say, 1000 nodes. how should tackle problem? there variety of graph data structures may take at. suggest have @ informative discussions efficient graph data structure in thread: https://softwareengineering.stackexchange.com/questions/148313/what-is-the-most-space-efficien...

java - Why is my JFrame window doing that?(check description) -

i'm programming cookie clicker game remake , when scale jframe window, white appears. disappears hover cursor on button(when refreshes) , need fix that, because same when launch game. here's screenshot(unscaled | scaled): http://s3.postimg.org/xomifomhf/bandicam_19.png this whole code of game: package cookieclicker.tominocz; import java.awt.borderlayout; import java.awt.color; import java.awt.dimension; import java.awt.gridbagconstraints; import java.awt.gridbaglayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.io.bufferedreader; import java.io.bufferedwriter; import java.io.file; import java.io.filereader; import java.io.filewriter; import java.io.ioexception; import javax.swing.borderfactory; import javax.swing.icon; import javax.swing.imageicon; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jpanel; public class main { public static int num1; static icon ic...

Google Spreadsheet a column mirrors a different columns values when it shouldnt be -

Image
ive been working on spreadsheet examine something. converting recursive formula linear one. initial value or first state 60. second state 240. done taking previous state, doubling it, , adding 120. leads 3rd , 4th states of 600 , 1320. base formula clear enough (60+120)*2^(n-1)-120 accurately expresses it. my second part comes needing add in ability decrease costs while still staying true state. last formula works when cost reduction 0. after considerable effort (i kept having minor rounding errors) arrived @ (round(60-60*0.015*b$2)+(120-round(120*rounddown(b$2/3)*0.03,0)))*2^($a2-1)-(120-round(120*rounddown(b$2/3)*0.03,0)) . to test formulas created table following values, a2=1 a5=4, , b2=0 h2=6. using google spreadsheets examine information. when populate table found values correct formula, except on g. on g values identical f. try , correct have deleted information cells, deleted columns, , tried again in new spreadsheet. in cases g=f when should not. cant figure out why i...

Which function for finding if a string is in an array (VBA) is better? -

i have 2 functions check see if string exists in array. don't know better , if there reasons use 1 on other. appreciated. thank :) function 1 function isinarray(stringtobefound string, arr variant) boolean isinarray = (ubound(filter(arr, stringtobefound)) > -1) end function function 2 function isinarray(myarray variant, val string) boolean dim integer, found boolean found = false if not len(join(myarray)) > 0 found = false else = 0 ubound(myarray) if myarray(i) = val found = true end if next end if isinarray = found end function this do. for each thing in arr if instr(thing, stringtobefound) > 0 msgbox thing next your second function uses lot of memory big array. this happens when join strings. don't know if join function uses stringbuilding or not. doubt nothing else in basic does. ordinary concatination shuffles lot of bytes around memory. strin...

git - Pulling with GitHub? -

this question has answer here: how resolve git saying “commit changes or stash them before can merge”? 4 answers the remote repository newer version local repository, , have made changes local repository. how merge two? when try "git pull origin master", gives me "commit changes or stash them" error. is there anyway merge easily? you have few options: if you're done local changes, go ahead , commit them. then, when git pull origin master , git merge remote changes local ones, or ask merge manually if cannot. if you're not quite done you're working on locally, can git stash , "stashes" changes away temporarily. once that, can git pull origin master , reapply changes using git stash pop . again, if there merge conflicts, need handle them yourself. if you're ok tossing out local changes, git checkout . , pul...

python - Issue with sending nested json objects to sqlite db -

i have large file of json objects 1 object per line. send data sqlite database. each json object formatted this: {"1": {"google": 5}, "2": "", "3": 0.0, "4": [10.0, 20.0, 30.0, 20.0], "6": "", "7": 2, "8": {}, "9": 1.0, "10": 0.0} i tried code , got following error: query = "insert daily values (?,?,?,?,?,?,?,?,?,?)" columns = ['1', '2', '3', '4', '5', '6','7', '8', '9', '10'] open(json_file) f: head = islice(f, 5) x in head: line = json.loads(x) keys = tuple(line[c] c in columns) c.execute(query, keys) interfaceerror: error binding parameter 0 - unsupported type. two questions: 1) why getting error? assume has the first hey's value being nested dict, i'm not sure how fix it. 2) created ta...

django - How do I look in a list of items, find the user and see if it exists in a different table and change the template as a result? -

i have simple follow/following setup running. when user (request.user) see's object likes, can click follow button , follow user. when returns want button on object not enabled cause following user. what happening in background, follower/followee record being made. object in question has id of followee. can't figure out how add representation object_list. in rest add field serializer , take care of it. evaluate truthiness of new field. any ideas on how accomplish this? you should separate query , make test in template. view: def objects_list(request): ... return render(request, "the_template_path.html", { 'objects': objectname.objects.all()[0:100], 'followed_object_ids': objectname.objects.filter(follower=request.user).values_list('id', flat=true) }) template: {% object in objects %} {% if object.id in followed_object_ids %} ... {% else %} ... {% endif %} {% end...

matlab - sparse representation for image prediction -

i m working on project have implemented dictionary omp algorithm cant understand how implement on lena image.i providing code on here. %function [x_pr pp]=ompmod_pred2(d1,a1,sl,errorgoal) %____________________________________________________ %prediction using (aurelie method) % d1=dictionary; %a1=image block of size (16x16); %sl=sparsity label %x_pr=predicted block s=8; %d=first 3:4 of d1 d=d1(1:3*s^2,:); %d2=last 1:4 of d1 d2=d1(3*s^2+1:4*s^2,:); %x_ac=block predicted x_ac=a1(9:16,9:16); %x1=reshape a1 column y1=im2col(a1,[s,s],'distinct'); x1=im2col(y1,[s^2,4],'distinct'); %x=first 3:4 of x1 x=x1(1:3*s^2,1); %x2=last 1:4 of x1 x2=x1(3*s^2+1:4*s^2,1); %___________________________________ %a2=calculation of solution vector @ %diffrent sparsity label using omp %___________________________________ [n,p]=size(x); [n,k]=size(d); e2 = errorgoal^2*n; s1=1:s1 maxnumcoef = s1; a2(:,1)= zeros(size(d,2),size(x,2)); errorres = x; % new entry k=1:1:p, x=x(:,k); r...

ruby - how to examine contents of database during or after rails integration test -

i'm experienced dev i'm total web , rails newbie. i'm trying implement kind of market place rails application. i've developed app i'm far along in customer interaction flow , i'm realizing need automate stuff cause dev/test via browser consumes time. say have customer interaction flow goes page a, page b, c, d...g. , i'm developing 'h' page. know use automated test facilities (e.g. minitest) automate whole thing. being how still have rails training wheels on see database state progress 1 state next myself rather trust test automation doing i'm expecting. my question is, there way have minitest automate/simulate user interaction flow -> g , let me take on in manual way there such click newly-developed browser button while using db browser watch db state progress appropriately? if not - i'm guessing - i'd happily settle way examine database contents after integration test. integration tests work fine. it's after complete i...

ios - CLLocation Manager how to update after certain distance -

i using cllocationmanager didupdatelocations so: func locationmanager(manager: cllocationmanager!, didupdatelocations locations: [anyobject]!) { location = locations.last as? cllocation nsnotificationcenter.defaultcenter().postnotificationname("location", object: self) } this working fine want post notification if location distance away original location. can use locations.first and compare locations.last seems update original not if user continues moving around city. to calculate distance need 2 cllocation (let's say, newlocation , oldlocation ). can calculate distance between 2 locations using: let distance = double(newlocation.distancefromlocation(oldlocation)) after add logic decide when post notification: if distance > myminimum distance{ nsnotificationcenter.defaultcenter().postnotificationname("location", object: self) } note , shortest distance calculated between points (straight line) not calculate route d...

Share value from database in all view in laravel 5 -

i'm new laravel. i'm trying create simple app variable shouold in every view. create setting model, many fields , unique slug field. share variable database i've created middleware: public function handle($request, closure $next) { $site_settings = cache::remember('settings', 60, function() { return setting::all(); }); view()->share('site_settings', $site_settings); return $next($request); } now show variable in view have: {{{ $site_settings->get(0)->value }}} this works great, i'd have more intuitive code in view, accessing setting slug. like: {{{ $site_settings->findbyslug("myvariable")->value }}} so it's possible filter collection unique slug? info: this assumes settings table structure following: ---------------------- | id | key | value | ---------------------- | 1 | title | foo | | 2 | asd | bar | | 3 | qqq | zzz | ---------------------- steps st...

filepicker.io - jQuery 'this' in callback -

i have filepicker.io dialog coming fine on success call seem lose 'this' context. so code var fileprocess ={ savefileinfo: function () { .....process info here }, selectfile: function () { filepicker.pick({ mimetype: 'image/*' }, function (blob) { this.savefileinfo(); }); } } so there "context: this" can in ajax call? try creating new variable named self or me set current value of this outside callback. then, use closures, can access this callback through me or self . like: this.mesg = "hello"; var self = this; function handler() { alert(self.mesg); } later after context switch... handler(); // alert 'hello' edit: oh nuts... realized won't work... try: function handler() { alert(this.msg); } var newhandler = handler.bind(this); later... newhandler(); function.prototype.bind() takes object, , returns function. whenever returned function called, object passed...

string - Algorithm to add implied parentheses in boolean expression -

i have string such "a , b or not c , d". atoms simple uppercase letters a,b,c... , operators { and, or, not }. devise algorithm can add parentheses implied usual rules of precedence. can think of simple way this? perhaps using regex? the desired output "(a , b) or ((not c) , d)". it can simple (python code ahead): def popnext(stream, token): if stream[0:len(token)] == list(token): del stream[0:len(token)] return true return false def parse_binary(stream, operator, nextfn): es = [nextfn(stream)] while popnext(stream, operator): es.append(nextfn(stream)) return '(' + ' {} '.format(operator).join(es) + ')' if len(es) > 1 else es[0] def parse_ors(stream): return parse_binary(stream, 'or', parse_ands) def parse_ands(stream): return parse_binary(stream, 'and', parse_unary) def parse_unary(stream): if popnext(stream, 'not'): return ...