Posts

Showing posts from January, 2010

c# - Passing Two Optional parameter to RedirectToRoute -

i passing 2 nullable parameters products action. forced pass value in mallid , otherwise no route table matches found error. want pass null in mallid , receive in products action. return redirecttoroute("products", new { mallid =(int32?)null, storeid =(int32?)storeproducts.storeid }); [route("mall/{mallid?}/store/{storeid?}/products", name = "products")] public actionresult products(string mallid, long? storeid) { return view(products); } attribute routing cracking head great too. [route("mall/{mallid?}/store/{storeid?}/products", name = "products")] public actionresult products(string mallid = null, long? storeid) { return view(products); } and don't pass in value mallid

windows - Possible to Kill Processes using WMI Python -

i know possible create process on remote windows machine using wmi module wish know if same can said ending process. havent been able find thread or documentation please if can me appreciated. i'm not sure using wmi module can use pskill exit processes on remote machine

hash - Derive key and IV from string for AES encryption in CryptoJS and PHP -

how can generate key , iv each common string, may serve in encryption algorithm using aes in php? example: $key_string = derivate_in_valid_key("i love stackoverflow"); $iv_string = derivate__in_valid_iv("i love questions"); and in way can repeat derivation process in javascript also. you can use pbkdf2 derive key , iv password. cryptojs , php both provide implementations thereof. aes supports key sizes of 128, 192 , 256 bits, , block size of 128-bit. iv must same size block size modes such cbc. single invocation of pbkdf2 generate key the following code works generate iv. doing so, requires second random salt must sent alongside ciphertext. javascript ( demo ): var password = "test"; var iterations = 500; var keysize = 256; var salt = cryptojs.lib.wordarray.random(128/8); console.log(salt.tostring(cryptojs.enc.base64)); var output = cryptojs.pbkdf2(password, salt, { keysize: keysize/32, iterations: iterations });

c# - IInvokeProvider.Invoke in NUnit Test -

i have wpf user control writing unit tests using nunit. 1 of tests displays control on window , clicks button on control. after looks confirm correct result received. using raisedevents looks , works correctly. mybutton.raiseevent(buttonargs); assert.areequal(expected, actual); i trying same thing using automation framework. like: buttonautomationpeer peer = new buttonautomationpeer(mybutton); iinvokeprovider invokeprov = (iinvokeprovider)(peer.getpattern(patterninterface.invoke)); invokeprov.invoke(); assert.areequal(expected, actual); now in case assert fails (as expected) because invoke called asynchronously , has not yet occurred @ time of assertion. i hoping resolve calling invoke on separate thread , waiting complete. thread thread = new thread(invokeprov.invoke); thread.start(); thread.join(); however still fails. sleeping: invokeprov.invoke(); thread.sleep(1000); showing dialog , forcing user continue, work. invokeprov.invoke(); system.windows.mess

ios - Initial app load tab bar tint blinking -

when ios application starts tab bar icons have default tint (light blue). setup own custom tint color in viewdidload . applies delay , see transition between default tint color , custom tint color. how can apply custom tint color tab bar before interface appear , eliminate color blinking? override func viewwillappear(animated: bool) { super.viewwillappear(animated) // set tint here after view has been loaded }

c# - ASP.NET MVC Pass Multiple Models to View From Controller -

i need have view displays employee first , last name , employees associated supervisor first , last name. i have 2 models follow: public class employee { public int employeeid { get; set; } public string firstname { get; set; } public string lastname { get; set; } public string department { get; set; } public int supervisorid { get; set; } public virtual icollection<supervisor> supervisor { get; set; } } public class supervisor { public int supervisorid { get; set; } public string firstname { get; set; } public string lastname { get; set; } public string phone { get; set; } public string email { get; set; } public string department { get; set; } public virtual employee employee { get; set; } } to display needed data have created model: public class employeesupervisor { public int employeeid { get; set; } public string firstname { get; set; } public string lastname { get; set; } public string depa

javascript - flot chart get data from span using jquery -

i'm using php create span contains data flot chart. want data using jquery using var somevar= $('span#someid').text(); it takes data span, chart not being drawn. know data correct if copy span , assign var directly in javascript, chart comes straight away here's copy of data (it's stored this <span id="someid">[["19.00","0.04833"],["18.45","0.04717"],["18.35","0.04833"],["18.20","0.04686"],["18.10","0.04718"],["18.00","0.04937"],["17.50","0.04674"],["17.35","0.04804"],["17.20","0.04810"],["17.10","0.04723"],["17.00","0.04989"],["16.45","0.05519"],["16.35","0.08635"],["16.20","0.04742"],["16.10","0.04712"],["16.00","0.04861"]

Update a Google fusion table from a Google Spreadsheet -

i have able update google fusion table google spreadsheet. this ( https://gist.github.com/chrislkeller/3013360 ) obsolete. there new google fusion tables api, when i've looked @ official examples connecting google oauth 2.0, ( https://developers.google.com/fusiontables/docs/samples/python ), involves working around oauth. there has easier way of doing this, @ least sort of google oauth built google apps scripts.... better yet, existing library. missing? you can enable advanced service within apps script project access fusion tables directly: see: https://developers.google.com/apps-script/advanced/fusion-tables https://developers.google.com/apps-script/guides/services/advanced#enabling_advanced_services

datatable - wicket manipulating DefaultDataTable -

i creating web application in wicket , had created table shows user information. wanted manipulate table if cell contained "n" background color red , if contained "y" background color green. @ moment having trouble determine inside cell. create table following: datatable = new defaultdatatable<tablemodalint, string>("table", columns, new tablemodalprovider(), 100000){ @suppresswarnings("rawtypes") @override protected item newcellitem(string id, int index, imodel model) { item item = super.newcellitem(id, index, model); if (id == "3"){ item.add(attributemodifier.replace("align", "center")); } return item; } }; i capable of determining cell wanna check being displayed user. on how can this? change color know i'll have add item.add(attributemodifier.replace("bgcolor", "red&quo

php - Is IF obligatory to be followed by ELSE -

i not sure if if must followed else in example above or if if can used alone without else. page show if there no else? beginner... <?php $rank = $user["rank"]; if ($rank != 'admin'){ header('location: get_the_he.._out.php'); exit(); } else { ?> <html> <head><title>show page</title></head> <body> here show page if user admin </body> </html> <?php } ?> no. there no need have else if. need make sure script not continue after if, doing here :)

json - custom javascript deserializer in c# -

i working on c# application has browser integrated it. browser send data c# in json format. some of fields json can dserialized using javascript deserializer, have data custom deserializer required, need register deserializer thing custom deserializer must called special data , default javascript deserializer must called other data, special data can identified there target field's data type / name in c#. how can achieve this. something this. public class example { public string abc; public someotherdatatype xyz; public void example() { serializer = new javascriptserializer(); // receive json string serializer.registerconverters(new javascriptconverter[] { new system.web.script.serialization.cs.customconverter() }); //call deserializer } } the json string { "abc" : "valueabc" "xyz" : "valuexyz" } now custom deserializer must called during deserializing xyz , default must calle

javascript - Passing a string value from c# file to js file -

i trying pass string value c# file js file. if try pass int value, can pass it, unable pass string value. string value = "abc"; int a=5; tablecell.attributes.add("onclick", "f1("+value +")"); //nothing happens tablecell.attributes.add("onclick", "f1("+a +")"); //works js file function f1(value) { alert(value); } pass string value in quotes '' use tablecell.attributes.add("onclick", "f1('"+value +"')"); ^ ^ otherwise treated variable. must getting error in browser console.

android - AppCompatEditText tinting issue on lollipop and above -

Image
i've updated appcompat-v7:22.1.0 , there seems tinting issue edittexts colorcontrolactivated color overlaying colorcontrolnormal color. here source example app demonstrates issue: https://github.com/andrewgiang/edittextissue lollipop tinting issue: expected tint:

javascript - How do i delay this function -

this question has answer here: delay jquery effects 6 answers i have code: $('a[href*=#]').click(function() { $('html, body').animate({ scrolltop: $($.attr(this, 'href')).offset().top }, 500); return false; }); but need 600ms delay after click link page have chance perform other actions set 500ms , thank in advance jquery has delay method $('a[href*=#]').click(function(){ $('html, body').delay(600).animate({ scrolltop: $( $(this).attr('href') ).offset().top }, 500); return false; });

c# - Override EqualityComparer for LINQ to SQL class -

i want override equalitycomparer 1 of linq sql classes (autogenerated visual studio) when match indexof, use comparison instead of whatever class. not seem work, , override not called. here logic comparison: clientfilelist f = new clientfilelist(); f.clientid = -1 * lines; f.jobid = jobid; f.drscode = aparts[0]; f.documentnumber = aparts[1]; f.revision = aparts[2]; f.title = aparts[3]; f.titleline2 = aparts[4]; f.titleline3 = aparts[5]; f.sheetnumber = aparts[6]; f.status = aparts[7]; f.colorcode = colorcode; if(ocfile.indexof(f)==-1) { // element not duplicate ocfile.add(f); } and here extended class override equalitycomparer: public partial class clientfilelist : equalitycomparer<clientfilelist> { public override bool equals(clientfilelist x, clientfilelist y) { //throw new notimplementedexception(); return (x.documentnumber == y.documentnumber && x.revision == y.revision); } public override int geth

python - Better way to set default value in django model field -

i implementing field in django model calls following function default value def get_default_value(): = mymodel.objects.aggregate(max_id=max('id')) return get_unique_value_based_on_num(a['max_id'] or 0) class mymodel: default_value_field = charfield(default=get_default_value) although may wrong on this, fear implementation may result in race condition. is there better way ? may use f object or else ? to avoid race conditions, best letting database handle integrity of table, 1 of things databases made for. to so, catch integrityerror raised saving model instance , try again different value when fails. from django.db import integrityerror, models, transaction def get_default_value(): = mymodel.objects.aggregate(max_id=max('id')) return get_unique_value_based_on_num(a['max_id'] or 0) class mymodel(models.model): # have unicity enforced @ database level unique=true. default_value_field = models.charfield

python - Where are my errors? (54 lines of code) -

this current code , when run it, few errors...and i'm not sure are. traceback (most recent call last): file "d:/.actual w4/lab3problem1.py", line 54, in main() file "d:/.actual w4/lab3problem1.py", line 8, in main nestediffunction() file "d:/.actual w4/lab3problem1.py", line 27, in nestediffunction if (booksread == 0): nameerror: name 'booksread' not defined def main(): print("welcome ryan's book club!") booksread = int(input('please enter amount of books have read far: ')) # if (booksread < 0): # print("that's impossible! please re-enter amount of books have read: ") # booksread1 = int(input('please enter amount of books have read far: ')) #simpleiffunction() nestediffunction() #eliffunction() def simpleiffunction(): if (booksread == 0): print('you have 0 points!') if (bo

php - Cron job posts 40-50 new posts to WordPress then fails with transport error - HTTP status code was not 200 -

i have cron job runs php xmlrpc script calls metaweblog.newpost in loop, make posts wordpress site. posts added successfully, until, after typically 40 or 50 posts, script stop error: transport error - http status code not 200 the error log contained (i have removed ip address): (9)bad file descriptor: [client :44726] mod_fcgid: ap_pass_brigade failed in handle_request_ipc function when check phpinfo see zend memory manager enabled , memory_limit 64m. what should looking @ solve this? a 1 second delay did not fix it, , 2 second delay fixed of time. 3 second delay fixed it.

Swift subclassing, recursion, and super casting -

i'm trying define swift class has recursive function returns names of variables in class. works printing it's variables, when use i'll using base class models, , may have multiple layers of inheritance. want method return array of variable names on current instance, names of variables on super classes, until reach base cool class. class cool:nsobject { func dostuff() -> [string] { var values = [string]() let mirrortypes = reflect(self) in 0 ..< mirrortypes.count { let (name, type) = mirrortypes[i] if let supercool = super as! cool while name == "super" { values += supercool.dostuff() } } return values } } the problem in: if let supercool = super as! cool while name == "super" { it causes expected '.' or '[' after super compiler error.

asp.net - Passing null in textboxes not working -

hi m trying pass null values in date textboxes textbox 3 , textbox 4 not able so. please let me know doing wrong. need when page load , textboxes empty need gridview load entire table . @ present loads when enter date range if leave date textboxes empty empty page.i have ajax calendar extension drop down calendar control attached these 2 text boxes. don't know if problem. please help.. here code <asp:sqldatasource id="sqldatasource2" runat="server" connectionstring="<%$ connectionstrings:ingestconnectionstring %>" selectcommand="select id, story_number, date, memory_card, story_name library (story_name '%' + @story_name + '%') , (story_number '%' + @story_number + '%') , (@startdate null or @startdate = '' or date >= @startdate) , (@enddate null or @enddate = '' or date <= @enddate)"> <selectparameters> <asp:controlparameter controlid="

vb.net - Listview - Multi column - Change selection color for the whole row -

Image
i change selection color in listview, default (blue). can not adapt code found needs. here code closest. if e.item.selected = true e.graphics.fillrectangle(new solidbrush(color.gray), e.bounds) textrenderer.drawtext(e.graphics, e.item.text, new font(listview2.font, nothing), new point(e.bounds.left + 3, e.bounds.top + 2), color.white) else e.drawdefault = true end if the main problem e.item.text part. doesn't work multi column listview. here result. before selection : ...and after : is possible preserve values other columns , still have full row selection? thanks. the thing keep in mind ownerdraw listview there 2 events respond (or override if subclassing) if control details view : drawcolumnheader , drawsubitem . drawitem used when control using different view , there no subitems draw. since subitems(0) same item.text , can use drawsubitem draw item , subitem text. cannot tell snippet located, work: priv

Include Functions PHP -

i have php file include functions , css page. trying make include function generate of html. can not figure out how css file in php include function made. <?phpe function htmlstart( $title) { echo "<!doctype html>\n"; echo "<html>\n"; echo "<head>\n"; echo " <title>".$title."</title>\n"; echo " <link href=\ 'inclab.css' type=\"text/css\" rel=\"stylesheet\" />\n"; echo "</head>\n"; echo "<body>\n"; } ?> the problem have echo line: echo " <link href=\ 'inclab.css' type=\"text/css\" rel=\"stylesheet\" />\n"; i tried use double quotes , error, tried use single quotes "inclab.css , got no error. wounding if right way it. also, made navigation bar in include file how put in class (for css

postgresql - How to append URI as string in SQL query -

looks simple unable make happen. when browsing domain.com/post/1 , should show data row id value 1 . row id integer ( int4 ). below the codes, not working: package main import "fmt" import "github.com/go-martini/martini" import "net/http" import "database/sql" import _ "github.com/lib/pq" func setupdb() *sql.db { db, err := sql.open("postgres", "user=postgres password=apassword dbname=lesson4 sslmode=disable") panicif(err) return db } func panicif(err error) { if err != nil { panic(err) } } func main() { m := martini.classic() m.map(setupdb()) m.get("/post/:idnumber", func(rw http.responsewriter, r *http.request, db *sql.db) { rows, err := db.query(`select title, author, description books id = params["idnumber"]`) panicif(err) defer rows.close() var title, author, description string rows.next() { err:= rows.scan(&title, &auth

python - Add users to groups in Django -

i using group module in django. i've created views groupcreateview , groupupdateview in can update permissions , group name, want add users groups. right have update each user object , set groups belongs. want other way around create groups , add users group. how obtained? guess it's group.user_set.add(user) i assuming want add newly created user existing group automatically . correct me if wrong since not stated in question. here have in views.py from django.views.generic.edit import createview django.contrib.auth.models import user django.contrib.auth.models import group django.core.urlresolvers import reverse class usercreate(createview): model = user fields = ['username'] #only expose username field sake of simplicity add more fields need #this 1 called when user has been created def get_success_url(self): g = group.objects.get(name='test') # assuming have group 'test' created already. check auth_us

r - knitr, cairo and ggplot2: font family 'Source Code Pro' not found in PostScript fontdatabase -

trying fix problem otf-fonts have (see how use otf-font in ggplot2 graphics? ) found can use these fonts ggplot2. using knitr rmd-files okay: --- title: "fonttest" author: "me" date: "22. april 2015" output: html_document --- ```{r, echo=false} library(ggplot2) ggplot(mtcars, aes(x=wt, y=mpg, color=factor(gear))) + geom_point() + ggtitle("fuel efficiency of 32 cars") + xlab("weight (x1000 lb)") + ylab("miles per gallon") + theme(text=element_text(size=16, family="arial")) ``` but when want use latex (rnw-files) error: \documentclass{article} \begin{document} \sweaveopts{concordance=true} <<>>= sys.setenv(lang = "en") library(ggplot2, quietly=true) @ <<>>= ggplot(mtcars, aes(x=wt, y=mpg, color=factor(gear))) + geom_point() + ggtitle("fuel efficiency of 32 cars") + xlab("weight (x1000 lb)") + ylab("miles per gallon") + theme(

qt - Include file oddity in ui_mainwindow.h -

in app have oddity in ui_mainwindow.h file include section. last 4 lines of includes looks like #include <qtwidgets/qwidget> #include <treeviewview.h> #include "logo.h" #include "partslistview.h" as can see first line references qt library file ok. second line 1 of files, yet has angle brackets round it. thrid , last lines mine , included properly. treeviewview.h contains subclass of qtreeview. drop tree view on main window , promote treeviewview. same partslistview, based on qtableview. gets promoted in qt-creator in same way treeview. the problem having have added new signal real treeviewview.h file. have connect statement connects slot. when run error "no such signal: treeviewview::newslot(qstring, qstring)" but declared in real header file right next older signal connects in line before new connect line. i think error somehow related odd inclusion in ui header file. whether cause of signal connection problem, needs

mysql - Select latest data per group from joined tables -

i have 2 tables this: survey: survey_id | store_code | timestamp product_stock: survey_id | product_code | production_month | value how can latest value, based on survey timestamp , grouped store_code, product_code, , production_month? for example if have survey_id | store_code | timestamp 1 store_1 2015-04-20 2 store_1 2015-04-22 3 store_2 2015-04-21 4 store_2 2015-04-22 survey_id | product_code | production_month | value 1 product_1 2 15 2 product_1 2 10 1 product_1 3 20 1 product_2 2 12 3 product_2 2 23 4 product_2 2 17 it'd return result this survey_id | store_code | time_stamp | product_code | production_month | value 2 store_1 2015-04-22 product_1 2 10 1 store_1

java - All business logic in stored procedure -

my project's using n-tier architecture , common framework as: presentation layer: jsf 2.0 + primefaces business logic layer: spring management transaction data access layer: spring data + jpa spring security security , user management spring integration integration external system for business logic, we're using java code , reside in business layer, client requires move business logic database , use stored procedures (database oracle). i tried convince client , give disadvantage , advantage if move business logic database below: disadvantages : stored procedure not programming language, should use manage data , not write logic code stored procedure make logic become complex. 1 logic maybe difficult implement stored procedure easy if use programming language java difficult debug or unit test diffucult handler exception difficult maintenance, update stored procedure can't integrate external system take effort write crud each table when orm framework

java - Service injected into spring controller is not available in one of the functions -

i writing spring controller, injects bean. the bean added in config(we use java config everything): @bean public notificationservice notificationservice() { return new notificationservice(); } the service has few injected dependencies , few functions: public class notificationservice { @inject notificationrepository notificationrepository; @inject projectrepository projectrepository; @inject modelmapper modelmapper; public notificationdto create(notificationdto notificationdto) { //convert domain object, save, return dto updated id return notificationdto; } public void markasread(long id, string recipientnip) { //find notification, update status } } model mapper has no configuration, set strict. meanwhile repositoriers interfaces extending jparepository no custom functions. found @enablejparepositories . finally have controller tries use code above: @restcontroller @requestmapping("/notific

ibm mobilefirst - How to run the "PushNotification" Sample on the MF Test Server (Remote Server)? -

i try run sample push notification, getting started ( https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-6-3/notifications/push-notifications-hybrid-applications/ ), on mf server using , db2. sample inside mf studio eclipse works on mf development server. problem: getting pushnotification on mobildevice it works mf studio eclipse on default mf development server it not work on mf test server using , db2 question: how run "pushnotification" sample on mf test server? following environment given: mf server (was,db2) mobilefirsttestserver (serverconfiguration) |-> pushnotifications (environment) |-> pushnotification (application) (deployed) |-> pushadapter (adapter) (deployed) |-> device registered using browser submit notification works: request: http://192.168.126.133:9082/pushnotifications/invoke?adapter=pushadapter&procedure=submitnotification&parameters=[%22thoma

sql server - Sql query for 3 level tree? -

i have table , want 3 lvl tree. example node id parentid name 1 -1 test 1 2 -1 test 2 3 1 test 1.1 4 1 test 1.2 5 3 test 1.1.1 6 3 test 1.1.2 7 5 test 1.1.1.1 if filtered parentid = -1 want rows parentid = -1 , children's +2 lvl. if filtered id = 2 want row id = 2 , children's +2 lvl. update i use ms sql server 2008, entity framework 6.1.3. understand, can use 3 selects. looking effective method you can use recursive sql in sql server. with reccte (childid, parentid, name, depth) assuming ( select yourtable.id childid, yourtable.parentid, cast('test ' + yourtable.id varchar(20)) name 0 depth yourtable parentid = -1 union select yourtable.id childid, yourtable.parentid parentid, reccte.path + '.' + yourtable.id name reccte.dept

android - ArrayAdapter row color method changes multiple rows -

i'm attempting make arrayadapter custom list view. when user clicks on "finish" on listview , want row color particular entry turn red hide "finish" button , show different button called "reset". far works great changes row , button configuration of rows further down in scrollable list. i've looked @ number of different solutions , i've tried i've seen suggested. must missing something... public class resultsadapter extends baseadapter { private static string logtag = "logtag: " + thread.currentthread() .getstacktrace()[2].getclass().getsimplename(); // log tag records context mcontext; // add context layoutinflater inflater; // instance of inflater resultdatasource resultdatasource; // lists of result private list<result> maindatalist = null; private arraylist<result> arraylist; // instance constructor public resultsadapter(context context, list<result> maindatalist, resul

shell - Finding unique values in a data file based on two columns -

this question has answer here: awk/unix group by 4 answers i have file in unix this name1 text text 123432re text name2 text text 12344qp text name3 text text1 134234ts text name3 text text2 134234ts text i want find different types of values in 3rd column user names, lets name1 , name2 , name3 . like below: name1 1 name2 1 name3 2 how can required result? if text in columns before 4th column cannot contain spaces, following should gawk : gawk '{++vals[$1][$3];} end {for (u in vals) { c = 0; (t in vals[u]) { ++c; }; print u" "c;} }' yourfile (note, gawk supports multidimensional arrays, while standard awk doesn't, same solution won't work standard awk .)

How can i create nodes with different fields (angularJS)? -

i want create node diffrent fields here index.html , app.js index.html <html> <head> <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css"> <link rel="stylesheet" href="css/bootstrap/bootstrap-theme.min.css"> <link rel="stylesheet" href="css/nodecss.css"> </head> <body ng-app="webapp"> <h1>module opale</h1> titre<input type="text" placeholder="titre"><br /> metadonnées<input type="text" placeholder="titre"><br /> objectif du module<input type="text" placeholder="objectif"> <script type="text/ng-template" id="tree_item_opale.html"> <button class="addchild" ng-click="addchild(data)">addchild</button> <button ng-show="data.parent" ng-click=&qu

ios - Is it possible (or advisable) for a method to recognize its caller? -

i'm developing simple game player needs roll die , "the computer" needs it. i roll method performs differently each type of player. it's set bool parameter called isplayer (vs. iscomputer). players pass true value, computer false. there's if statements in method act accordingly. this seems clunky me. there better way? i thinking of creating playertype enum , each player have type still need pass type method. or change game variable type , method recognize that. any thoughts helpful. thanks. no seems fine , much-used , simple pattern. a bool fine time there 2 types of player (or behaviour) , moving enum if number of players extends beyond 2. alternatively there polymorphism roll method behaves differently depending on subclass implements it. require no parameters passed behaviour locked in class.

Java Help Recursion & Binary Trees -

i new java, , new recursion , binary trees. building program takes text document , stores in binary tree. need take string , find out how many times appears in text. my problem(s) either while adding data and/or when searching data string. i have decided store string , frequency in each node built. add methods follows: public void add(string newword) { //change word case make comparing easier newword = newword.touppercase(); root = recursiveadd(root, newword); } /** * takes root , recurses until root null (base case) * frequency incremented if data being added, or if * exits. if data not present, method recurses */ private node recursiveadd(node subtree, string newword) { //base case: root null //empty trees have node created, set, , incr freq if (subtree == null) { subtree = new node(); subtree.setstoredword(newword); subtree.incrfreqcount(); return subtree; } int comparison = newword.compareto(su