Posts

Showing posts from August, 2011

ember.js - Build dynamic relationship in ember data -

i have access api endpoints get, cannot suggest or apply modifications. this sample schema of each api: var person = ds.model.extend { firstname: ds.attr(), lastname: ds.attr() } var credit = ds.model.extend { name: ds.attr(), personid: : ds.belongsto('person') } var debit = ds.model.extend { name: ds.attr(), personid: : ds.belongsto('person') } i can api/person, api/credit, api/debit individually. after fetching data. want map relationship between person , credit/debit similar this... var person = ds.model.extend { firstname: ds.attr(), lastname: ds.attr(), **debits: ds.hasmany('debit'),** **credits: ds.hasmany('credit')** } how can accomplish in ember-data? jsbin - http://emberjs.jsbin.com/gewowucamo/8/edit?html,js,output everything you're doing work. when load data using store.push() builds related relationships (if exist). this jsbin gives example of you're doing works. ...

c# - Why does httpWebRequest.GetResponse() timeout when stream is not used? -

i ran strange behavior understand. reading image via httpwebrequest. following code raises timeout exception: httpwebrequest httpwebrequest = (httpwebrequest)httpwebrequest.create(url); httpwebrequest.timeout = 5000; httpwebresponse httpwebreponse = (httpwebresponse)httpwebrequest.getresponse(); stream stream = httpwebreponse.getresponsestream(); please note stream not used anywhere else afterwards. however, if add following line: image image = image.fromstream(stream); also here note image not used anywhere later on. can explain why timeout in first case?

postgresql - How can I do Multiple Queries (build out a DB) in Node.JS? -

really new node.js , relatively new postgresql. reason creates first table, not second. totally doing wrong. can't seem find code examples similar enough extrapolate answer from. want create 2 tables. seems can run 1 query , that's it. no more. it's suggested connection ends before second can executed. don't know why. can't find single example of doing in dozen different google searches. var client = new pg.client(connectionstring); client.connect(); var query = client.query('create table preferences(id serial primary key, food varchar(40) not null, preferred boolean)'); client.query('create table foods(id serial primary key, food varchar(40) not null, type varchar(40) not null, spicy boolean, spiciness varchar(10)'); query.on('end', function() { client.end(); }); i had doubts client.query , have execute @ end. took example out of tutorial second table added. i'm playing , trying learn here test. just state ultimate end goal: w...

Understanding Scope on Javascript -

i'm understanding "scope" found code, im wondering how can execute "inner" function, tried this: outer().inner(); but doesn't works /* global scope */ var local = true; var global = true; function outer() { /* local scope */ var local = true; var global = false; /* nearest scope = outer */ local = !global; console.log("local: "+local); console.log("global: "+global); function inner() { /* nearest scope = outer */ local = false; global = false; /* nearest scope = undefined */ /* defaults defining global */ public = global; } } you change outer object instead of function. /* global scope */ var local = true; var global = true; var outer = { /* local scope */ local : ...

excel - Copy cell J1 from multiple files and paste into column of master file -

i have code take files folder, open 1 each one, print name first column of "master file" close , loop through entire folder way. in each file opened, there information in cell j1 copy , paste column 3 of "master file". section of code returns error ( object not support property or method cannot tell line referring to) , causes program stop after opening 1 file. any ideas? full code: sub loopthroughdirectory() dim objfso object dim objfolder object dim objfile object dim myfolder string dim sht worksheet dim integer myfolder = "c:\users\trembos\documents\tds\progress\" set sht = activesheet 'create instance of filesystemobject set objfso = createobject("scripting.filesystemobject") 'get folder object set objfolder = objfso.getfolder(myfolder) = 1 'loop through directory file , print names each objfile in objfolder.files if lcase(right(objfile.name, 3)) ...

c++ - Cast a polymorphic smart pointer object -

i implemented following smart pointer template class: #ifndef __projectmanager__msharedptr__ #define __projectmanager__msharedptr__ #include <stdio.h> #include "refcount.h" template <class t> class msmartptr { t *data; refcount *rc; public: msmartptr(t* srcptr); msmartptr(const msmartptr&); ~msmartptr(); t* operator->() const; t& operator*() const; msmartptr<t>& operator=( msmartptr&); msmartptr<t> operator()(msmartptr&); }; template<class t> msmartptr<t> msmartptr<t>::operator()(msmartptr<t>& src) { return dynamic_cast<??>(src); } template <class t> msmartptr<t>::msmartptr(t *srcptr): data(srcptr) { rc = new refcount(); rc->add(); } template<class t> msmartptr<t>::~msmartptr() { if (rc->remove() == 0) { delete data; delete rc; } } template<class t> msmartptr<t>::msmar...

Magallanes deployment tool PHP -

i use magallanes deploy projects, , problem have how can catch errors during deployment, example when throw command create database, exist. and other how can return personalized messages tasks, example <?php namespace task; use mage\task\abstracttask; class assignpermissions extends abstracttask { public function getname() { return 'asignando permisos ' . $this->getparameter('permission','') . ' la carpeta ' . $this->getparameter('target',''); } public function run() { $permission = $this->getparameter('permission',''); $target = $this->getparameter('target',''); if($permission == '' , $target == '') { return false; } $result = $this->runcommandremote('chmod ' . $permission . ' ' . $target); return $result; } } if permission parameter empty, r...

Wireshark to decrypt SSL mutual -

is there way decrypt mutual ssl (client & server, 2 ways) ? i found link : https://www.wireshark.org/lists/wireshark-users/201001/msg00147.html but still not able decrypt. not sure client port. finally managed working following tuto: https://jimshaver.net/2015/02/11/decrypting-tls-browser-traffic-with-wireshark-the-easy-way/

java - How to return double[] in jni input argument -

in java code have defined following function signature: public native boolean getdata( double [] data ); in c++ code i'd populate double array data return java, , returned boolean function indicate whether data set correctly or not. javah created following c++ function signature: jniexport jboolean jnicall java_com_test_getdata___3d( jnienv* penv, jclass cls, jdoublearray darray ) how implement function in c++ can return 3 double values generated in c++ code? i'd similar article: http://www.javaworld.com/article/2077554/learn-java/java-tip-54--returning-data-in-reference-arguments-via-jni.html instead of using stringbuffer, i'd fill in array of doubles values. it should follows: jniexport jboolean jnicall java_com_test_getdata___3d( jnienv* penv, jclass cls, jdoublearray darray ) { jboolean iscopy1; jdouble* srcarrayelems = penv->getdoublearrayelements(darray, &iscopy1); jint n = penv->getarraylength(darray); ...

c# - adding object to a dictionary get a different value than expected -

i have strange behavior, working on 5 days , cant seems find problem yet. don't know whether it's stupid mistakes or i'm using bad approach such things happened. assumed list problem i'm not sure. i'm using list of class named item models of json. think there's no problem on list of item, because have checked of item on list , , has same value on json. my approach using list accessed key on every item, i'm using dictionary. but strange goes this : item added dictionary goes looped (adding same key , value) after item number 30, when checked using breakpoints, var item in items has right value expected . when added dictionary , item added it(dictionary) not item in local variable foreach statement added before this model json class item { public string key { get; set; } public string description { get; set; } public string question { get; set; } public double cf { get; set; } } here code has strange behavior c...

How to grab every class from specified namespace c#? -

so have read few ver similar questions, answers not giving me result. my code list<type> thelist = assembly.getexecutingassembly().gettypes().tolist().where(t => t.namespace == "foo.test").tolist(); and not return anything, though there multiple classes inside namespace. there 3 static classes inside foo.test testone, testtwo, , testthree; none returned in little 1 liner got stack overflow thread. how grab these 3 static classes given namespace foo.test? program namespace foo.program, both our namespaces close, , have using foo.test in program includes. you're running both case sensitivity , incomplete namespace name issues. might better off using case insensitive search coupled indexof() current culture. list<type> thelist = assembly.getexecutingassembly().gettypes().where(t => culture.compareinfo.indexof(t.namespace, "foo.test", compareoptions.ignorecase)) .tolist(); alternatively, if namespace correct, can ...

c# - How do I return a new object from a mocked repository using a LINQ Expression? -

i using rhino mocks , have created mock repository. var salesforcepolicies = mockrepository.generatemock<irepository<salesforcepolicy>>(); i have private method return policy item repository. private salesforcepolicy getsalesforcepolicybyclientid(decimal clientid) { var policy = salesforcepolicies.findbyexp(x => x.idnumber == clientid).firstordefault(); if (policy == null) throw new accountupdaterexception("policy not found in sales force lookup table."); return policy; } i trying repository return new object 1 property set when query called in private method. not want break encapsulation , set public virtual . the compiler screaming when write this... var clientid = decimal.parse("123456"); salesforcepolicies.stub(x => x.findbyexp(y => y.idnumber == clientid)).return(new salesforcepolicy { policynumber = "123456" }); how can mocked repository return new object when queried? error: best overloaded meth...

ios - Tableview reload with setNeedsDisplay not working -

i have tableview in view lists steps executed. want show step marked when step executed. problem facing tableview not refresh until procedure executed steps. consequently steps show marked @ same time. this function starts running when user presses button: -(void)initialiseer { //do first step [self.mytableview reloaddata]; [self.myview setneedsdisplay]; //do second step [self.mytableview reloaddata]; [self.myview setneedsdisplay]; //do third step [self.mytableview reloaddata]; [self.myview setneedsdisplay]; } myview view iboutlet. mytableview tableview iboutlet. tried [self.view setneedsdisplay] , [self. mytableview setneedsdisplay] not work either. tried getting cell tableview , making changes on cell itself. nothing refreshed until procedure finished executing completely... can tell me doing wrong? new ios development , searched, read, tried... did not find answer far. i think need read on run loop , setneedsdisplay (which ...

ruby on rails - human attribute name in a partial for a form_for -

i have shared partial i'm using in various form_for tags so: <%= render 'shared/text_field_attribute', :f => f, :attribute => :some_attr, :predicate => 'is/starts with/ends with/etc.' %> app/views/shared/text_field_attribute.html.erb looks this: <div class="form-group"> <%= f.label attribute, "#{attribute} #{predicate}", class: 'sr-only' %> <%= f.text_field attribute, class: 'form-control', placeholder: "#{f.object.class.human_attribute_name(attribute)} #{predicate}…" %> </div> is there more concise human attribute name? f.object.class.human_attribute_name(attribute) instead of: f.object.class.human_attribute_name(attribute) you can use humanize method so: attribute.to_s.humanize

Node-steam-trade, how to get items names? -

i'm making steambot, take items users , need name of items , it's price send on site. how should name of each item in items array? have alreay know items[i].appid assetid , others, how can name , average price? steam.on('tradeoffers', function(number) { if (number > 0) { offers.getoffers({ get_received_offers: 1, active_only: 1, time_historical_cutoff: math.round(date.now() / 1000) }, function(error, body) { if(body.response.trade_offers_received) { body.response.trade_offers_received.foreach(function(offer) { if (offer.trade_offer_state == 2) { console.log(offer); console.log('recieved trade offer: ' + offer.tradeofferid); var exception = false; var items = offer.items_to_receive; for(var i=0; i< items.length;i++) { if(items[i].appid != "730") { exception = true; ...

ios - Problems with Auto Layout with collision -

i'm trying use size classes in new storyboard auto layout , cannot seem make constraints work properly. have game uses ton of collision , without autolayout scales on iphone 5. when change iphone 4 or iphone 6 or other layout, storyboard gets cut off on side. tried fix using autolayout, when select it, ruins collision. brings object in storyboard , applies collision. on top of that, seems there no clearcut way resize autolayout/size classes (unless i'm missing somewhere). there tutorial on working constraints in xcode 6 collision isn't reset/ruined , scales ios devices? if turn on autolayout unable move view (by manipulating frame) has constraint applied it. assigning new cgrect uiview won't move object if object has x,y constraint set. you'll instead need create iboutlets each constraint want move or resize. create outlets yourviewconstraintx; yourviewconstrainty; and can update them self.yourviewconstraintx.constant = 20;

jquery - JavaScript Adblocker detection - jsonip doesn't show -

im running script see if using adblocker. script: <script type="application/javascript" src="http://jsonip.appspot.com/?callback=getip"></script> <p><a style="text-decoration: none;">&copy; example.com</a></p> <br> <div class="tester" style="display:none"><a href="http://www.namecheap.com?aff=87222"><img src="http://files.namecheap.com/graphics/linkus/728x90-1.gif" height="90" width="728" border="0" alt="namecheap"></a></div> <script> if (document.getelementbyid("tester") == undefined) { document.write('<p><a style="text-decoration: none;">#ban '); function getip(json){ document.write(json.ip); }; document.write('</a></p>'); } </script> it shows text #ban , whitespace of course, doesnt ip. doing wrong? ...

javascript - Disable past dates and enable only certain future dates in datepicker -

i attempting use jquery datepicker, wish disable past days , allow future thursdays. can allow thursdays, mindate functionality add doesn't work it. code: <script> jquery(document).ready(function() { jquery('#input_40_4').datepicker({ beforeshowday: function(date) { return [date.getday() == 4, ""];} }); }); $(function () { $("#input_40_4'").datepicker({ mindate: 0 }); }); </script> can explain why these don't work together? you can add more options datepicker separating them commas. $(document).ready(function() { $('#input_40_4').datepicker({ beforeshowday: function(date) { return [date.getday() == 4, ""];}, mindate : 0 // can add more options here well, seperate them commas }); }); the reason why didn't work in question because overwrite options datepicker created in function on line 10 options datepicker in documentready section. you...

git - Where i can find user login and password on visual studio online page? -

i try find username (and password) of project on [visualstudioonline.com] so, try push repo project,but cannot find login @ least. what login? microsoft live id? or else? thank you! p.s. i have git string commit project this: git remote add origin username.visualstudio.com/defaultcollection/_project.git so, type git command line- , ask username: username@gmail.com , password... when type microsoft account password (from login)- have failed 1 go project https://projectname.visualstudio.com/defaultcollection/projectname/ . click on name in right upper corner , select edit profile. pop appear . in pop can see general, local, ecredentials, connections 4 tabs . click under credentials . , select enable alternate credentials , save . hope helps .

r - How to use trained caret object to predict on new data (not used while training)? -

i using caret package train random forest model on training dataset. have used 10-fold cross validation object randomforestfit . use object predict on new data set test_data . want respective class probabilities. how that? i have been using extractprob function follows : extractprob(randomforestfit, textx = test_data_predictors, testy = test_data_labels) but it's giving me unexpected results. from extractprob page example, need wrap model in list: knnfit <- train(species ~ ., data = iris, method = "knn", trcontrol = traincontrol(method = "cv")) rdafit <- train(species ~ ., data = iris, method = "rda", trcontrol = traincontrol(method = "cv")) predict(knnfit) predict(knnfit, type = "prob") bothmodels <- list(knn = knnfit, tree = rdafit) predict(bothmodels) extractprediction(bothmodels, testx = iris[1:10, -5]) extractprob(bothmodels, testx = iris...

postgresql - Rails records not displayed when grouped -

Image
i have book model sake of question has 5 fields (id, title, issue, release_date, print_run). i'm trying populate sales table grouped title here's have in controller: @books = book.all.where("release_date > ?", "2012-05-01").where("print_run > ?", "1").group(:title) and in view here's part of table: <% @books.each |title| %> <tr> <td><%= title.title %></td> <td class="text-center"> <% if title.print_run > 1 && title.release_date.between?((date.today - 12.month).beginning_of_month, (date.today - 12.month).end_of_month) %> <%= title.print_run %> <% else %> 0 <% end %> </td> </tr> <% end %> each book has 1 issue per month have table set 14 columns (title, 1 each month, , total). display print_run of each title month, when use group(:title) in controller, displays print run last month (but rest 0). if remove group(:titl...

Find the lowest location within rows where there are non-zero elements for each column in a matrix in MATLAB -

for example, have 4x6 matrix a: a = 0 0 0 0 4 3 0 2 1 0 0 0 0 5 0 8 7 0 8 9 10 3 0 2 i want find lowest location within rows of non-zero elements found each column. should go this: column 1 => row 4 column 2 => row 2 column 3 => row 2 column 4 => row 3 column 5 => row 1 column 6 => row 1 and result should following vector: result = [4, 2, 2, 3, 1, 1] anyone has idea how obtain this? this should it: a = [0, 0, 0, 0, 4, 3; 0, 2, 1, 0, 0, 0; 0, 5, 0, 8, 7, 0; 8, 9, 10, 3, 0, 2]; indices = repmat((1:size(a))', [1, size(a, 2)]); indices(a == 0) = nan; min(indices, [], 1) here indices is: indices = 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 3 4 4 4 4 4 4 we set every element of indices nan wherever zero, gives us: indices = nan nan nan nan 1 1 nan 2 2 nan n...

html - How to keep nav bar from shifting elements to next line when zooming in? -

edit: solved jirikuchta ! added white-space: nowrap; #navigation in css. read on more information on problem fixed. hope can else out there! i've seen question hundred times on internet on past few days trying fix problem, absolutely nothing has worked me. when zoom @ in google chrome, nav bar shifts last link next line, ruining whole layout. i'm new html first real roadblock i've run into, , i'm absolutely stumped. i've followed advice on countless other websites, adding min-width , max-width, wrappers, positions, switched em , %, nothing has worked. i'm assuming problem when zoom, things round , make things big space provided, don't know how counter problem. in advance , help! html: <!doctype html> <html> <head> <meta charset="utf-8"> <title>about</title> <link rel="shortcut icon" type="image/x-icon" href="layoutimages/favicon.png"> <link href='http://fonts....

html - Adding footer to image in C# -

i using getusermedia api capture image , draw canvas. using todataurl() of canvas "imageurl". url saved png image local file. looking before saving image add comment image @ bottom of image(not on image) footer. have below code. can 1 suggest me how in c#. imagebyte= convert.frombase64string(imageurl); using (var streambitmap = new memorystream(imagebyte)) { using (var img = image.fromstream(streambitmap)) { img.save(localpath); } } you can create new bitmap higher original image fit footer below. next copy original image , footer bitmap , save new bitmap. the method (assuming footer width <= image width): public bitmap appendimagefooter(system.drawing.image bmp, system.drawing.image footer) { //create new image bigger original image make place footer bitmap newimage = new bitmap(bmp.height+footer.height,bmp.width); //get graphics new image , copy original ima...

r - add segments to barchart (discrete x-axis) in ggplot2 -

Image
i trying draw segments on each bar of barchart ggplot2 . know how continuous x-axis, not discrete axis. did kind of "hack" making-up line text. it looks nice in picture, don't legend "limit" metal concentration and, of all, length of segment changes every time zoom in or out. does know geometry implement better? df = data.frame('metal'=c("cu", "fr", "zn"), 'observed'=c(550, 60, 100), 'limit'=c(200, 150, 120)) ggplot(data=df) + aes(x=metal) + geom_bar(aes(y=observed), stat="identity", fill="grey") + geom_text(aes(y=limit, label="_____________"), size=rel(6), color="red") edit: the question close this one adapted this answer ggplot(data=df) + aes(x=metal) + geom_bar(aes(y=observed), stat="identity", fill="grey") + geom_errorbar(aes(y=limit,ymin=limit,ymax=limit,colour="limit"))

node.js - How exactly does eval work with nodejs? -

let's do: eval( db_config = { host: 'localhost', user: 'root', database: 'forum', password: 'test' } ); var gamefunctions = require('gamefunctions.js'); i can use db_config anywhere inside gamefunctions.js without having pass through parameter. that's pretty neat. but, bad practice? reason ask because if do: var db_config = { host: 'localhost', user: 'root', database: 'forum', password: 'test' } var gamefunctions = require('gamefunctions.js'); db_config becomes undefined anytime use in gamefunctions.js . , have pass through parameter on each different function seems evaling first save time , code, downside this? does eval define variables in gl...

Which paypal service should I use -

in web application (spring mvc + jsp), have implement payment process take money of (i.e buyer), deposit else (i.e seller), , keep portion myself (i.e commission). process perform on website instead of redirecting paypal. have tried search service need, after while of reading it, confused. thinking may need mix between adaptive payment or website payment pro. however, think paypal provide service searching for, haven't found yet. mind me out of confusion please? in order payment split part of checkout need use adaptive payments, pay api chained payment. unfortunately, can't avoid redirecting user paypal method. if that's must, you'll need go payments pro, can't split within single checkout, , can't split fees among receivers. you'll end paying fee when receive money, , when send money there fee there, too. also, if go route responsible chargebacks occur, not recommended.

Spring 4.1.6 and Hibernate 3.2.2? -

we migrated spring 3.x spring 4.1.6. spring 4 , above recommends hibernate 4 or hibernate 3.6.10. plan continue using hibernate 3.2.2 there several breaking changes b/w hibernate 3.2.2 , 3.6.10 , plan address later. far faced 1 issue spring 4 using exception classes missing in hibernate 3.2.2. able fix easily. does have pointers other issues face combination ? or pointers how figure out specific features of hibernate 3.6 spring 4 using thats missing in hibernate 3.2.2 ? you may take @ spring's official migration guide : the org.springframework.orm.hibernate3 package phasing out of spring framework 4.2. keep supporting time being; however, recommend upgrade hibernate 4.2/4.3 or 5.0. as of spring framework 4.0.1, provide hibernatetemplate variant in org.springframework.orm.hibernate4 ease migration common hibernate 3.x data access code, in particular if motivation upgrade lack of bug fixes in hibernate 3.x line. note newly written code recommende...

Parsing icinga conf files in python -

i'm trying write wrapper icinga2 instance. objets inside config files this; object object_type "object_name" { some_property = "some_value" } example; object host "server1" { import "generic-host" address = "192.168.0.1" vars.os = "linux" } object host "server2" { import "generic-host" address = "192.168.0.2" vars.os = "linux" } i'm looking like: icinga = icinga("/etc/icinga2/conf.d/hosts.conf") print icinga.hosts_list() icinga.hosts_add("server3","192.168.0.3") icinga.hosts_remove("server1") so tried using pynag, like; nc = config('/etc/icinga2/conf.d/hosts.conf') nc.parse() print nc.get_host('server1') but i'm getting; file "./icinga.py", line 51, in <module> print nc.get_host('server1') file "/library/python/2.7/site-packages/pynag/parsers/__ini...

ios - Parse.com user search without regex -

i have app have users user name , spot real name. allow users query find other users. query looks this: pfquery *userquery = [pfuser query]; [userquery wherekey:kcpusername containsstring:[searchtext lowercasestring]]; pfquery *userrealnamequery = [pfuser query]; [usernamequery wherekey:kcpuserfullname containsstring: searchtext]; pfquery *userrealnamewithcapsquery = [pfuser query]; [userrealnamewithcapsquery wherekey:kcpuserfullname containsstring:[searchtext capitalizedstring]]; pfquery *userrealnamewithlowerquery = [pfuser query]; [userrealnamewithlowerquery wherekey:kcpuserfullname containsstring:[searchtext lowercasestring]]; pfquery *finalquery = [pfquery orquerywithsubqueries:@[userquery, userrealnamequery, userrealnamewithcapsquery, userrealnamewithlowerquery]]; this works great, returning list of users match searchtext . however, i've become aware containsstring uses regex, if have many users searching @ same time run 80 regex queries / min limitation in par...

c++ - OpenCv 2.4.11 - picture won't display -

i have been trying load , display picture opencv 2.4.11 (debug) in vs 2013. problem picture won't display , can't figure out. displayed empty window filled gray colour. tryed display plenty of images, changing attributes picture loading etc. , looking same problem online. here's code: static mat read_sample(const string& samplepath, int &label, char separator = ';') { mat sample; //sample = imread(samplepath, 1); sample = imread("c:/users/honzik/desktop/kotel.jpg", cv_load_image_color); waitkey(0); label = 777; if (sample.empty()) { cout << "error loading sample!" << endl; exit(1); } //namedwindow("mywindow", cv_window_autosize); imshow("mywindow", sample); //mat graysample; //cvtcolor(sample, graysample, cv_bgr2gray); //imshow("gray sample", graysample); mat resizedsample; resize(sample, resizedsample, size(92,...

java - SWT redraw shell -

the problem pretty obvious, want after press button (or label in case) layout change , update. tried several solution suggested none worked me. change in createloginlayout() inside 'login' mouse track listener. know code looks overcomplicated, because use windowbuilder protected shell mainshell; private text hangmanpic; private text cluefield; private composite alphabetcomposite; private display display; private label currguess; private gamemanager gamemanager; private label cluetitle; private text usrfield; private label passtitle; private text passfield; private label login; private label register; public static void main(string[] args) { try { main window = new main(); window.open(); } catch (exception e) { e.printstacktrace(); } } /** * open window. */ public void open() { display = display.getdefault(); createcontents(); mainshell.open(); mainshell.layout(); while (!mainshell.isdisposed()) { if (!dis...

sql - Joining and Repeating Rows -

i have requirement repeat rows values in other tables. ex: order table order 1 2 3 4 5 6 dept table dept person p1 p2 b p3 b p4 b p5 c p6 c p7 c p8 c p9 output expected dept person order p1 1 p2 2 p1 3 p2 4 p1 5 p2 6 b p3 1 b p4 2 b p5 3 b p3 4 b p4 5 b p5 6 c p6 1 c p7 2 c p8 3 c p9 4 c p6 5 c p7 6 any ideas on how this? kept order simplicity need not in sequence; assume of date or varchar! here's 1 way it: select dept, person, [order] (select dept, person, row_number() on (partition dept order person) rn, count(*) on (partition dept) cnt dept ) t cross join [order] rn = ([order] - 1) % cnt + 1 order dept, [order], person this sort of brute force solution: every single combination between order , dept tables , use window functions selectively filter rows out of cartesian set. demo here...

css - IE 8 with bootstrap media queries -

please see http://emailforusa.com/karmanew/ the bottom portion appearing 1 below instead of 3 column. i conditionally using html5shiv.min.js , respond.min.js not figure out why. also tried google's http://html5shiv.googlecode.com/svn/trunk/html5.js , https://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js problem not solved. any ?

regex - extracting chunk of string that matches regular expression using sed in unix -

suppose have bunch of urls , each url contains unique identifier. looks 'abc1000002'. has same leading string, 'abc', , number digits different. the identifier occurs in various positions in urls, http://www.examle.com?abc1000002 http://www.example.com?abc1000002=blahblah#3fdslfkj i can write regular expression like, 'abc[0-9][0-9][0-9][0-9][0-9][0-9]..[0-9], how write sed command extract chunk matches regular expression? grep better tool job: s='http://www.example.com/?abc1000002=blahblah#3fdslfkj' grep -eo 'abc[0-9]+' <<< "$s" abc1000002

mysql - count number of hierarchical childrens in sql -

i have table stores parent , left child , right child information. how count number of children belongs parent? example table structure is: parent left right -------------------- 1 2 3 3 4 5 4 8 9 5 10 11 2 6 7 9 12 null how count number of sub nodes parent. for example 4 contains following hierarchical child nodes - 8,9,12 number of children 3. 3 contains following sub nodes -> 4,5,10,11,8,9,12 total number of children 7. how achieve using sql query? create table mytable ( parent int not null, cleft int null, cright int null ) insert mytable (parent,cleft,cright) values (1,2,3); insert mytable (parent,cleft,cright) values (2,6,7); insert mytable (parent,cleft,cright) values (3,4,5); insert mytable (parent,cleft,cright) values (4,8,9); insert mytable (parent,cleft,cright) values (5,10,11); insert mytable (parent,cleft,cright) values (6,null,null); insert mytable (parent,cleft,crig...

angularjs - Append new element after element clicked with html template -

i have ng-click function appends new <tr> 1 clicked function expandtransactiondetail($event) { var row = angular.element($event.currenttarget); row.after('<tr><td>holla!</td></tr>'); } this html test. html become more complex. derive html template file. need make use of $compile feature in angularjs? nginclude ? what really want create directive in can have own template , scope , more fun stuff: var myapp = angular.module('myapp', []); myapp.directive('mydirective', function() { return { restrict: 'e', scope: { data: '=mydata' }, link: function(scope, elem, attrs) { elem.on('click', function() { elem.append(scope.data); }); } }; }); myapp.controller('myctrl', function($scope) {}); <script src="https://ajax.googleapis.com/ajax/libs/angularjs...

arrays - why does the code below cause excel to crash? -

intro , issue: loop through columns of activesheet, if there's title ask user proceed in redimensioning array, , changing value. it keeps crashing excel after commenting out part array filled. please give me notices , opinions on issue. about code: this seed of vba script rearrange column different sheets depending on values in array created, each column found in activesheet represents correct order of columns saved in array , used fix order of columns in specific sheet. i should mention there not many rows in activesheet arrays 100-200 elements long of text can long 10 letters. sub deletecolumns() dim polyarr(), pointarr(), linearr(), autotitle string dim crnttitle variant dim crntrow, crntclmn, lastrow, lastclmn long set wizard = activesheet wizard lastclmn = .cells(1, .columns.count).end(xltoleft).column lastrow = .range("a" & .rows.count).end(xlup).row crntc...

javascript - How do I remove the time from a feed published date -

i have created rss feed using google feed api , need remove 'published time' published date , show 'date'. i have piece of code. function rssfeedsetup() { var feedpointer = new google.feeds.feed(feedurl) //google feed api method feedpointer.setnumentries(feedlimit) //google feed api method feedpointer.load(displayfeed) //google feed api method } function displayfeed(result) { if (!result.error) { var thefeeds = result.feed.entries (var = 0; < thefeeds.length; i++) rssoutput += "<li><a href='" + thefeeds[i].link + "'>" + thefeeds[i].publisheddate + "</a></li>" rssoutput += "</ul>" feedcontainer.innerhtml = rssoutput } else alert("error fetching feeds!") } window.onload = function () { rssfeedsetup() } can this? you can create date in javascript publisheddate string , extract year ...

How to clear cell when enter invalid data in Excel using VBA -

i have excel sheet in accepting value user when user enter value vba run check data valid or not , if data not valid prompt message saying invalid data. here code: private sub worksheet_change(byval target range) if target.address = "$d$12" or target.address = "$d$13" or target.address = "$d$14" or target.address = "$d$15" call room end if end sub room method sub room() dim lastrow long if isnumeric(range("i17")) if [i17] < 0 msgbox "msg " end if end if end sub in i17 cell have formula =c6-(d12+(2*d13) + (2*d14) + (3*d15)) my problem when wrong data enter in of cells (d12, d13, d14, d15) cell should clear automatically after showing prompt message. how can done? the first thing should clean how check target is. multiple cells (fill down, paste range, ...). accomplished intersecting target range interested in, , we'll store range variable, later. if there no overlap, intersect retur...

arcgis - dijit/form/select to select search fields in Arc JS API -

i'm brand new javascript, dojo , html , i've searched everywhere examples of , cannot find any. i have map feature points , find task highlight feature points on map, , display them in grid it's field attributes. works great when specify search field as: findparams.searchfields = ["location"]; but if add: findparams.searchfields = ["location", "model_num"]; the grid displays results multiple fields (ie. searching attributes in location "a" find attributes in model_num containing letter "a"). decided add drop down menu select specify field search in (one @ time) results more precise. so added following dijit: <select id="fieldselect" data-dojo-type="dijit/form/select" name="fieldselect"> <option value="" selected="selected">select field</option> <option value="model_num">model number</option> ...

iframe - HTML Auto Height Adjust -

beginner here , use little help. need have html document auto adjust height of page given. here have written far. <marquee height="900px" width="791px" style="border:none" behavior="scroll" direction="up" scrollamount="3"> <iframe src="http://www.icclos.net/signage/signageroomscheduleformatted.htm" style="border:none" height="2400" width="791" scrolling="no" border="no"/> </marquee> please advise on how can improve , correct. information appreciated. you can set height of marquee 100% rather fixed number. should automatically adjust height of screen.

ExtJS Grid column with dataIndex from referenced model -

i have extjs gridanel viewmodel store bound it. model of store defined model field references model. for sake of simplicity here's example: ext.define('user', { extend: 'ext.data.model', fields: ['name'] }); ext.define('order', { extend: 'ext.data.model', fields: ['date', { name: 'user', reference: 'user' }] }); viewmodel: { store: { order: { model: 'order', } } } in gridpanel have 2 columns. in 1 column, dataindex: 'date' works correctly, displaying date. however, in second column want display name of user. have no idea how that. user field on object declaring dataindex: user doesn't work. tried dataindex: {user.name} doesn't work either. tried bind: { data: '{user.name}' } also no avail. have found solution using renderer config of column ugly , beats point of having model reference if h...

Django-cms plugin mptt filtering by node to display new subtree, based on config -

i trying implement plugin django-cms shows tree of of links. want filter tree based on config user chooses in cms. based on node chooses in config want able display sub-tree. here models.py from django.db import models mptt.models import mpttmodel, treeforeignkey cms.models.pluginmodel import cmsplugin class section(mpttmodel): name = models.charfield(max_length=25, unique=true) parent = treeforeignkey('self', null=true, blank=true, related_name='children', db_index=true) class mpttmeta: order_insertion_by = ['name'] def __str__(self): return self.name class sectionconfig(cmsplugin): root_shown = models.foreignkey("section") title = models.charfield(default="usefull links", max_length=25) here cms_plugins.py: from cms.plugin_base import cmspluginbase cms.plugin_pool import plugin_pool cms.models.pluginmodel import cmsplugin django.utils.translation import ugettext_lazy _ links_plugin.mo...

c++11 - msvc++ doesn't see overloaded operator<< -

i'm porting piece of code written linux , compiled gcc v4.8.2 (using -std=c++11) windows. part of overloaded operator<< msvc++ 2013 doesn't agree with. condensed example below. we've defined custom stream class supports standard stream manipulator functions. reason we've overloaded operator<< accepts function pointer second argument. if define templated overload of operator<< . msvc++ complains: error c2676: binary '<<' : 'foobar' not define operator or conversion type acceptable predefined operator but if specify type of second argument std::ostream instead of templated std::basis_ostream<..,..> code works expected. at first thought had messed template arguments. however, if define arbitrary template function instead of overload of operator<< code compiles fine. what's going on here? example #include "stdafx.h" #include <iostream> #include <sstream> #incl...

javascript - How to make jQuery script refresh itself? -

explanation: ajax load content div "content" without refreshing page. if div "content" longer 300px - hide "soc_menu_l". script runs absolutely ok on page's refresh: if try update div's height without refreshing page - nothing happens. check heights of div in mozilla's inspector - height changed, script not react it. how can make script "watch" height continuously , infinitely? $(function () { if ($('#content').height() > 300) { $('.soc_menu_l').hide(); } }); or maybe should call script each time after "content"-div loaded? option 1 add event listener: $('#change1').click(function() { $('#content').css({"height":"600px"}); $(window).fireevent('change1'); }); $(window).addeventlistener('change1', function() { if($('#content').height() > 300){ $('.soc_menu_l').hide(); } });

angularjs - Nested Grid Example - Different Columns -

i using latest version of ui-grid ui-grid.info . what best way handle nested grids possibility of nested child grid having different columns parent row. expandable grids best approach. have not tried more 1 level work pretty well. http://ui-grid.info/docs/#/tutorial/216_expandable_grid

c# - Refactoring a concrete method in abstract class which contains an abstract method -

considering below code, abstract class abstractclass { public abstract void abstractmethoda(); public void concretemethoda() { //some operation concretemethodb(); } } public void concretemethodb() { //huge code unrelated class abstractmethoda(); } } class derivedclass : abstractclass { public void abstractmethoda() { //some operation } } now wish move concretemethodb() separate class , make call method concretemethoda() in abstract class. since concretemethodb() uses abstract method abstractmethoda() implemented in derivedclass, unable access method abstractmethoda() new class? idea on how resolve this? why don't make this static class helper { public static void concretemethodb(abstractclass caller) { //huge code unrelated class caller.abstractmethoda(); } } and in abstractclass abstract class abstractclass { public abstract void abstractmethoda(); public void concretemethoda() { //some operation helper.concretemethodb(...