Posts

Showing posts from June, 2015

Python NDB: Property validation in queries? -

i have model: def category_path_validator(prop , val): # makes sure path of form `first.second(...)last` # , represents valid path in category tree. pass class product(ndb.model): category_path = nsb.stringproperty(validator=category_path_validator) i want able products within category query is: product.query(ndb.and(product.category_path >= 'furniture' , product.category_path <= 'furniturez')) (adding z works since <=,>= compares strings lexicography ) now produces error because furniturez not valid category. is there way query value without validation , still able set property with validation ? i think best way split validation 2 parts. first part simplify validator check stringproperty : def category_path_validator(prop , val): # makes sure path of form `first.second(...)last` pass the second part add model hook : def _pre_put_hook(self): # makes sure category_path represents valid path...

How to consistently setup PHP-FPM 5.6 with nginx on Amazon EC2 AMI instance -

i cannot find way setup php-fpm on nginx on amazon ami ec2 instance scratch. know should not difficult, finding different answers based on *nix versions confusing. here condensed steps i've taken thought work, don't. have set of steps reliably setup php-fpm nginx in amazon ami ec2 instance? i've intentionally left out nginx.conf, etc post since "stock" installations default yum repositories. nginx version: 1.6.2 does have reliable steps setup php-fpm in nginx amazon ami ec2 instances? prefer setup myself instead of using ami in amazon marketplace charges setup. thanks # install packages yum install -y nginx yum install -y php56-fpm.x86_64 # enable php in nginx.conf vi /etc/nginx/nginx.conf # add index.php @ beginning of index index index.php index.html index.htm; # uncomment php block in nginx.conf location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_para...

iOS Objective-C blocks warning: Control reaches end of non-void function -

i trying use objective-c blocks. have method: - (void *)getobjectswithsuccess:(void (^)(nsarray *objectives))success failure:(void (^)(nserror *error))failure; { nsmutablearray *objects = [[nsmutablearray alloc] init]; nsstring *url = [url_constant]; nsdictionary *parameters = @{@"username" : username_constant, @"password" : password_constant}; afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager]; [manager post:url parameters:parameters success:^(afhttprequestoperation *operation, id responseobjects) { (id responseobject in responseobjects) { nsstring *title = [responseobject objectforkey:@"title"]; nsstring *description = [responseobject objectforkey:@"description"]; object *object = [[object alloc] init]; objective.title = title; objective.description = description; [objects addobject:obje...

javascript - Multiple markers Google Map API v3 from array of addresses using Angular Js -

Image
i have implement multiple markers functionality array of addresses using angular js. here fiddle : http://jsfiddle.net/cvsdp/175/ but i'm getting following error : uncaught error: [$injector:modulerr] failed instantiate module myapp can 1 please me. you can change jsfiddle setting onload no wrap - in <body> see working example: http://jsfiddle.net/cvsdp/179/ edit: also, change line map = new google.maps.map(angular.element(document.queryselector("#map_canvas")[0]), myoptions); to following: map = new google.maps.map(document.queryselector("#map_canvas"), myoptions); the working jsfiddle: http://jsfiddle.net/cvsdp/180/

Tao OpenGL C# Tab Not Rotate -

why opengl not rotating when placed @ tab bar? private void simpleopenglcontrol1_paint_1(object sender, painteventargs e) { gl.glclear(gl.gl_color_buffer_bit | gl.gl_depth_buffer_bit); gl.glmatrixmode(gl.gl_modelview); gl.glloadidentity(); gl.gltranslated(0, 0, -5); gl.glrotated(yrot += 1, 1, 1, 0); gl.glpointsize(3); gl.glpolygonmode(gl.gl_front, gl.gl_lines); gl.glpolygonmode(gl.gl_back, gl.gl_lines); gl.glbegin(gl.gl_quads); { ////vista posterior gl.glcolor3ub(255, 0, 255); gl.glvertex3d(0, 1, -1); gl.glvertex3d(1, -1, -1); gl.glvertex3d(-1, -1, -1); gl.glvertex3d(0, 1, -1); ////debajo gl.glcolor3ub(0, 255, 255); gl.glvertex3d(-1, -1, -1); gl.glvertex3d(1, -1, -1); gl.glvertex3d(1, -1, 1); gl.glvertex3d(-1, -1, 1); ////por la izqu...

reactjs - Is there a convention for Flux messages sent via the Dispatcher? -

i'm building first react front end , see number of conventions messages sent via dispatcher. e.g. { type: actiontypes.receive_raw_messages, rawmessages: rawmessages } https://github.com/facebook/flux/blob/master/examples/flux-chat/js/actions/chatserveractioncreators.js#l21 and { source: 'view_action', action: action } http://facebook.github.io/react/blog/2014/09/24/testing-flux-applications.html#putting-it-all-together what best message format use & why? the short answer is, doesn't matter—as long stores right data. use following format: { type: 'action_type', // defined constant payload: { ... } // payload of json serializable types } if app needs distinguish between actions initiated user , actions come server or other source, may considering adding source key; use separate action types or data within payload purpose. i make payload object (never raw value) data can added without changing receiving sites. exampl...

java - How to solve "Unreachable Statement" -

this android code.i have error in below line toast "unreachable statement" , know error come return of if don't know how solve it error part: do { return; if ((paramanonymous2int == 0) && (androidhtmlactivity.this.count == 4)) { toast.maketext(getapplicationcontext(),"نسخه رایگان",toast.length_short).show(); return; } } the whole function : @javascriptinterface public void savedialog(final string paramstring) { final sqlitedatabase mydatabase = openorcreatedatabase("copycollection", mode_private, null); object localobject = mydatabase.rawquery("select * details id=" + paramstring + ";", null); if (((cursor)localobject).movetofirst()) { { androidhtmlactivity.this.appname = ((cursor)localobject).getstring(1); androidhtmlactivity.this.txtclip = ((cursor)localobject).getstring(2); ...

cluster analysis - R warning - longer object length is not a multiple of shorter object length -

Image
this question has answer here: why “warning longer object length not multiple of shorter object length”? 2 answers i'm trying perform clustering on spatial data based on distance constrain cluster size. found article online, ( spatial clustering equal sizes ), , works small list of date 3 clusters. however, when tried run larger list , cluster them 30 clusters, doesn't work expected. clusters returns uneven again, below. i tried smaller data 30 cluster , example dataset, both worked out evenly. guess it's wrong data. i'm not sure how fix it. table( cl_constrain$cluster ) cluster 1 2 3 4 5 6 7 8 9 10 size 151 63 67 88 65 89 92 82 72 84 cluster 11 12 13 14 15 16 17 18 19 20 size 60 61 44 46 60 51 65 216 56 188 cluster 20 21 22 23 24 25 26 27 28 29 30 size 229 78 101...

CSS margin and padding not being applied -

so i've got list of items, separated border. i'd have equal padding , margin applied top , bottom of each item. here's fiddle contains simplified version of i'm working with. now, see, have 10px of margin , padding applied top , bottom of each item, items aren't evenly spaced. there's more space above each item below it. i realize result of css's collapsing margins behaviour , , fix adding more padding margin spacing want. the issue is, however, items, want highlight adding background colour, fiddle . , when do, padding on top , bottom must same. so how can fix issue? want super flexible, can customize amount of padding , margin if like, , able remove border still have display properly. html: <div class="list"> <div class="item"> <span class="fill">&nbsp;</span> </div> <div class="item"> <span class="fill">&nbsp;</span>...

javascript - How do I populate a list box on a textbox change event -

simple one, need please. need populate list box based on values of textbox. sample.aspx code below <div> <asp:textbox id="textbox1" autopostback="true" runat="server" ontextchanged="textbox1_textchanged"></asp:textbox> <asp:listbox id="listbox1" runat="server"></asp:listbox> </div> my sample .aspx.cs code below protected void page_load(object sender, eventargs e) { datalist("page"); } protected void textbox1_textchanged(object sender, eventargs e) { datalist(textbox1.text); } private void datalist(string value) { datatable dt = new datatable(); dt.columns.add("city", typeof(string)); dt.columns.add("country", typeof(string)); (int = 0; < 10; i++) { datarow dr = dt.newrow(); dr["city"] = i.tostri...

google chrome - CSS is producing a box shadow not a drop shadow -

Image
i have image below , have written code in external style sheet when rollover image creates drop shadow, creating box shadow. code using is: .pick:hover { -webkit-filter: drop-shadow(5px 5px 5px #222); filter: drop-shadow(5px 5px 5px #222); } where going wrong? the image posted isn't transparent png...of course shadow going shown around 'box-model'. here, ideal means of having hover-shadow have 2 images , toggle between them on hover. a real drop-shadow ( run snippet see effect ) :: .pick { width: 225px; height: 225px; background-image: url('http://i.imgur.com/ceyilod.png');-o-transition:.5s; -ms-transition:.5s; -moz-transition:.5s; -webkit-transition:.5s; } .pick:hover { background-image: url('http://i.stack.imgur.com/wqgbi.png')} <div class="pick"></div>

C++ Universal Unicodes -

i had quick question , couldn't find answer anywhere else. trying make universal function return proper unicode (instead of making literals) shown below in std::string getunicode() function. \xe2\x99\xa , cardtype being treated 2 separate strings in output, causes "?" followed cardtype number. in case: cout << "\xe2\x99\xa0"; //prints out symbol, cout << "\xe2\x99\xa" << 0; //prints out "?" followed 0. bad cout << card.getunicode(); //prints out "?" followed 0. bad any ideas? 4-6 month beginner c++. #ifndef card_h #define card_h #include <map> #include <sstream> #include <string> enum card_type {spade = 0, club = 3, heart = 5, diamond = 6}; class card { private: int number; card_type cardtype; public: card(card_type, int); void displaycard(); int getnumber() { return number; } card_type getcardtype...

c# - Show 2d-array in DataGridView -

i have 2d array. want print array in datagridview throws error: [argument outofrangeexception unhandled ] this code for (int j = 0; j < height; j++) { (int = 0; < width; i++) { datagridview1[i, j].value = state[i, j].h; //state[i, j].h array datagridview1[i, j].style.backcolor pixelcolor[i,j]; datagridview1[i, j].style.forecolor = color.gold; } } as comments have pointed out, should focus on rows , cells. need build datagridview columns , populate each row cell cell. the width of array should correspond dgv columns , height dgv rows. take following simple example: string[,] twod = new string[,] { {"row 0 col 0", "row 0 col 1", "row 0 col 2"}, {"row 1 col 0", "row 1 col 1", "row 1 col 2"}, {"row 2 col 0", "row 2 col 1", "row 2 col 2"}, {"row 3 col 0", "row 3 col 1", ...

core data - iOS/coredata/swipe to delete: Why is following code not working? -

i trying swipe delete work core data using following code not working. realize there 2 approaches in following when 1 needed can't work in case. appreciate if can spot wrong. in advance suggestions. //enables swipe delete - (void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath { // remove row data model //first approach if (editingstyle == uitableviewcelleditingstyledelete) { // delete object manageobjectcontext nslog(@"should deleting here");//this shows in log [self.managedobjectcontext deleteobject:[self.fetchedresultscontroller objectatindexpath:indexpath]]; nserror *error = nil; if (![self.managedobjectcontext save:&error]) { // handle error } } //second approach // delete item items *itemtodelete = [self.fetchedresu...

android - 9-patch padding doesn't adjust correctly -

Image
adding 9-patch: seems ok here: however, after adding android:padding="5dp" , padding doesn't happen around content. also, arrow stretches bit. 9-patch drawn incorrectly? textview: this ended doing it. guess adding background 9-patch directly textview doesn't work. wrap in framelayout <framelayout android:background="@drawable/notification_bg" android:layout_width="wrap_content" android:layout_height="wrap_content"> <textview android:id="@+id/tv_number_left" android:padding="2dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone"/> </framelayout>

python: IndexError: list index out of range (file = sys.argv[1]) -

if __name__ == "__main__": file = sys.argv[1] f = fst("q0") #f.addstate("1", true) #f.addstate("2", true) #f.addstate("3", true) in line file = sys.argv[1] getting error. can please me out. the sys.argv list populated when command line arguments script present. sys.argv[0] name of script running. sys.argv[1] first command line argument passed script. need call script like: python script_name first_arg

html - how to select special tag after another special tag with jquery -

i have html page <input> tag came after <span class="class1"> want select input tags disabled how can jquery selector? i'm test $('span.class1+ :disabled') , not work ! my html somthing this: <span class="class1"></span> <input type="text" disabled/> <span class="class1"></span> <input type="text"/> <input type="text" disabled/> i want select input first input (note: not third input) the other answers have no limit on when stop searching. process all siblings after each class1 span (regardless of span between them, should act "fences"). based on layout, want stop after hits next span, use nextuntil limit search , filter target required elements: $(document).ready(function(){ $('span.class1').nextuntil('span').filter('input:disabled').val('disabled text box') }); <script src=...

java - In-app purchase cause error -

i'm trying make in app purchase in application wrong. made tutorial: http://developer.android.com/training/in-app-billing/purchase-iab-products.html , stackoverflows solutions id didnt , i'm still getting error after run application: java.lang.illegalstateexception: iab helper not set up. can't perform operation: queryinventory caused response result_billing_unavailable it's happening after call method mhelper.queryinventoryasync(mgotinventorylistener); code oncreate in activity: mhelper = new iabhelper(this, string1 + string2 + string3); mhelper.enabledebuglogging(true); mhelper.startsetup(new iabhelper.oniabsetupfinishedlistener() { public void oniabsetupfinished(iabresult result) { if (!result.issuccess()) { log.d(tag, "problem setting in-app billing: " + result); } if (mhelper == null) return; log.d(tag, "setup successful. querying inventory."); ...

multithreading - Interrupting a thread in Python with a KeyboardException in the main thread -

i have few classes more or less this: import threading import time class foo(): def __init__(self, interval, callbacks): self.thread = threading.thread(target=self.loop) self.interval = interval self.thread_stop = threading.event() self.callbacks = callbacks def loop(): while not self.thread_stop.is_set(): #do stuff... callback in self.callbacks(): callback() time.sleep(self.interval) def start(self): self.thread.start() def kill(self): self.thread_stop.set() which using main thread this: interval = someinterval callbacks = [some callbacks] f = foo(interval, callbacks) try: f.start() except keyboardinterrupt: f.kill() raise i keyboardinterrupt kill thread after callbacks have been completed, before loop repeats. ignored , have resort killing terminal process program running in. i saw idea of using threading.event this post , appear...

Is there a compelling reason to use PHP's operator === in comparison operations, over ==? -

say have code: $str = '5'; $int = 5; for comparison, there reason use (with conversion): if ($int === intval($str)) //... or use native php facilities? if ($int == $str) //... to me, == looks simpler, perhaps @ expense of having php work me. using '==' tends lead subtle bugs - eg if 2 strings numbers, php not compare them strings, can give unexpected results - common/scary example is: <?php $actual_password = '240610708'; $provided_password = 'qnkcdzo'; // these presumably stored in database $stored_password_md5 = md5($actual_password); //0e462097431906509019562988736854; $stored_password_hash = password_hash($actual_password, password_default); $computed_password_md5 = md5($provided_password); //0e830400451993494058024219903391 var_dump($stored_password_md5 == $computed_password_md5); // bool(true) - bad! no! var_dump($stored_password_md5 === $computed_password_md5); // bool(false) - better, still no. vulnerable timing...

I want to use the htmlbody of a google sites page as a template for an email template, but I can't get it to find and replace -

i have been successful finding , replacing using document template, , can unmodified html email, no luck in being able find , replace content. should it, right? (i tried replacetext too, assume document thing)) don't error message or anything, script continues on next steps, don't replacement. var site = sitesapp.getpagebyurl(pageurl); var body = site.gethtmlcontent(); body.replace("{%organization%}", "organization") thanks (the thing replaced (in case {%organization%} within table on site if matters) try following line: body = body.replace("{%organization%}", "organization"); the string replace function not alter original string. instead, returns new string value. code above assign new value original body variable. for more information see link .

vb.net - Syntax Error OledbException delete statement -

i can't fugure out syntax error here. spot it? or going wrong? dim mycommand new oledb.oledbcommand("delete * team intplayerno='" & txtuniformno.text & "'_ strfirstname='" & txtfirstname.text & "'_ strlastname='" & txtlastname.text & "'_ strparentname='" & txtparent.text & "'_ straddress='" & txtaddress.text & "'_ strcity='" & txtcity.text & "'_ strstate='" & txtstate.text & "'_ strzipcode='" & txtzip.text & "'_ strphone='" & txtphone.text & "'_ intage='" & txtage.text & "'", myconnection) a delete statement delete team where... you best advised use parameterized queries avoid sql injection attacks

c# - My first attempt at an application framework using Entity Framework -

so i'm writing framework projects. this framework should take pt out of starting new projects providing generic foundation upon project built. the framework includes: a generic db context provided application database name generic data models include "common" data such user model email address , password property generic crud functionality generic data models so far feel i've got stuck on in attempt make dbcontext class generic possible. see below: public class dataentities : dbcontext { public string _databasename { get; set; } public string databasename { { if (string.compare(_databasename, string.empty, stringcomparison.invariantcultureignorecase) == 0) { return "lysdatabase"; } else { return _databasename; } } set; } public initializer _initializer { get; set; } public enum ini...

java - Query in <c:if test> condition in jsp -

in jsp, suppose have <div class = "x"> comes dynamically application. not in jsp gets called when particular condition satisfied in application. want apply <c:if> condition set of statements executed when div not created, can write condition such <c:if test = { ! div ="x"} . is right or suggest me else? maybe you've better load html before jsp , use jsoup library find div element selector? <c:if> looks request attributes instead of html markup. jsp div string. another solution - javascript.

vbScript - Arrays -

i new in vbscript , wondering if please advise: i trying loop single value in array. see following: dim reportesta(3) reportesta(0) = "report1" reportesta(1) = "report2" reportesta(2) = "report3" i wrote sub procedure follow: sub reporte1() each i=0 in reportesta posicionarcursor() ''this sub commkeys reportesta(0) next end sub it won't work , not sure doing wrong. other way though be: for i=0 0 posicionarcursor() ''this sub commkeys reportesta(0) next there 2 syntax loop through array: for each in reportesta ' code here next or one: for i=0 ubound(reportesta) ' code here next

json - Issues with Curl request in python -

i attempting simple json currency rate response api (oanda). receiving various error codes, such 'invalid syntax'. here updated code: import requests import json optparse import optionparser def connect_to_stream(): """ environment <domain> fxtrade stream-fxtrade.oanda.com fxtrade practice stream-fxpractice.oanda.com sandbox stream-sandbox.oanda.com """ # replace following variables personal ones domain = 'stream-fxpractice.oanda.com' access_token = 'xxxxxxxxxxxxxxxx' account_id = 'xxxxxxxxx' instruments = "eur_usd" try: s = requests.session() url = "https://" + domain + "/v1/prices" headers = {'authorization' : 'bearer ' + access_token, # 'x-accept-datetime-format' : 'unix' } params = {...

Exporting report to file using SQL Server Management Studio 2012 -

i have report run extract content of "description" field, transfer different system run program against file. previously, i'd export in comma or tab separated format. when try now, whether use tabs, commas or define own separator, when export data fields separated 5 spaces, not separator character. i'm doing this: tools -> options -> query results -> sql server -> results text i select either "comma delimited", "tab delimited" or "custom separator" (i tried using "%"), when run query & save file, doesn't contain separator value, spaces. how can fix this? thanks, david a details: sql server studio manager version 11.0.5058.0 os: windows 8.2 (64 bit) sql database version: 2008 r2 the "results text" option applied when choose seeing query results in text mode (results tab - ctrl + t). i looked way set custom delimiter "results text" (ctrl + shift + f) option could...

validation - Validate f:viewParam value to be one of a select set of allowable values -

i learning jsf 2.2 , having little trouble finding answer can understand how have more validation on parameter. i have source.xhtml file has link this: <h:link value="alter" outcome="/main/showsqltemplates.xhtml"> <f:param name="type" value="alter" /> </h:link> and in destination.xhtml have code looks this: <f:metadata> <f:viewparam id="type" name="type" value="#{showsqltemplatemanagedbean.type}" required="true" requiredmessage="invalid page access. please use link menu."/> </f:metadata> <h:message for="type" class="bold"></h:message> <br/>type : #{showsqltemplatemanagedbean.type} and bean class looks this: @managedbean @requestscoped public class showsqltemplatemanagedbean { string type = ""; public string gettype() { return type; } public void set...

debugging - cmake: how to build opencv in both debug and release mode? -

i using cmake gui 2.8 build opencv 2.4.10 on linux machine. want build both debug , release versions @ same time have 2 libraries /lib/debug , /lib/release. i notice opencv has parameter cmake_build_type don't know how enable both types. how configure cmake gui that? is not possible them @ same time. should configure 2 separate build directories, 1 debug , 1 release builds.

Java code containing ! In for loop -

how ! big in loop affects program.is there checking done between , big? public int numberofmoves(int size) { int power=2; int[] moves = new int[105]; int pocet = 0; boolean big=false; (int i=1;i<105&&!big;i++) { int num=1; (int j=0;j<power;j++) num*=i; if (num>size) big=true; else { moves[pocet]=num; pocet++; } } } ! negation operator, means !true == false , !false == true . in case, outer loop condition "loop while i<105 , big false "

Qt 5 C++ undefined reference to Class::function(QString, Qstring, ...) -

i know question has been answered in forum before, need more specific help. here's code: sessionwindow.cpp #include "sessionwindow.h" #include "ui_sessionwindow.h" #include "session.h" #include "utils.h" #include <qstringlist> sessionwindow::sessionwindow(qwidget *parent) : qdialog(parent), ui(new ui::sessionwindow) { ui->setupui(this); this->setfixedsize(this->size()); } sessionwindow::~sessionwindow() { delete ui; } void sessionwindow::on_cancelbtn_clicked() { close(); } void sessionwindow::on_createbtn_clicked() { qstring min = (ui->ismin) ? "min" : "nomin"; qstring sp = (ui->sphidd) ? "nosp" : "sp"; qstring name = ui->sessionname->text(); qstring user = ui->skuser->text(); qstring pass = ui->skpass->text(); utils u; u.createsession(name, user, pass, min, sp); } ...

Terminating a program using carriage return in C -

quesion: write c program accept line of text. store in array & write out backwards. allow length of line unspecified terminated carriage return assume not exceed 80 characters solution: #include <stdio.h> int main() { printf("\nenter sentence:\n"); char sent[80]; // creates array of length 80 int = 0; while((sent[i] = getchar()) != '\n') { i++; } sent[i] = '\0'; printf("the reversed sentence : "); for(i=i-1; i>=0; i--) { printf("%c", sent[i]); } getchar(); scanf("%c", &sent[i]); return 0; } is code correct? (i wondering carriage return part) what if enter 80 characters??? end putting '\0' @ sent[81], bad... sent[80] '\n' , sent[81] '\0' also not sure why do getchar(); scanf("%c",&sent[i]); at end of function. @ point -1.

java - How to change utf-8mb4 to UTF-8 in groovy? -

currently, have problem receiving string input user mobile. string inputed , contained utf8mb4 characters (smiley, emoji, etc). caused error in backend (mysql) since accepts utf-8 input. now, how can replace utf-8mb4 input utf-8? def utf8mb4string = '👳👳👳👳👳👳👳'; // parse utf8mb4string utf8 // logic here //possible utf8 result maybe: '�������' i have found similar question here how convert utf-8mb4 utf-8? no clear answer yet implementation in groovy. you can't store characters (like "man turban") outside basic multi-lingual plane (bmp) mysql's poorly-named "utf8" encoding. need specify "utf8mb4" instead. if don't care store characters, , want replace or discard them, you'd have iterate on string, , build new string (in java): intstream converted = utf8mb4string.codepoints().map(cp -> character.isbmpcodepoint(cp) ? cp : '\ufffd'); string str = converted.collect(stringbuilder::new, (b...

sql server - How does 12/30/9999 date in SQL work in a stored procedure? -

i'm reading stored procedure , noticed date parameter default 12/30/9999 , in condition. how work in stored proc? in parameter section.. alter procedure [dw].[sp_policydetail] @inforcedate date = '12/30/9999', @policyeffectivedatestart date = null, @policyeffectivedateend date = null, @underwriter_full_name varchar(100) = null, @branch_office_name varchar(100) = null in condition.. where p.line_of_business_cd= 'exp' , p.policy_status_cd<> 'tmp' , ( @inforcedate = '12/30/9999') or ( p.policy_status_cd= 'bnd' , p.policy_effective_dt<= @inforcedate , p.policy_expiration_dt > @inforcedate , p.cancellation_effective_dt > @inforcedate ) ) , (@policyeffectivedatestart null or (p.policy_effective_dt between @policyeffectivedatestart , @policyeffectivedateend)) , p.from_date <= @inforcedate , p.to_date > ...

java - Facebook OAuth redirect_uri Issue -

Image
i trying build authentication flow in our app facebook in java. using facebook4j library. my corresponding code follows - public string authenticate() throws ioexception { facebook facebook = new facebookfactory().getinstance(); string redirecturl = facebook.getoauthauthorizationurl("http://localhost:9099/default/facebook/verify.html"); servletresponse.sendredirect(redirecturl); return null; } public string verify() throws exception { string code = servletrequest.getparameter("code"); facebook facebook = new facebookfactory().getinstance(); accesstoken accesstoken = facebook.getoauthaccesstoken(code); string token = accesstoken.gettoken(); servletresponse.getwriter().write(token); return null; } i getting error after redirection on line - accesstoken accesstoken = facebook.getoauthaccesstoken(code); the error follows - facebookexception{statuscode=400, errortype='oauthexception', errormessage='redi...

javascript - AngularJS Resource not using ID on update -

i have pretty basic factory: app.factory('person', function($resource) { return $resource(api_route+'/people/:id.json', { id: "@id" }, { update: { method: "put" } }); }); it performs get request specified url expected, when tried update, goes /people.json instead of /people/:id.json . person.get({ id: personid }, function(person) { return $scope.person = person; }); $scope.person.$update() the response server logs: started put "/hr/angular/people.json" 128.104.86.165 @ 2015-04-14 14:12:30 -0500 actioncontroller::routingerror (no route matches [put] "/angular/people.json"): i tried different way of doing update command got same response. person.update($scope.person, function(person) { console.log($person); }); if hardcode id resource path, $resource(api_route+'/people/1234.json') , i'm able expected actions on individual, including update. don't see i'm missing allow get ...

Should Java POJO have field validation and throw exceptions in setter methods? -

let's have tens of java pojos represent domain, is, data in system flows objects between different layers of system. system may web application, or simple desktop application. domain consists of doesn't matter. when designing system, confused should put validation logic. pojos ( domain objects ) represent data, , of fields inside of objects must adhere criteria, if put lot of validation logic inside setter-methods, way tell calling client throw exception. , if don't want system crash, exception must checked exception must caught , handled. consequence of each , every time create new object using setter-methods (or constructors), have either re-throw exception or use try-catch block. doesn't feel right forced use try-catch on many setter-methods. so question should put validation logic, don't clutter code lot of boilerplate try-catch blocks , rethrows. finest java byte eaters welcome join discussion. i have researched , googled, not found specific discussio...

c# - Can I stream a file to a SQL Server stored procedure? -

i have file on remote machine want 'copy' sql server host machine specific area. i'm wondering options doing through sql server stored procedure, , more want stream file contents, not reading entire contents memory first. i'm looking streamed version of this: create procedure [dbo].[savefile] (@filename nvarchar(255), @contents nvarchar(max)) begin declare @objecttoken int exec sp_oacreate 'adodb.stream', @objecttoken output exec sp_oasetproperty @objecttoken, 'type', 1 exec sp_oamethod @objecttoken, 'open' exec sp_oamethod @objecttoken, 'writetext', null, @contents exec sp_oamethod @objecttoken, 'savetofile', null, 'c:\\destination\\' + @filename, 2 exec sp_oamethod @objecttoken, 'close' exec sp_oadestroy @objecttoken end can have filestream or equivalent stored procedure input parameter? have clr stored procedure handle stream? perhaps 1 procedure open stream , re...

javascript - isotope height not calculated right tablet -

so problem: i'm using isotope , i'm having height issue. doesn't calculate correct height on tablet/ipad - gets crumbled @ top). desktop , smartphones working fine. this code isotope: $(window).load(function() { var $container = $('.isotope').isotope({ itemselector: '.item', layoutmode: 'masonry', transitionduration: '0.7s' }); $('.isotope-filters').on('click', 'a', function () { var filtervalue = $(this).attr('data-filter'); $container.isotope({ filter: filtervalue }); // active state var active = $(this), activeclass = active.data('filter'), parentfilters = active.closest('.isotope-filters'); if (active.hasclass('selected')) { return false; } parentfilters.find('a').removeclass('active');...

MySQL - Trigger - Before Insert and using the SK (Auto Increment) -

i have simple posts table in mysql has post_id sk (surrogate key). replies original post id stored in same table in parent_post_id column, want perform following logic: before insert (i think ...) if parent_post_id has not been defined on insert, default row value newly generated post_id (from auto-int sequence) if parent_post_id has been defined on insert, set whatever has been passed. example post_id | parent_post_id | date_time | message 12 12 2015-04-14 21:10 new post (start of thread) 13 12 2015-04-14 21:12 reply post id 12 the answer here: https://stackoverflow.com/a/11061766/1266457 looks might need do, although not sure it's doing. thanks. for before insert trigger can not last inserted primary key , other way of doing max value table , increment it. here way it delimiter // create trigger posts_before_ins before insert on posts each row begin declare last_id int; if new.parent_post...

Remove duplicated row from datagridview c# -

i want unique rows. loop should check rows in datagridview , see if matches text textbox, if not, add value textbox datagridview. problem: first row works, loop iterate through first row in datagridview, why wont continue through other rows? private void laggtill_click(object sender, eventargs e) { bool dublett = false; foreach (datagridviewrow r in datagridview1.rows) { if(r.cells[0].value.tostring() == txtnamn.text) // txtnamn textbox { dublett = true; messagebox.show("varan finns redan, gör om!"); } break; } if(dublett == false) { datarow dr; dr = dt.newrow(); dr["namn"] = txtnamn.text; dr["pris"] = txtpris.text; dr["v...

jquery - JavaScript onClick does not work in Firefox -

i have confirmation popup opens when user clicks on link: <a onclick="openpopup('#popup1')">foo</a> here relevant javascript: function openpopup(id) { $(id).show(); event.preventdefault(); $(id).addclass('is-visible'); $(id).css("z-index", "999999999999999999999999"); } in safari , chrome works fine. in firefox, however, trigger not seem work. ideas why? i tried change link so: <a href="javascript:openpopup('#popup1');">foo</a> no changes though. help! in firefox, however, trigger not seem work. ideas why? firefox not make event object global. have pass along event handler, e.g. onclick="openpopup('#popup1', event)" since using jquery, should bind handler jquery can use jquery's augmented event object.

cobol - File status 23 on READ after START -

my question pertaining file status 23, according microfocus means upon attempt read .dat file: "indicates no record found." or "indicates duplicate key condition. attempt has been made store record create duplicate key in indexed or relative file or duplicate alternate record key not allow duplicates." i have eliminated fact latter issue because i'm allowing duplicates in case. the reason i'm stumped i'm using start navigate record inside of .dat file, , when execute read after start has positioned file pointer, file status 23. here code: 900-get-inst-id. open input inst-mst. move fall-in-inst inst-name-rec. start inst-mst key equal inst-name-rec invalid key display "record not found" not invalid key read inst-mst move inst-id-rec ws-inst-id end-start. close inst-mst. so when running code start runs , goes not invalid key ...