Posts

Showing posts from August, 2012

c# - SignalR difference between Context.Request.Cookies and Context.RequestCookies -

is there difference between context.request.cookies , context.requestcookies ? both properties seem have identical values. confusing. it's same. following implementation of requestcookies property of microsoft.aspnet.signalr.hubs.hubcallercontext class: public idictionary<string, cookie> requestcookies { { return this.request.cookies; } } you can validate decompiling microsoft.aspnet.signalr.core.dll. actually, since open-source, don't need decompile, code can downloaded github: https://github.com/signalr/signalr/blob/master/src/microsoft.aspnet.signalr.core/hubs/hubcallercontext.cs

pass by reference - How can a method without the out or ref change a variable outside itself? C# -

this question has answer here: what difference between reference type , value type in c#? 12 answers how possible change values of array a inside of sumelemtnts method? because it's static method? because method returns variable sum , there no ref or out. class program { public static int sumelements(int[] a) { int[] a2 = a; int sum = 0; (int = 0; < a2.length; i++) { int temp = a2[i] * 10; a2[i] = temp; sum += temp; } a[a2.length - 2] = sum; return sum; } public static void main(string[] args) { int[] = { 1, 2, 3 }; int sum = sumelements(a); console.write("sum = " + sum + ", "); (int = 0; < a.length; i++) { console.write(a[i] + " "); } } } the re...

java - MDB is not consuming Messages from Queue on standalone Hornetq -

i using wildfly-8.0.0.final , hornetq-2.4.0.final. i'm trying read messages queues on hornetq server using mdb. mdb running on wildfly. first removed messaging configuration standalone.xml(wildfly).in hornetq-2.4.0.final, added queue in hornetq-jms.xml. in mdb, gave @messagedriven(activationconfig = { @activationconfigproperty(propertyname = "destinationtype", propertyvalue = "javax.jms.queue"), @activationconfigproperty(propertyname = "destination", propertyvalue = "queue/myqueue"), @activationconfigproperty(propertyname = "acknowledgemode", propertyvalue = "auto-acknowledge"), @activationconfigproperty(propertyname = "connectorclassname", propertyvalue = "org.hornetq.core.remoting.impl.netty.nettyconnectorfactory"), @activationconfigproperty(propertyname = "connectionparameters", propertyvalue = "host=localhost;port=5445")}) @resourceadapter(...

c# - Creating an admin page in asp.net mvc 5 -

i started basic tutorial http://www.asp.net/mvc/tutorials/mvc-5/introduction/getting-started . i've added 2 roles in database table aspnetroles (yes db generated automatically) now i'm looking tutorials create admin page. because don't know start. can of put me in right direction. you start adding admincontroller , give actions . you place [authorize] attribute above controller admins able access actions controller, similar below: [authorize(roles = "admin, anotherrole")] public class admincontroller : controller { public actionresult index() { return view(); } }

Is the list of Python reserved words and builtins available in a library? -

is list of python reserved words , builtins available in library? want like: x.y import reserved_words_and_builtins if x in reserved_words_and_builtins: x += '_' to verify string keyword can use keyword.iskeyword ; list of reserved keywords can use keyword.kwlist : >>> import keyword >>> keyword.iskeyword('break') true >>> keyword.kwlist ['false', 'none', 'true', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'] if want include built-in names (python 3)...

vim - Inserting text when opening a file -

i trying edit new file vim. first line should given text string. like vim -c ":insert text" filename.txt the behaviour looking filename.txt opened vim , word text appears on first line. the command above wrong.. suggestion on how obtain behaviour. thanks. convoluted solution: this seems want. not save file, inserts text. vim -c ':exe "normal itext"' filename.txt this works same, exits insert mode after text entered: vim -c ':exe "normal itext\<esc>"' filename.txt previous, incorrect solution. helpful: similar hal's answer, can have vim grab text standard input: echo "this text" | vim - -c ":w filename.txt" and vim open "this text" on first line, , -c command call :w filename.txt command vim opens.

sql - Returning a list of rows that are unique by type and returning the first pass -

id userid type pass date 1 12 track1 1 20140101 2 32 track2 0 20140105 3 43 pull1 1 20140105 4 66 pull2 1 20140110 5 54 pull1 0 20140119 6 54 track1 0 20140120 so users can take multiple attempts 'type', can take 'track1' multiple times, or 'pull2' multiple times. i want return first pass (1) each unique 'type' each user. i want return both pass , fail rows, first instance of pass or fail. how can this? sample table , output id userid type pass date 1 12 track1 1 20140101 2 12 track2 0 20140105 3 12 pull1 1 20140105 4 12 pull2 1 20140110 5 12 pull1 0 20140119 6 12 track1 0 20140120 7 12 track1 0 20140121 8 12 pull1 1 20140115 9 12 track2 0 20140125 output: 1 12 track1 1 20140101 2 12 track2 0 20140105 3 12 pull1 1 20140105 4 12 pull2 1 20140110 select t1.* usertrackstatus t1 join ( select u...

Pass Control form one Executable to another C++ -

this question has answer here: differences between fork , exec 7 answers does there exist way pass control 1 exe file such when first exe ends second 1 starts working ? the exec family of functions replace 1 running program image another. open files , various other bits of state preserved, may or may not want; write glue code appropriate.

c++ - Facet ctype, do_is() and specializations -

i derived ctype class build own facet in order override virtual function do_is() . purpose make stream extractor ignore space characters (and still tokenize on tabulation character). overriding calls implementation of mother class. compile wchar_t . there no implementation of ctype::do_is() char template value. that's true gcc , vs 2010. here code ; have uncomment 5th line test between 2 versions. #include <iostream> #include <locale> #include <sstream> // #define wide_characters #ifdef wide_characters typedef wchar_t charactertype; std::basic_string<charactertype> in = l"string1\tstring2 string3"; std::basic_ostream<charactertype>& consoleout = std::wcout; #else typedef char charactertype; std::basic_string<charactertype> in = "string1\tstring2 string3"; std::basic_ostream<charactertype>& consoleout = std::cout; #endif struct csv_whitespace : std::ctype<charactertype> { bool do_is(mask m,...

vim - Deleting specific patterns without deleting the whole lines -

say want remove comment blocks in source code without deleting whole lines on. it's possible achieve using :%s/\/\*.*\*\// command. wondering, there specific delete command this, or replacing matched pattern best approach? difference wouldn't much, i'm curious. replacing nothing idiomatic 'delete pattern' operation. :%s/pattern//g if want blank lines contain pattern, in example, obvious solution add wildcard matches around pattern. :%s/.*pattern.*// an alternative use :global normal mode or ex command. these 2 achieve same thing: :g/pattern/normal! s :g/pattern/delete|put! _ by way, while don't recommend using abbreviated command names in scripts or in code other people might see, think it's fine use them interactively. tend abbreviate such commands :g/pattern/norm! s , :g/pattern/d|pu!_ .

c++ - Enable "." and "->" in emacs autocomplete -

is there way autocomplete popup after typing "." or "->"? i thought code was (add-to-list 'ac-omni-completion-sources (cons "\\." '(ac-source-semantic))) (add-to-list 'ac-omni-completion-sources (cons "->" '(ac-source-semantic))) but seems may have been deprecated. the closest i've see alex ott's response here using: (defun my-c-mode-cedet-hook () (local-set-key "." 'semantic-complete-self-insert) (local-set-key ">" 'semantic-complete-self-insert)) (add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook) however, pops frame display suggestions semantic. have use autocomplete's native popup if possible, in such manner when attempt reference member function of class using "myclass->", autocomplete popup suggestions. idea if can accomplished? sorry big oversight on comment. i'm @ bit...

php - Select and call_user_func_array issue -

i've function: private function db_bind_array($stmt, &$row) { $md = $stmt->result_metadata(); $param = array(); while($field = $md->fetch_field()) { $param[] = &$row[$field->name];} return call_user_func_array(array($stmt, 'bind_result'), $param); } private function db_query($sql, $bind_param, $param) { if($stmt = $this->conn->prepare($sql)) { if(!$bindret = call_user_func_array(array($stmt,'bind_param'), array_merge(array($bind_param), $param))) $this->terminate(); if(!$stmt->execute()) $this->terminate(); $res = array(); if($this->db_bind_array($stmt, $res)) return array($stmt, $res); } } protected function select($recs, $table, $where, $bind_param, $param, $order_by = '', $sort = '', $limit = 1) { if($order_by != '') $order_by = 'order '.$order_by; $sql = "select $recs $table $where $order_by $sort limit $limit"; return $this->exeselect($sql, $bind_p...

php - Declare global array in codeigniter to access between different functions -

i want declare global variable in model , use accordingly. syntax below example how want use it, may not proper syntax. want know proper syntax implement. global $stddata call 1st function via ajax: add array of data global variable. global $stddata = array(1=>"a",2=>"b"); after user triggers event call 2nd function via ajax: access array stored in global variable above. echo $stddata your question similar : code igniter - best place declare global variable or how declare global variable in codeigniter 2.2? try this, might solution.

c++ - Reading from a file to a string doesn't work as expected -

i'm writing first programm in opengl , c/c++. came across following problem: i wrote method reads file (in case containing vertex or fragment shader) , returns content 1 string. std::string loadshader(const char* filepath) { if(filepath){ std::ifstream ifs(filepath, std::ifstream::in); std::ostringstream oss; std::string temp; while(ifs.good()){ getline(ifs, temp); oss << temp << '\n'; std::cout << temp << std::endl; } ifs.close(); return oss.str(); } else{ exit(exit_failure); } } i've 2 files: vertexshader.glsl , fragmentshader.glsl want convert 2 seperate strings creation of shaders. code above called in following way: void createshaders(void){ glenum errorcheckvalue = glgeterror(); const glchar* vertexshader = loadshader("vertexshader.glsl").c_str(); const glchar* fragmentshader = loadshade...

html - Hidden table row does not display where it is supposed to -

this supposed display additional information in hidden row each row in table. the problem is, not being displayed under row rather above table. if select row 3 view additional information, hidden row should appear under instead appearing on top of rows. i'm guessing there's wrong table structure can't figure out what. and here's jsfiddle <link rel="stylesheet" type="text/css" href="http://drvic10k.github.io/bootstrap-sortable/contents/bootstrap-sortable.css"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script src="http://drvic10k.github.io/bootstrap-sortable/scripts/bootstrap-sortable.js"></script> <script src="http://drvic10k.github.io/bootstrap-sortable/scripts/moment.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></scri...

What to learn after JavaScript? -

i've finished watching beginner javascript tutorials; it's quite easy understand. i'm trying intermediate ones now, can't find any. i've decided not waste time while looking continuation on javascript journey. should learn next? prefer important, , perhaps, closely related javascript. it depends on goal is, , have learned. if want become web developer , should learn server-side web languages php or asp.net. if want become general developer, useful know systems languages java or c++. if want computer scientist, studying algorithms might start.

linux - commands in bash script doesn't work properly -

i have script : #!/bin/bash ./process-list $1 det=$? echo $det if [ $det -eq 1 ] echo "!!!" ssh -n -f 192.0.2.1 "/usr/local/bin/sshfs -r 192.0.2.2:/home/sth/rootcheck_redhat /home/ossl7/r" rk=$(ssh -n -f 192.0.2.1 'cd /home/s/r/rootcheck-2.4; ./ossec-rootcheck >&2; echo $?' 2>res) if [ $rk -eq 0 ] echo "not!" fi fi exit; i ssh system 192.0.2.1 , run sshfs command on it. actualy want mount directory of system 192.0.2.2 on system 192.0.2.1 , run program (which located in directory) on system 192.0.2.1 . these ssh , sshfs commands work properly. when run them manually , output of program ossec-rootcheck written file res ,but when run script, mount done no output written file res . guess program ossec-rootcheck runned don't know why output isn't written! script used work before don't know happend suddenly! as far understand program, remote machine has stdin>stderr, how local machine ssh ...

PHP Interfaces are used in Dependency Injections, how then? -

i have seen following code: class loginauth { function __construct(authinterface $auth) { $this->auth = $auth; } function userlogin ($credits) { return $this->auth->login($credits); } } my question interfaces described php is: object interfaces allow create code specifies methods class must implement, without having define how these methods handled. so, see interfaces not used define internal logic of [class'] controller, allow definition of methods should implemented class. how possible that, interface not contain actual logic inside methods, deployed. mean, method login() member of auth() class defined in interface: interface authinterface () { function login($credits){} } then how such signature used (as used in main example)?

c# - How to use the data of DataTable in report viewer? -

i data source of datagridview datatable , passed reportviewer datatable dd = (datatable)dgvcars.datasource; dd.tablename = "cars"; report r = new report(dd); r.show(); // materialssuppliersdataset t = new materialssuppliersdataset(); // messagebox.show("" + dd.rows[0][1]); reportdatasource rds = new reportdatasource("cars",dd); rv.processingmode = processingmode.local; localreport lc = rv.localreport; lc.datasources.add(rds); rv.localreport.reportpath = "report1.rdlc"; this.rv.refreshreport(); how can use fields of datatable display in report ? to bind records report viewer use databind. this.reportviewer1.localreport.reportpath = server.mappath("report1.rdlc"); reportdatasource rds = new reportdatasource("cars", dataset); this.reportviewer1.processingmode = processingmode.local this.reportviewer1.localrep...

valueinjecter - Automapper vs Value Injecter Performance and Flexiblitiy as of 2014 -

from automapper , value injecter 1 fastest, 1 flexible one? of 2014 (today) not evaluation of past if worried performance can use smartconventioninjection, learns matches between pairs of types , works faster because of that, doesn't uses value of property in matching algorithm ( times don't need that) can see here: http://valueinjecter.codeplex.com/wikipage?title=smartconventioninjection there speed tests well for differences, flexibility, see question: automapper vs valueinjecter

php - Generate a unique link for each email id :Yii -

i have yii web app user can send mass email. in mail send unique link each email id. don't have idea how this. where should start in order implement this? 1). how generate unique links automatically each email id. 2). how track response if user clicks on link? sounds you'd need store data somehow after each email sent, unique hash. inside email use unique hash in url query. then on page you'd use hash call info stored email, lets discussion panel or something. a simple effective token can generated so: $token = substr( md5( microtime() ), -12 ); you can generate unique backwards compatible hash users email. (this insecure!) $token = base64_encode ( $email ); // users email encoded you can use code decode , search email in database $emailtoken = base64_decode( $_get['t'] ); // contains users email you can test see if valid token make secure against basic injections so: if ( base64_encode( base64_decode( $_get['t'] ) ) === ...

How to make status-bar untouchable in android? -

i trying make lock screen android, versions greater honeycomb. have been searching working solution since month haven't been successful. i'll specific situation. in specific activity want status bar visible untouchable @ all . in other words user should not able pull down. i don't want solution collapse status bar when activity loses focus . doesn't work! still able pull down status bar after 1 or 2 tries on galaxy note-2. i don't want put activity in fullscreen mode . hide status bar want visible. i know possible . there threads saying it's impossible so. know it's possible because there other custom lock screens implement same. (eg. dodol locker, locker+, etc.) i appreciate working code. thanks in advance. lets give try not make status bar untouchable stop getting dragged,first give permissions in mainfest file expand_status_bar <uses-permission android:name="android.permission.expand_status_bar" /> declare these...

android - Not seeing Geofence Transitions in Google's tutorial on Geofencing -

Image
i trying test geofence functionality using google's example: creating & monitoring geofences . have uploaded code here . problem never notification of entry or exit. have wifi, 4g , gps on. have tried test in following ways: i walk out of house 50ft , walk in - no notifications. can see play services gets connected , "geofenceutils.action_geofences_added in mainactivity.java" gets triggered, think geofences getting added correctly. enabled mock locations in settings , used fake gps app , changed location - starting same coordinates geofence1 , setting totally outside (in state) - still dont exit notification. what doing wrong? had success in running google's example: creating & monitoring geofences . have uploaded code here easy browsing. i trying learn geofencing - detecting entry & exit. i mark answer right answer can use geofencing working on real device . i having issues example code. 1 of main issues had around declaring r...

Date picker in JQuery and php -

i implementing calendar using jquery . pure html form tested , it's working fine. when embed in php, it's not working , error shows when select inspect element is--> object has no method datepicker. pure html: <html lang="en"> <head> <title>date thing</title> <link href="jquery-ui-1.10.4.custom/css/start/jquery-ui-1.10.4.custom.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery-ui-1.10.4.custom/js/jquery-1.10.2.js"></script> <script type="text/javascript" src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.js"></script> <script type="text/javascript" src="jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $( "#datepickerid" ).datepicker({ changeyear: tru...

networking - Telnet session starts with 21 bytes of crap -

within small embedded application i'm providing telnet server sending simple commands it. testing connect using putty. found there 21 bytes of data sent server on connection. so...what be? initialisation sequence? from understanding telnet plain connection should not have such data... thanks! ok, got it: when selecting "active auto negotiation mode" in putty sends these data additional information of whatever...so 1 has tod rop characters ascii code larger 127 ignore these data.

How to retrieve all possible Facebook likes categories? -

when requesting facebook user's likes through api, list looks this: { category: 'product/service', name: 'runkeeper', created_time: '2014-04-05t12:17:09+0000', id: '24659131143' } { category: 'science website', name: 'i fucking love science', created_time: '2014-04-03t08:11:53+0000', id: '367116489976035' } ... since "likes" page likes, assumed full list of page categories https://www.facebook.com/pages/create.php page. once i've done this, realized likes categories not in list. so, question is, how can retrieve list of possible facebook likes categories?

android - Loading images to custom listview - how to gradually load? -

i have custom listview - contains imageview, text , checkbox. i loading images dropbox (taking thumnails or else getting shared url image) , loading them custom listview using imageadapter . it slow load images in given folder. takes several seconds load few images, minute if there dozens, , app crashes assume out of memory exception if there lots of images. it seems taking 2 seconds url dropbox (or bitmap if decode stream). taking 60 seconds retreive 30 image urls. excessive (not sure why taking long?) i hoping can improve code lot faster. load images incrementally, i.e. keep ui responsive , load images in batches. i using async task, can advise. note have tried using universal image loader , still takes long time load images. i should note think problem in retrieving image data dropbox. code below retrieves thumbnail file, , slow. have tried changing code instead retrieve url link image, again slow execute , loop. so there way inside of loop images , to sta...

Crop path within canvas Android -

Image
in below image red color canvas. black color part figure drawing in canvas. want crop black color part canvas. how shall it?. i tried using canvas.clippath() guess no longer supported in android now, due hardware acceleration. tried disableing hardware acceleration dint work gave on canvas.clippath() . is there other way can use crop path within canvas ? any appreciated. in advance :)

How to recover table after drop it in SQL Server -

i drop table in sql server using code: drop table temp now, try recover table, don't know solution :( please, tell me solution problem if know. thanks! if drop table executed inside transaction , has not been committed can rollback. if isn't, need backup of database. recover table database. if backup not present, search 3rd party recovery tools.

hadoop - Questions about Oozie/Sqoop -

i have few questions: 1. why there mapreduce process in sqoop load data hdfs mysql? e.g. data in hdfs on directory: /foo/bar to load data in mysql bar table, why there mapreduce process? sqoop export --connect jdbc:mysql://localhost/hduser --table foo -m 1 --export-dir /foo/bar after entering above command, mapreduce process executes. 2. how can enable/disable key in mysql using sqoop/oozie? since huge data getting loaded mysql, need use enable/disable. how achieve it? 3. how run multiple oozie jobs in parallel? 4. how run oozie jobs in cron? you can answer 1 or more questions. thank you. i'll go through questions 1 one. feel free ask more questions in comments , elaborate on things unclear you. 1. why there mapreduce process in sqoop load data hdfs mysql? this because sqoop based on mapreduce. if consider how files stored in hdfs, split small chunks , these chunks stored across cluster (some of chunks might on same node). makes perfect sen...

c# - How does anonymous methods omit parameter list? -

i reading in msdn documentation on anonymous methods (c# programming guide) , not understand part omitting parameter list. says: there 1 case in anonymous method provides functionality not found in lambda expressions. anonymous methods enable omit parameter list. means anonymous method can converted delegates variety of signatures. not possible lambda expressions. my understanding special case when anonymous methods not using arguments. anonymous methods can leave out parameters entirely. correct? i think confused lambda expressions , anonymous methods . need understand lambda expressions syntantic sugars .for example, can create anonymous method takes 2 integer parameter , returns integer this: func<int, int, int> func = delegate(int x, int y) { return x + y; }; using lambda syntax can shorten statement this: func<int, int, int> func2 = (x,y) => ret...

objective c - XCode 5: Automatic ARC conversion unavailable -

i decided bite bullet , convert large years-old project arc. but, all of menu items in xcode-5->edit->refactor contain term "refactor" dimmed , unavailable. no fiddling has been able enable them. if create new empty project, available, when open old, large project, not. project has been "updated" xcode "xcode 3.2 compatible", recent compatibility level offers. because xcode doesn't know how import existing project, or know how accept drag of group 1 project another, transporting large, complicated project new project file time-consuming, error-fraught undertaking hoping avoid. anybody seen problem, , resolved without starting new project , laboriously copying files over? so answer ( thank you, greg parker! ) platform still set x86+x86_64 , disables arc conversion tool. may need quit xcode , re-open target convert arc menu item enabled.

Mutiple highcharts on single page -

i planning design single page application. planing using angularjs. want display multiple charts on same page. generate pdf report contains charts on 1 page. want give option user select no of row generated.(pagination) want , else printed on single page? there way achieve this?

python - Selecting specific rows and columns from NumPy array -

i've been going crazy trying figure out stupid thing i'm doing wrong here. i'm using numpy, , have specific row indices , specific column indices want select from. here's gist of problem: import numpy np = np.arange(20).reshape((5,4)) # array([[ 0, 1, 2, 3], # [ 4, 5, 6, 7], # [ 8, 9, 10, 11], # [12, 13, 14, 15], # [16, 17, 18, 19]]) # if select rows, works print a[[0, 1, 3], :] # array([[ 0, 1, 2, 3], # [ 4, 5, 6, 7], # [12, 13, 14, 15]]) # if select rows , single column, works print a[[0, 1, 3], 2] # array([ 2, 6, 14]) # if select rows , columns, fails print a[[0,1,3], [0,2]] # traceback (most recent call last): # file "<stdin>", line 1, in <module> # valueerror: shape mismatch: objects cannot broadcast single shape why happening? surely should able select 1st, 2nd, , 4th rows, , 1st , 3rd columns? result i'm expecting is: a[[0,1,3], [0,2]] => [[0, 2], ...

java - How to retrieve data from MYSQL database hosted on Azure VM? -

i'm software engineering student , need help. i have developped dynamic web project (java ee/jsf/hibernate/mysql/apache tomcat/eclipse) , have deployed on windows azure. created virtual machine installed mysql , tomcat. my problem is: how can retreive data database hosted on vm process actions on? i thought rest ws project wich invoke services, don't know services exposed or how connection db.(i need free) i'm blocked , more appreciated . best regards. one option is, instead of hosting database on vm, create mysql on azure shown here - http://azure.microsoft.com/en-us/documentation/articles/store-php-create-mysql-database/ also, azure websites supports java web applications - can deploy tomcat application azure websites shown here - http://azure.microsoft.com/en-us/documentation/articles/web-sites-java-get-started/

javascript - Sails.js query on an associated value -

i'm using sails.js version 0.10.0-rc4 . models using sails-mysql. i'm trying query model has "one-to-many" association model (the query happening on "many" side). it looks this: post.find() .where({ category: category_id }) .populate("category") .exec( ... ) this gives me empty array when leave out .populate("category") correct result set. i know leave .populate("category") out , fetch each correlating category object separately, i'm wondering if there's better solution problem. it's not 100% clear you're trying here. if goal filter categories populated on post , can do: post.find() .populate("category", {where: { category: category_id }}) .exec( ... ) if want retrieve post s category, do: category.findone(category_id) .populate("posts") .exec(function(e, c) {console.log(c.posts);})

c# - Set required fields based on HTTP Verb -

is possible set optional [required] attribute, applicable on patch or put. have following code no matter controller call required. public class car { [datamember(order = 0)] public string carid { get; set; } [datamember(order = 1)] [required] public string isincluded { get; set; } } controller; [httppatch] public httpresponsemessage patchcar(car car) { // check if submitted body valid if (!modelstate.isvalid) { // bad! } } what want following; public class car { [datamember(order = 0)] public string carid { get; set; } [datamember(order = 1)] [required(patch = true, put = false] public string isincluded { get; set; } } then modelstate take account. i thought creating separate derived classes each action (verb), code becomes incredibly verbose. this 1 of drawbacks of using data annotations validation unfortunately cannot conditionally added. there number of options you... create separate mode...

javascript - Posting a form with jQuery and want to change the submit button after click -

here's code i'm using :p did not work! and anyways hell "it looks post code please add more details" ? <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#button").click(function(){ $("#button").submit(sendform) }); function sendform() { $.post('post.cfm',$("#button").serialize(),function(data,status){ $("#result").html(data) }); return false } $("#button").html("friend request sent"); }); }); </script> </head> <body> <form id="button"> <input type="submit" value="add friend"> </form> you try this: var sendform = function() { $.post('post.cfm',$("#button").serialize(),function(data,status){ $("#result").html(data) }); var req...

Shipping information from SQUARE CONNECT -

i have been tasked develop way create shipping labels items shipped square market. is there way download or access shipping data entered buyers during order process? i use square connect api. the information available on "order confirmation" page not json form. is going available @ time in future through square connect api? order management, including accessing shipping addresses square market orders, not possible square connect api. available functionality described in documentation . however, actively developing api, , pass feedback along engineering team.

php - Set up PDO connection without password -

i'm trying connect database, changed database's root password in interest of security. however, in order connect database , use pdo, apparently have pass password in php, not security: $hsdbc = new pdo('mysql:dbname=hs database;host=127.0.0.1;charset=utf8', 'root','passwordgoeshere'); $hsdbc->setattribute(pdo::attr_emulate_prepares, false); $hsdbc->setattribute(pdo::attr_errmode, pdo::errmode_exception); am being stupid , because it's php no-one person views actual file able see password, or there way without passing password in file. people not able go , read files. should safe on place host it. able files if able place when host stuff. should not possible if don't have info there.(which should known you). this not pdo. mysql , mysqli this

c# - Fill xaml rectangle multiples solidcolorbrush -

Image
this type of fill in rectangle in xaml possible? i don't want use gradient fill rectangle, in image per section using solid colorbrush different. thanks try this: <rectangle width="300" height="100" stroke="black" strokethickness="3"> <rectangle.fill> <lineargradientbrush startpoint="0 0" endpoint="1 0"> <gradientstop color="red" offset="0"/> <gradientstop color="red" offset=".33"/> <gradientstop color="black" offset=".33"/> <gradientstop color="black" offset=".34"/> <gradientstop color="green" offset=".34"/> <gradientstop color="green" offset=".66"/> <gradientstop color="black" offset=".66"/> <gradientstop color="black" offset=".67...

How to concatenate a char array case [0] and [1] to a char pointer in C? -

i want concatenate 2 characters '7' , '9' form string "79". first, initialized variables. (restriction: have use char types , must not make charac alike variable.) char *charac = (char *) malloc(sizeof(char) * 200); char *combined = (char *) malloc(sizeof(char) * 200); then gave values charac[0] , charac[1]. charac[0] = '7'; charac[1] = '9'; printf("charac[0] : %c\n", charac[0] ); printf("charac[1] : %c\n", charac[1] ); i want concatenate charac[0] , charac[1] strcpy(combined, (char*)charac[0]); strcat(combined, (char*)charac[1]); printf("combined : %s\n", combined); free(combined); but code above doesn't work. got error message: "warning: cast pointer integer of different size". after reading of comments , suggestions, obtain output result want. here final code: char *charac = (char *) malloc(sizeof(char) * 200); char *combined = (char *) malloc(sizeof(char) * 200); ...

Is possible to specify different permissions depending on the Android version? -

my app using parse library push notifications, requires permissions work properly. i've noticed of potential users of application bit suspicious in particular of permission get_accounts: think access personal data or :-/ i looked @ android documentation (see here ) , seems get_accounts required push notifications devices running os versions below 4.0.4, rid of permission @ least higher os versions. what best way achieve this?. imagine use play store multiple apk support, necessary removing single line of permissions in manifest file?. hope there better solution far couldn't find out other. use android:maxsdkversion on <uses-permission> manifest entry: <uses-permission android:name="android.permission.get_accounts" android:maxsdkversion="13" /> note: should still test on both android versions parse may still check account on higher versions of android.

c - trying this merge sort... but it's not working... can anyone find the error? -

i'm having problem c program perform merge sort on user-defined array. when run program, it's taking array input, abruptly stops after , shows error 255. algorithm mycodeschool.org. here's code: #include<stdio.h> #include<stdlib.h> void merge(int *a, int *left,int *right,int n, int ln, int rn) { int i,j,k; i=j=k=0; while(i<ln&&j<rn) { if(left[i]<=right[j]) { a[k]=left[i]; i++; } else { a[k]=right[j]; j++; } k++; } while(i<ln) { a[k]=a[i]; k++; i++; } while(j<rn) { a[k]=a[j]; k++; j++; } } void mergesort(int *a, int n) // partition { int mid,i,*left,*right; if(n<=1) return; mid=n/2; left=(int *)malloc(sizeof(int)*mid); right=(int *)malloc(sizeof(int)*(n-mid)); for(i=0;i<mid;i++) left[i]=a[i]; for(i=mid;i<n;i++); right[i-mid]=a[i]; mergesort(left,mid); mergesort(right,(n-mid)); merge(a,left,right,n,mid,n-mid); } int main() { int *a,n,i; printf(...

sql - Insert multiple rows into a table with a trigger on insert into another table -

i attempting create t-sql trigger insert x number of rows third table based upon data being inserted original table , data contained in second table; however, i'm getting sorts of errors in select portions of insert statement. if comment out portion [qmgmt].[dbo].[skillcolumns].[columnid] in (select columnid [qmgmt].[dbo].[skillcolumns]) , intellisense gets rid of red lines. table designs: users table - contains user info skillcolumns table - list of columns possible, filtered on productgroupid of user skills table - contains data per user, 1 row every columnid in skillcolumns create trigger tr_users_insert on [qmgmt].[dbo].[users] after insert begin insert [qmgmt].[dbo].[skills]([userid], [displayname], [columnid]) select [itable].[userid], [itable].[displayname], [cid] in (select [columnid] [cid] [qmgmt].[dbo].[skillcolumns]) inserted [itable] inner join [qmgmt].[dbo].[skillcolumns] on [itable]...

c# - Loading gif image visible while the execution process runs -

i using window app , c#.. have picture invisible @ start of app.. when button clicked, picture box has shown.. i use coding picture box not visible private void btnsearch_click(object sender, eventargs e) { if (cmbproject.text == "---select---") { messagebox.show("please select project name"); return; } else { picturebox1.visible = true; picturebox1.bringtofront(); picturebox1.show(); fillreport(); thread.sleep(5000); picturebox1.visible = false; } } don't use sleep - blocks thread, means no windows messages processed, , form won't repainted. instead, use timer hide image after 5 seconds. add timer form, , change code this: picturebox1.visible = true; fillreport(); timer1.interval = 5000; timer1.start(); and...

Android Lock Pattern Errors -

i'm trying use android lock pattern but when import library eclipse, got these errors : icontentview cannot resolved type r cannot resolved variable error parsing xml: not well-formed (invalid token ) code errors : implements icontentview public class lockpatternactivity extends activity implements icontentview { private static final string classname = lockpatternactivity.class.getname(); /** * use action create new pattern. can provide * {@link iencrypter} * {@link security#setencrypterclass(android.content.context, class)} * improve security. * <p/> * if user created pattern, {@link activity#result_ok} returns * pattern ({@link #extra_pattern}). otherwise * {@link activity#result_canceled} returns. * * @see #extra_pending_intent_ok * @see #extra_pending_intent_cancelled * @since v2.4 beta anyone used facing problem? how solve that? lot. try following.. right click library project >> build path >> con...

java - Image processing - OpenCV, Identifying digits -

Image
i new image processing , opencv in particular. i working on ocr project in need identify numbers. this image process: lets optimized image, questions are: in image number apeared several times, lets found contours, how can know 1 if the best 1 process? how can know in angle need rotate each contour make stright? in image number apeared several times, lets found contours, how can know 1 if the best 1 process? you want biggest number, because least warped perspective. want numbers in middle of image, because n middle of ball. how can know in angle need rotate each contour make stright? have @ rotated rect . explained how find angle in thread . since have centered ball, should think using mapping "unwarp" ball (so projection globe onto map). should pretty straightforward afterwards find numbers on flat image. edit: since have 10 numbers might "brute force" solution big enough training set. throw numbers detect classifier , ...

c# - Why use private methods in WPF MVVM? -

i took on development of relatively mature wpf mvvm project didn't have lot of unit tests. once understood of code doing thought it'd idea write more. now, don't have experience of either mvvm or wpf seems obvious given relatively limited, property-based binding between ui , code, lot of logic can locked away behind private methods. that's i'd have done, , that's predecessor had done. unit testing private methods bit of pain (i know how use privateobject, it's clumsy), , reading around discussion on subject there seemed fair number of people evangelising decreased use of private methods facilitate testing. so got me thinking: primary reason locking things behind private methods other developers using object don't overwhelmed near-useless methods, right? in wpf mvvm you're invoking objects xaml, there's limited intellisense , need know names of you're calling before so. so ... there reason using private methods when coding in parad...

c++ - Qt: "No such signal" error -

i have simple code; here i've 2 buttons, press first 1 , shows msgbox. press "okay", , should call connected action written in second button, doesn't. instead error: object::connect: no such signal qmessagebox::buttonclicked(qmessagebox::ok) object::connect: (receiver name: 'openfile_bttn') the code: #include "mainwindow.h" #include "ui_mainwindow.h" mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); } mainwindow::~mainwindow() { delete ui; } void mainwindow::on_openfile_bttn_clicked(){ qfiledialog::getopenfilename(this,tr("open file"), "", tr(""));//open dialog "openfile" } void mainwindow::on_pushbutton_clicked(){ qmessagebox msgbox; msgbox.settext("push button choose file"); //connect clicking button in msgbox action in openfile_bttn button qwidget::connect(&msgbox,signal(but...

ruby on rails - Why is 'FactoryGirl.lint' giving InvalidFactoryError? -

long time reader first time poster here on :) for last couple of days i've been setting factorygirl. yesterday changed factories (mainly user , brand factories) replacing: language.find_or_create_by_code('en') with: language.find_by_code('en') || create(:language) because first option creates language object code attribute filled in; while second uses language factory create object (and fills in attributes specified in factory) now when run test fails on factory.lint, stating user (and admin_user) factories invalid. reverting above code doesn't fix , stack trace provided factorygirl.lint pretty useless.. when comment lint function, tests run fine without issues. when manually create factory in rails console , use .valid? on it, returns true i'm @ loss why lint considers factories invalid. my user factory looks this: factorygirl.define factory :user ignore lang { language.find_by_code('en') || create(:langu...