Posts

Showing posts from June, 2010

php - SMTP response code 530 returned by Amazon SES -

i trying send email through amazon ses smtp interface with php referring link : aws ses smtp interface php it giving error of authentication failure . [smtp: invalid response code received server (code: 530, response: must issue starttls command first)] just inform, have moved out the amazon ses sandbox, , have sender email verified. how should deal response code? this worked me. try adding following enviornment variables: aws_access_key_id variable name , your access id variable value and, aws_secret_access_key variable name , your access key variable value

javascript - Best way to validate long list of random postal codes -

i have long list of postal codes have validate. link postal codes as can see it's quite random there no real order. i tried making switch , put in hand so: switch (true) { case ($(this).val().length < 5) : console.log("not filled out"); break; case (number >= 1001 && number <= 6999): validated = true; error = false; break; case (number >= 8001 && number <= 34999): validated = true; error = false; break; case (number >= 36001 && number <= 37999): validated = true; error = false; break; default: console.log("error");

bash - svnnotify html color diff -

i'm using svnnotify send notification email upon commits. have following script on repo's hooks/post-commit : #!/bin/sh repos="$1" rev="$2" address in $(/bin/cat /var/svn/teachbyapp/hooks/addressee.list) /usr/local/bin/svnnotify \ -r $rev \ -c \ -d \ --diff-encoding utf8 \ -h html::colordiff \ -p $repos \ -t "$address" \ --from svn@factory.e-levelcom.com done it works balck , white diff (no colors @ all). added lines underlined whereas removed lines have strike-through format. nothing else, no color @ all. how can colored diff? this ok found it. thanks this work also needed append --css-inline option svnnotify command in script

scala - Sample Spark Program -

hi i'm learning spark , scala have 1 scenario need come sparkscala code input file name attr1 attr2 attr3 john y n n smith n y n expected output john attr1 y john attr2 n john attr3 n smith attr1 n ... ... i know how in map-reduce for each line name sepearately , iterate through attr values , emmit output (name, attrx y/n) in scala , spark bit confusing, can 1 me? assume know number of input attributes, , input attributes separated \t , this: in java // load data file javardd<string> file = jsc.textfile(path); // build header rdd javardd<string> header = jsc.parallelize(arrays.aslist(file.first())); // subtract header have real data javardd<string> data = file.subtract(header); // create row rdd javardd<row> rowrdd = data.flatmap(new flatmapfunction<string,row>(){ private static final long serialversionuid = 1l; @override public iterable<row> call(string line) thr

array difference - PHP array_diff output -

Image
i using array_diff correctly compare 2 arrays. in documentation, says output this: array ( [1] => blue ) as can see, each output come in single line. but when try it, shows me output in 1 line. maybe can little friendly, because have 4 rows compare, i'm supposed have, in future, hundreds of them. how solve this? you can "pretty print" array: echo "<pre>"; print_r($myarray); echo "</pre>";

django - Use a validator to modify/save a Field instead to raise an error -

in field of django model want user type dot ('.') @ end of textfield. otherwise want add it. i've thought using validator seems it's not proper way it: name = models.textfield(validators=[validate_dot]) def validate_dot(value): if value: if value[-1] != '.': return value + '.' whay need change value of textfield (if required) not raise error. what best approach achieve it? you can override save() method on model. def save(self, *args, **kwargs): if not self.name.endswith("."): self.name = self.name + "." super(model, self).save(*args, **kwargs)

ignore returned value procedure/function VHDL -

i have several functions , procedures in vhdl package. wanted ask if there way of ignore out items of these. know open keyword port maps. using dummy signals assigned procedure out. might more efficient way this. ¿is there such thing vhdl? if set out signals open following error: "formal e5 of mode out must have associated actual" thanks in advance, antonio edited: code procedure reg2ind (signal reg : in std_logic_vector(15 downto 0); signal e1,e2,e3,e4,e5,e6,e7,e8 : out std_logic; signal e9,e10,e11,e12,e13,e14,e15,e16 : out std_logic) begin e1 <= reg(0); e2 <= reg(1); e3 <= reg(2); e4 <= reg(3); e5 <= reg(4); e6 <= reg(5); e7 <= reg(6); e8 <= reg(7); e9 <= reg(8); e10 <= reg(9); e11 <= reg(10); e12 <= reg(11); e13 <= reg(12); e14 <= reg(13); e15 <= reg(14); e16 <= reg(15); end reg2ind; when use it: reg2ind(val183,ord_p.err.err_17,ord_p.err.err_18, ord_p.err.err_19,ord_

java - Android submenu: how to go back to previous submenu (or to main menu from submenu) -

beginner trying organize menu... have problem implement "back"-option in submenus. expect lead user automatically main menu. couldn't find solution. did has same challenge before? i use xml context menu: <item android:icon="@android:drawable/ic_menu_sort_by_size" android:title="menu" android:id="@+id/main_main_menu" app:showasaction="always"> <menu> <item android:id="@+id/goto_main_menu" android:orderincategory="1" android:title="@string/action_goto" android:icon="@android:drawable/ic_menu_directions"> <menu> <item android:orderincategory="1" android:title="new measurment" android:icon="@android:drawable/ic_menu_add"/> <item a

file io - Why does fread() in c read extra '#newlines' characters? -

while trying copy file string using fread() ,i getting characters file equal number of new lines. here code: #include <stdio.h> #include <stdlib.h> #define len 5000000 int main() { char *in = (char*) malloc(len); file *f=fopen("in.txt","r"); fread(in,5000000,1,f); printf("%ld\n", ftell(f)); in[ftell(f)]=0; int l; for(l=0;true;l++) { if(in[l]<10) break; printf("%d ",in[l]); } printf("\n"); } input program is: 1 2 <newline> link input : https://paste.fedoraproject.org/388281/46780193/ output printing ascii values of characters read: 6 49 10 50 10 13 10 if input is: 1 2 3 <newline> link input: https://paste.fedoraproject.org/388280/ output is: 9 49 10 50 10 51 10 51 13 10 i saw other test cases.in every test case number of characters number of new lines. have few questions: -why pattern this? -how this related f

How to setup AWS Opsworks in demon mode -

in aws opsworks, how can setup opsworks client or chef client in demon mode. in chef server can mention --demon option , run chef-client. but, in opsworks how can achieve this? opsworks works via chef 0 (aka chef client in local mode) , , such there's no chef server. when need make change custom cookbook: push custom cookbook repository. (or maybe refer cookbook in berksfile, whatever). after you've published changes way, need run update cookbooks have instances download new cookbooks. that doesn't mean cookbooks run then. when they're run depend on when recipes run in opswork event lifecycle .

ios - How to call to an extension from another viewcontroller in swift? -

i have extension in 1 view controller. extension uiviewcontroller { func hidekeyboardwhentappedaround() { let tap: uitapgesturerecognizer = uitapgesturerecognizer(target: self, action: #selector(uiviewcontroller.dismisskeyboard)) view.addgesturerecognizer(tap) } func dismisskeyboard() { view.endediting(true) } } can call extention within viewcontroller . if how can it? please me. thanks it's simple. in other view controller write self.hidekeyboardwhentappedaround() self.dismisskeyboard() any extension have defined instantly available instance of class have extended.

pdf generation - How to create PDF using PdfSharp which includes grid and images using c# -

i want generate pdf report of invoice page includes telerik grids, images etc controls , want create pdf these controls. if can provide demo great. one more thing in pdf generate code labels have specify perfect x-axis , y-axis. there way pdfsharp render labels aumatically? thanks in advance.

continuous deployment - How to deploy via FTP a website using BitBucket Pipelines -

i tried many times execute continuous integration via bitbucket pipeline (beta). moment need simple task, update remote server when push made on repository (in past used purpose codeship similar syntax). in pipelines necessary set file called bitbucket-pipelines.yml contains several rows differentiate between branches, etc. main instruction is: - lftp -c "open -u $ftp_user,$ftp_password ftp.mydomain.com; set ssl:verify-certificate no; mirror -rne /opt/atlassian/bitbucketci/agent/build /clone/ /public_html/dev" unfortunately not run correctly because failed (apparently infinite loop , new attempts). i tried discuss topic support did not recieve useful , in final message, suggested me other resources. maybe, there set succesfully similar things? thanks if git push want, try this. image: samueldebruyn/debian-git pipelines: default: - step: script: - echo "pipeline init" - apt-get update

jquery - Click events not working for marker attached to the line end -

i have below code. consists of line marker attached end. wrote on click event line , marker. when click marker element click event not working , css properties cursor types not setting up. how write click events marker element , apply css properties? $("#line12").on("click",function() { alert("hai clicked line") }) $("#arrow").on("click",function() { alert("hai clicked line") }) #line12 { cursor:pointer; } #arrow { cursor:pointer; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <svg width="600px" height="200px"> <defs> <marker id="arrow" markerwidth="10" markerheight="10" refx="0" refy="3" orient="auto" markerunits="strokewidth"> <path d="m0,0 l0,6 l9,3 z" fill="#000" /> </m

Need to pull Jpg or Png files from a URL in Java -

i have been tasked write quickie reusable program in java pull 1000 jpg or png files url. not expert on java , frankly don't have time needed research. not asking write me point me @ best method java 7 or 8. looked @ past questions , found many different methods , several years old thought see if better way may available now. it should simple as try { image image = imageio.read(new url("www.example.com/image.png")); } catch (exception e) { // handle exception }

python 3.x - How to embed 'QScintilla' code editor in self-made PyQt GUI? -

Image
i'm making small ide - fun! write in python, , use pyqt5 library build gui. here screenshot of current status: the code editor simple qtextedit() widget - embedded in qframe() widget, embedded in main window. parent child relationship follows (just bit simplified): qmainwindow( ) >> qframe( ) >> qtextedit( ) i implemented basic syntax highlighting, using qsyntaxhighlighter() class pyqt5. that's great - not yet awesome. mr. bakuriu advised me take @ qscintilla package. struggle several questions: question 1: installing qscintilla this pyqt documentation can find qscintilla2: http://pyqt.sourceforge.net/docs/qscintilla2/ . apparently on windows need download source code of qscintilla2 , build dll -file. isn't there more convenient way? example, pre-built packages (with installer)? i found download page: http://www.scintilla.org/scintilladownload.html . download page mentions: <<there no download available containing

android - arrayList becomes null after response in jsonArrayRequest -

error: in backgroundtask data in arraylist in try block,but after when reach after errorlistener(), arraylist becomes null. in logcat found these problem.how solve problem..?? package com.example.rahul.volley_jarray; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.support.v7.widget.linearlayoutmanager; import android.support.v7.widget.recyclerview; import android.util.log; import java.util.arraylist; public class displaylist extends appcompatactivity { recyclerview recyclerview; recyclerview.adapter adapter; recyclerview.layoutmanager layoutmanager; arraylist<contact> arraylist=new arraylist<>(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_display_list); recyclerview= (recyclerview) findviewbyid(r.id.recylerview); layoutmanager=new linearlayoutmanager(this); recyclerview.

java - How to setup TLS Server to authenticate client in spring integration? -

refer running client ssl/tls . explains scenario server client authentication. using spring integration process tls connections. spring-context file is: <bean id="sslcontextsupport" class="org.springframework.integration.ip.tcp.connection.defaulttcpsslcontextsupport"> <constructor-arg value="file:keystore.jks"/> <constructor-arg value="file:truststore.jks"/> <constructor-arg value="keystorepass"/> <constructor-arg value="trustpass"/> </bean> <int-ip:tcp-connection-factory id="crlfserver" type="server" port="${availableserversocket}" single-use="true" so-timeout="10000" using-nio="false" ssl-context-support="sslcontextsupport" /> my server accepting ssl connections , processing certificat

c++ - Recursion to generate permutations -

i find recursion, apart straight forward ones factorial, difficult understand. if want print permutations of string, lets string length 5, "abcde" , permutations of length 7 should be abced abdce abdec abecd abedc acbde acbed acdbe acdeb acebd acedb adbce adbec adcbe adceb adebc adecb aebcd aebdc aecbd aecdb aedbc aedcb bacde baced badce badec baecd baedc bcade bcaed ... if want recursion calculate permutation of factorial of 5 , 4 , 3 , 2 or 1 . algorithm should use? there function in c++ library this? assume printout should this: acbd bcad abc bac ab ba using recursion algorithm, pretty mathematical induction . first need deal base case, , find sub-problem pattern. for factorial, define problem f(n) factorial of n . base case, f(0)=1 sub-problem pattern, f(n)=n!=n*(n-1)!=n*f(n-1) and permutations, define p(e) permutation of set e . base case, p({}) = {{}} sub-problem pattern. consider process of permutation, let's have chosen first e

android - Create dynamic textview resource id to save the value in php server -

create dynamic id save value in php server. every time should create new textview id, value , save php mysql db. after clicking on addvip button , creating new textview value personadd.setonclicklistener(new onclicklistener(){ @override public void onclick(view arg0) { layoutinflater layoutinflater = (layoutinflater) getbasecontext().getsystemservice(context.layout_inflater_service); final view addview = layoutinflater.inflate(r.layout.personrowdetail, null); textview textout = (textview) addview.findviewbyid(r.id.textout); textout.settext(peoplehighpostionname.gettext().tostring() + "," + peoplehightpostionpostion.gettext().tostring()); textout.setid(r.id.textout); peoplehighpostionname.settext(""); peoplehightpostionpostion.settext(""); button buttonremove = (button) addview.findviewbyid(r.id.remove); buttonremove.setonclicklistener(new onclicklistener() {

reactjs - React Native Custom Android Keyboard -

i'm trying feasibility test building custom android keyboard using react native. has had success this? i've come across ios, i'm unable find similar android: https://github.com/sahlhoff/react-native-keyboard-template i realize custom keyboard ios, througt custom textinput weak custom keyboard, think principle same, hope you. react-native-custom-keyboard-ios

string - Efficient Data Structure For Substring Search? -

assume have set of strings s , query string q. want know if member of s substring of q. (for purpose of question substring includes equality, e.g. "foo" substring of "foo".) example assume function want called anysubstring : s = ["foo", "baz"] q = "foobar" assert anysubstring(s, q) # "foo" substring of "foobar" s = ["waldo", "baz"] assert not anysubstring(s, q) is there easy-to-implement algorithm time complexity sublinear in len(s) ? it's ok if s has processed clever data structure first because querying each s lot of q strings, amortized cost of preprocessing might reasonable. edit: clarify, don't care which member of s substring of q, whether @ least 1 is. in other words, only care boolean answer. i think aho-corasick algorithm want. think there solution simple implement, it's karp-rabin algorithm .

Activity NoClassDefFoundError using Android Studio -

note : not missing class in jar, don't rush mark duplicate. i'm porting big project eclipse android studio . succeeded see splashactivity on screen, fail mainactivity launched after splashactivity. i'm getting following error on runtime: > 06-13 14:42:30.176 12389-12389/com.totalboox e/androidruntime: fatal > exception: main process: com.totalboox, pid: 12389 > java.lang.noclassdeffounderror: com.androidcore.android.main.mainactivity$4 > @ com.androidcore.android.main.mainactivity.<init>(mainactivity.java:587) > @ java.lang.class.newinstance(native method) > @ android.app.instrumentation.newactivity(instrumentation.java:1067) > @ android.app.activitythread.performlaunchactivity(activitythread.java:2317) > @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) > @ android.app.activitythread.-wrap11(activitythread.java) > @ android.app.activitythread$h.handlemessage(activitythread.java:13

python 3.x - How to use a while loop to make code continue? -

sorry, tried researching while loops , examples found didn't me much. having hard time understanding concept outside of peoples examples. new python , tutorials use while loop in different scenario. here code: # guess number game. import random # ask user name print ('hello. name?') name = input () # ask user if play game. # if user confirms, game continues # if user denies, game ends print ('hi ' + name + ' nice meet you.') print ('would play game me?') answer = input() confirm = ['yes', 'yes',' y', 'y', 'yea', 'yea', 'yeah', 'yeah', 'yup', 'yup'] deny = ['no', 'no', 'n', 'n', 'nope', 'nope', 'nah', 'nah'] if answer in confirm: print ('great! let\'s started!') elif answer in deny: print ('i sorry hear that. maybe next time? goodbye') + exit() print ('i thinking of numb

javascript - How to make an arrow move across the canvas? -

Image
i need animate arrow 1-5 in following order (please see attached image) eg: arrow 1 move point 1 point 2 arrow 2 move point 2 point 3 ... until arrow 5. please see: i required use through jquery , html5 canvas. hope here can me this. it's complex me have no expertise in jquery animation. have no idea start, i've been stuck on 3 weeks , can't seem proper reference. appreciate in advance. you've spent 3 weeks fighting task...ouch! here's step-by-step tutorial showing how manage it. since you're in learning mode, leave out demo can learn assembling pieces. leave arrow-tail learning experience. luck project! calculate useful values path between p1 & p2 create points p1 & p2 want animate arrow-line along: var p1={x:0, y:100}; var p2={x:100, y:0}; calculate deltax & deltay representing vector between starting & ending points of current path (p1 p2): // calculate deltax & deltay of line between point p1 &

visual c++ - C++ Access violation when using SDL_ttf with SDL and SDL2 -

i using sdl2_ttf sdl2 (in visual studio 2015). when tried run following code, #include "sdl.h" #include "sdl_ttf.h" int main(int argc, char* args[]) { sdl_init(sdl_init_everything); ttf_init(); sdl_window* window; sdl_renderer* renderer; sdl_createwindowandrenderer(1600, 900, sdl_window_opengl, &window, &renderer); ttf_font* font = ttf_openfont("comic.ttf", 12); sdl_color color = { 0, 0, 0, 255 }; sdl_surface* textsurface = ttf_rendertext_solid(font, "asdf", color); sdl_texture* texture = sdl_createtexturefromsurface(renderer, textsurface); ttf_quit(); sdl_quit(); return 0; } i got "sdl.dll missing" runtime error. put sdl.dll, alongside sdl2.dll, libfreetype-6.dll, sdl_ttf.dll, zlib1.dll , other libraries in system32 folder, solved runtime error, instantaneously ran error: "unhandled exception @ 0x000000006c812e39 (sdl2.dll) in mcp2016.exe: 0xc0000005: access viola

wpf - FSC: error FS2024: Static linking may not use assembly that targets different profile with oxyplot example and FsXaml -

i'm using oxyplot fsxaml , gjallarhorn . works when using directly , binding output datapoint(x,y). when try following example simpledemofsharp : type mainviewmodel() = let mymodel = plotmodel() mymodel.series.add(functionseries(cos, 0.0, 10.0, 0.1, "cos(x)")) member mainwindow.mymodel get() = mymodel the build fails fsc: error fs2024: static linking may not use assembly targets different profile. error appears caused line: mymodel.series.add(functionseries(cos, 0.0, 10.0, 0.1, "cos(x)")) , if uncomment project compiles. have tried targetting lower .net versions, , creating fresh projects without success. there workaround? search appears maybe caused pcl profile issues. the example on own compiles , works (i.e. no other nuget packages installed oxyplot , oxyplot.wpf). edit: after further testing issue appears coming combination of fsxaml , oxyplot. example, when trying load mainwindow.xaml via fsxaml. the fsc.exe command

How to get Web Content by Structure name in Liferay Portlet? -

i need web content created specific structure in jsp portlet. i try use structurename throw excepcion classloader cl = portalclassloaderutil.getclassloader(); dynamicquery dynamicquery = dynamicqueryfactoryutil.forclass(journalarticle.class, cl) .add(propertyfactoryutil.forname("structurename").eq("empresa")); list <journalarticle> journalarticles = journalarticlelocalserviceutil.dynamicquery(dynamicquery); how web content structure? you need use structureid field when query journalarticles , passing structurekey value way dynamicquery dynamicquerystructure = dynamicqueryfactoryutil.forclass( ddmstructure.class).add(propertyfactoryutil.forname("name").like( "%>empresa</name>%")); list<ddmstructure> structures = ddmstructurelocalserviceutil.dynamicquery(dynamicquerystructure, 0, 1); if(!structures.isempty()) { string structurekey = struct

parsing - Pattern Matching in dypgen -

i want handle ambiguities in dypgen. found in manual, want know, how can use that. in manual point 5.2 "pattern matching on symbols" there example: expr: | expr op<"+"> expr { $1 + $2 } | expr op<"*"> expr { $1 * $2 } op matched "+" or "*", understand. find there: the patterns can caml patterns (but without keyword when). instance possible: expr: expr<(function([arg1;arg2],f_body)) f> expr { action } so tried put there other expressions, dont understand, happens. if put in there printf outputs value of matched string. if put in there (fun x -> printf x) , seems me same printf , dypgen complains syntax error , points end of expression. if put printf.printf in there, complains syntax error: operator expected . , if put there (fun x -> printf.printf x) says: lexing failed message: lexing: empty token these different error-messages mean? in end in hashtable, if value in there, don't know

c - Linked list prints extra 0 at the beginning -

i have basic singly linked list implementation. problem implementation, however, prints 0 @ beginning of list whereas not explicitly allocating storage node. code same below - #include <stdio.h> #include <stdlib.h> #include <assert.h> #define len 7 /* list node data structure */ typedef struct _ll_node_ { int data; struct _ll_node_ *next; } node; /* * @brief utility print state of list */ void print_list(node *head) { int = 0; node *tmp = head; while (tmp) { printf("node:\t%d,\tvalue:\t%d\n", ++i, tmp->data); tmp = tmp->next; } printf("\n"); } /* * @brief utility add nodes list */ node *add_node(node *head, int data) { node *tmp; if (head == null) { head = malloc(sizeof(node)); assert(head != null); head->data = data; head->next = null; } else { tmp = head; while (tmp->next) tmp = tmp-&

python - Adding items from a text file to QlistWidget in pyQt5 -

i've been working on code part of school project , don't seem getting anywhere. problem when try add text file qlistwidget program crashes. firstly want know if add files @ directory (each line in moviedir.txt directory) qlistwidget, secondly i'm not sure if i'm using right widget or if should qlistview. how make selected item in listwidget shows details in text box (e.g. size of file). i'm looking done on start if can please tell me the additems(self) appreciated. i'm new using classes have been neglected taught in school. i'm running pyqt5 on windows 7 # -*- coding: utf-8 -*- # form implementation generated reading ui file 'input.ui' # # created by: pyqt5 ui code generator 5.6 # # warning! changes made in file lost! pyqt5 import qtcore, qtgui, qtwidgets class ui_mainwindow(object): def setupui(self, mainwindow): mainwindow.setobjectname("mainwindow") mainwindow.resize(764, 500) mainwindow.setmini

android - Format JSON Body for Retrofit from single string value without model -

is there way turn single string value (plain text, not json) json body annotation? not want create such simple model. example @post("foo/{fooid}/bars") observable<void> postbar(@path("fooid") string styleid, @body barmodel bar); class barmodel { public string bar; } will give me expect: { "bar" : "hello world" } is there simple way annotation? this: @post("foo/{fooid}/bars") observable<void> postbar(@path("fooid") string styleid, @body("bar") string bar); retrofit has converter.factory abstract class can use custom http representation. can create converter construct okhttp.requestbody if method has specific annotation. the end result like: @post("/") call<void> postbar(@body @root("bar") string foo) and transform: postbar("hello world") { "bar" : "hello world" } . let's started. step 1 - create anno