Posts

Showing posts from August, 2010

Docx4j v3 Docx to HTML with Images -

i'm working convert docx html using docx4j version 3. the document contains white space consisting of tabs, spaces , newlines. resulting html either has unrecognized characters or not preserve whitespace @ all. the java code i'm using is: wordprocessingmlpackage wordmlpackage = docx4j.load(is); htmlsettings htmlsettings = docx4j.createhtmlsettings(); htmlsettings.setimagedirpath( system.getproperty("user.dir") + uploadedimagesdirectory ); htmlsettings.setwmlpackage(wordmlpackage); docx4j.tohtml(htmlsettings, out, docx4j.flag_export_prefer_xsl); string result = ((bytearrayoutputstream)out).tostring(); how can preserve whitespace in document. also, there method apply css particular node? specifically, have 3 images should evenly spaced horizontally on page. i've looked on documentation , searched online no success. thank you. i resolved issue , not related docx4j. docx4j parsed document perfectly! problem related sending output in email.

c# - .NET Assembly .DLL encryption and usage in teams -

i have relatively large c# project. want allow other developers collaborate me on project. i'm afraid copy source code verbatim. want protect code. there way grant collaborators usage of existing .dll's w/o them able read source code? or grant them temporary access .dll's , later when roll off project disable ability use .dll? absolutely, can give other people dlls without access source code. in situations this, obfuscate dll (many tools this, start dotfuscator included visual studio) can't decompile it. if want them able see source, there isn't can avoid them copying it, same "disabling ability use it". if have copy of file, there isn't can stop them doing (technologically speaking). security can think of have public functions check against server before executing (thus making dll useless if have server not allow them run), isn't 100% , make terrible experience end-users of code.

Ruby on Rails 4: New action in modal -

in index view have list of models , "create new" button. when user clicks on button modal form should presented 1 field: name of model - field required create model. when user enters name , click submit button model saved , edit view displayed normal page ( fields model available editing). how achieve this? have tried build new object in index action: def index @my_models = mymodel.all @new_model = mymodel.build end but did not work (i getting missing template error although without @new_model index displayed without problems) another question how render form? should put form new.html.erb file , include <%= render 'new' %> in body of modal? (i using bootstrap 3.1 create modal itself)? you can use @my_model = mymodel.new and call <%= render 'form' %> which uses @my_model.

c# - Automapper pass ForMember(s) as argument -

is there way can this? public void createmap<t, i>(??? formember) { mapper.createmap<t, i>().formember(formember); } i'm trying pass formember argument method can attach map. here possible way it: given 2 classes internal class exampleclass { public string name { get; set; } } internal class otherexampleclass { public string othername { get; set; } } define following function private static void createmap<from, to> (expression<func<from, object>> fromexpression, expression<func<to, object>> toexpression) { mapper.createmap<from, to>() .formember(toexpression, opt => opt.mapfrom(fromexpression)); } and call passing lambdas directly: createmap<exampleclass, otherexampleclass>(fromclass => fromclass.name, toclass => toclass.othername); the imappingexpression (the type returned formember method) not should use.

Gradle war ignores transitive dependencies when using 'configurations.runtime.asPath' in custom task -

i'm facing behavior can't explain, using gradle 1.10 have: settings.gradle: include('lib1', 'lib2', 'web') build.gradle: subprojects { apply plugin: 'java' } project(':web') { apply plugin: 'war' dependencies { compile project(':lib1') } task mytask(type: javaexec, dependson: 'compilejava') { main = "some.thirdparty.class" args "--searchpath", configurations.runtime.aspath } } project(':lib1') { dependencies { compile project(':lib2') } } project(':lib2') { } when run gradle clean war have lib1.jar in war/build/libs/web.war/web-inf/lib . to make web-inf/lib contain both lib1.jar , lib2.jar have to: move project('web') block end of file update configurations.runtime.aspath configurations.runtime (but need provide class path path, not solution) i read build lifecycle description, tried comp

java - Sort HashMap keys and store in ArrayList -

i need task of sorting hashmap keys string , store them in arraylist . have written below piece of code public static list<string> getsortedlistbykeys(hashmap<string,string> keysdictionary) { list<string> sortedkeyslist = null; sortedset<string> sortedkeysset = null; if(keysdictionary == null || keysdictionary.size() == 0){ return null; } sortedkeysset = new treeset<>(keysdictionary.keyset()); sortedkeyslist = new arraylist<>(sortedkeysset); return sortedkeyslist; } i have run , working fine. just want know if there better way achieve same since want sort strings based on natural ordering itself, directly create list , use collections.sort() on it. sortedkeyslist = new arraylist<>(keysdictionary.keyset()); collections.sort(sortedkeyslist); this way can avoid using sortedset intermediate step.

Is it possible to call two javascript functions on one html event? -

i'm trying this: <textarea onfocus = "myfunction(1)" onblur = "myfunction(0); return submitform();"> is possible? yes syntax wrong, see edited textarea: <textarea onfocus="myfunction(1);" onblur="myfunction(0); return submitform();"> ^------ ^-------- small letter important a yet better way attach jquery event handlers, or similiar different preferred framework.

google webfonts - Get Raleway lining numerals for system font usage -

we'd use raleway on our pcs numerals default jittered. description says it's achievable lining versions horizontally aligned. i've found so question details how lining version via css know how in download? you can use expert mode on http://www.fontsquirrel.com/tools/webfont-generator opentype flattening generate new font lining numerals turned on. additionally, generate font stylistic alts. give more modern, alternative w.

visual c++ - RapidXML saving into a File -

i have googled , have problem saving xml_document<> doc in .xml file. code shall save chess games notations xml file put in compressed file adding multimedia files it. can add audio comments every game stored in xml. #ifndef _filereader_hpp #define _file_reader_hpp #include<fstream> #include"rapidxml.hpp" #include"notation.h" namespace pgnx { class filewriter { std::map<unsigned int, tournament> data; std::ofstream file; std::string fn; rapidxml::xml_document<> doc; protected: void save(); public: filewriter(char* filename); filewriter(); ~filewriter(){} void prepare(); void inserttournament(tournament); //operators filewriter& operator+(tournament rhs); filewriter& operator=(std::map<unsigned int, tournament> rhs); filewriter& operator=(pgnx::filewriter rhs); tournament& op

codeblocks - CanonSDK with OpenFrameworks and OfxCanon -

i'm trying pull video 600d openframeworks using ofxcanon add-on in windows , codeblocks . i've followed instructions here: http://forum.openframeworks.cc/t/ofxcanon-installation-on-windows/11173 but when go compile test lots (50) of following error on various lines: ..\..\..\..\..\..\edsdkv2130w\windows\edsdk\header\edsdktypes.h 172 error: 'edsuint32' not name type i'm using windows 8 . ideas appreciated!

objective c - How to disable system location alert in iOS simulator -

i use kif framework ( http://github.com/kif-framework/kif ) xcode continuous integration server ui testing. when xcode ci server start app in ios simulator system alert "application use current location" appears. i use delegate - (void)locationmanager:(cllocationmanager *)manager didchangeauthorizationstatus: (clauthorizationstatus)status to notification user allows use location , need keep is. is possible tap ok on system alert kif ? didn't found out way. or how allow application use location service in simulator without showing alert ? according this answer top kif contributor , dismissing system alerts automatically impossible, , should therefore mock (i.e. provide substitute for) location service can test code without running alert.

Javascript closure: dynamically-defined functions, call method from current scope -

is possible have static function calls dynamically defined function? need because can't change static function, , know calls dynamic function. example: function staticfunc() { dynamicfunc(); } function test() { function dynamicfunc() {console.log('yay');} staticfunc(); }; test(); but gives me error dynamicfunc not defined . i know if hardcode staticfunc in test() , works. noticed error when call staticfunc , not when define (even though dynamicfunc not defined yet), makes seem staticfunc running inside test() 's scope, evidently not. any way this? way can think of make global function funcptr gets assigned dynamic function. closure can use variable of parent level scope in child level scope. here in case reverse have initialize function in child level scope , try invoke in parent scope not correct. you may pass current function parameter , invoke it: here demo function staticfunc(dynamicfunc) { dynamicfunc(); } function test() {

java - Spring AOP: Trying to use for logging but getting IllegalArgumentException -

i've seen similar problems posted on stack overflow , on spring forums cannot find solution. when try go homepage - before i've tried click on login - following exception: java.lang.illegalargumentexception: warning no match type name: enteredpassword [xlint:invalidabsolutetypename] here xml: <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/cont

xml - Image not displaying completely -

i need display svg image pdf file. below xslt code: <fo:block text-align="left" display-align="left" absolute-position="absolute" left="-1.5cm" top="-1cm"> <fo:external-graphic content-width="scale-to-fit" width="100%" content-height="50%" scaling="uniform"> <xsl:attribute name="src"> <xsl:value-of select="$src" /> </xsl:attribute> </fo:external-graphic> </fo:block> explaination: xml has many images. above code runs in loop , displays images 1 one. images height more page height, image getting cut. tried giving height = 50%. image width reducing. basically want image should fit in block. , bigger images should not cut. should fit in block given. please help. but if reduce height,

c# - Deleting Mail from gmail account -

i able send mails attachments multiple users using c# code. want delete sent mail have sent gmail account using c#. there way it. my code sending mail attachment. if (mailid1 != null) { system.net.mail.mailmessage mail = new system.net.mail.mailmessage(); try { mailidcount = mailid1.split(',').count(); mailids = new string[mailidcount]; mailids = mailid1.split(','); var adminmail = "user@gmail.com"; var adminpassword = "password123!"; var adminsmtpclient = "smtp.gmail.com" string sub = formobj["subject_text"]+" " + convert.todatetime(datetime.now.touniversaltime()).tostring("dd/mm/yyyy"); mail.subject = sub; mail.from = new system.net.mail.mailaddress(adminmail); mail.to.add(mailids[0]);

php - How to retrieve data from serialized jQuery string -

how retrieve data when post using ajax function that jquery("#wp_pass_reset").submit(function() { var url = document.getelementbyid('imgurl').innerhtml; var url2 = document.getelementbyid('adminurl').innerhtml; jquery('#result').html('<span class="loading"><img src="' + url + '/img/load.gif" /></span>').fadein(); var input_data = jquery('#wp_pass_reset').serialize(); jquery.ajax({ type: "post", url: url2 + 'admin-ajax.php', data: { action: 'resetpass_process', value: input_data, }, success: function(msg){ jquery('.loading').remove(); jquery('<div>').html(msg).appendto('div#result').hide().fadein('slow'); } }); return false; }); this form: <form class="user_form" id="wp_pass_reset" actio

python - Return some attributes only in detail view in django-tastypie -

i have attribute want expose in api. calculating attribute costly, want make available in detail view (aka /api/foo/1/ ) , not list view(aka /api/foo/ ). how can tastypie? you can "use_in" resource field attribute, has options of "all", "list" , "detail". you can read more here

Haskell Parsec Unexpected End of Input -

here's example of file i'm trying parse: xx00135 abcdefghij risk solutions page no : 7 beg per: 03/17/2014 current company 03/18/2014 end per: 03/18/2014 qa process - reject report 20:28:36 batch: 123456789 contrib: 987654321 - abcde fghi-san diego quote back: 1a23b45c79 code account no typ company name beg date end date err ------ -------------------- --- -------------------- -------- -------- --- 12345 1234567890001 ab abcde fghi products 20140314 20140914 059 xx00135 abcdefghij risk solutions page no : 8 beg per: 03/17/2014 current company 03/18/2014 end per: 03/18/2014 qa process - reject report 20:28:36 batch: 234567890 contrib: 987654321 - abcde fghi-san diego

css - Can i use ng-show with display:none? -

here plunker , happening when refresh page, if ng-show "false", show milliseconds. know why happening, happens because angular hasn't been loaded yet, want use css property "display:none" avoid this, still isn't working... you may want take @ ng-cloak . example: <div id="template1" ng-cloak>{{ 'hello' }}</div> this prevent browser displaying "#template1" div during brief time hello scope model don't have value.

how to delete the contents in getExternalFilesDir(null) android -

i have saved files using command: file file = new file(cont.getexternalfilesdir(null), filename); how can delete of files have saved? need clear content of cont.getexternalfilesdir(null) directory. thanks if want delete file can told perroloco, if need delete content think oo approach better :) first build method delete files inside directory recursively private void deleteallcontent(file file,string... filename) { if (file.isdirectory()) (file child : file.listfiles()) deleteallcontent(child); if(filename==null) file.delete(); else for(string fn:filename) if(file.getname().equals(filename)) file.delete(); } then can call new method external files dir. deleteallcontent(cont.getexternalfilesdir(null)); or deleteallcontent(cont.getexternalfilesdir(null),"myfile1","myfile2","etc");

ruby on rails - How to distribute uploaded files to Users attributes? -

okay, i'm little new @ this; don't know how go doing this: i have assets model, articles model, , user model. the assets model has paperclip document attribute. #asset.rb belongs_to :article has_attached_file :document, :path => "assets/:id-:basename-:style.:extension", storage: :dropbox, dropbox_credentials: rails.root.join("config/dropbox.yml") validates_attachment :document, content_type: { content_type: "application/pdf" } #article.rb belongs_to :user has_many :assets, dependent: :destroy accepts_nested_attributes_for :assets, allow_destroy: true, :reject_if => lambda { |d| d[:document].blank? } validates :title, :content, presence: true #articles_controller.rb def new @article = article.new @article.assets.build end def article_params params.require(:article).permit(:title, :content, assets_attributes: [:id, :article_id, :document, :_destroy] ) end #user.rb has_many :articles, dependent: :destroy has_m

python - Statsmodels Categorical Data from Formula (using pandas) -

i trying finish homework assignment , need use categorical variables in statsmodels (due refusal conform using stata else). have spent time reading through documentation both patsy , statsmodels , can't quite figure out why snippet of code isn't working. have tried breaking them down , creating patsy commands, come same error. i have: import numpy np import pandas pd import statsmodels.formula.api sm # i'm getting data data = pd.read_csv("http://people.stern.nyu.edu/wgreene/econometrics/bankdata.csv") # want use form regression form = "c ~ q1 + q2 + q3 + q4 + q5 + c(bank)" # regression mod = sm.ols(form, data=data) reg = mod.fit() print(reg.summary2()) this code raises error says: typeerror: 'series' object not callable . there similar example here on statsmodels website seems work fine , i'm not sure difference between i'm doing , they're doing is. any appreciated. cheers the problem c name of 1 of col

python - Progress Bar Todo List Tutorial -

i have been following light bird beginner's tutorial django. link in last part of part 1 tutorial tasked developing progress bar. not able progress bar work following code. from django.db import models django.contrib import admin django.utils.translation import ugettext _ django.utils.encoding import force_unicode django.http import httpresponse, httpresponseredirect django.core.urlresolvers import reverse django.contrib.auth.models import user # create models here. class datetime(models.model): datetime = models.datetimefield(auto_now_add=true) def __unicode__(self): return unicode(self.datetime.strftime("%b %d, %y, %i:%m %p")) class item(models.model): name = models.charfield(max_length=60) progress = models.integerfield(default=0) created = models.foreignkey(datetime) priority = models.integerfield(default=0) difficulty = models.integerfield(default=0) done = models.booleanfield(default=false) user = models.foreig

android - How to detect that new app has been installed on the device? -

how cleanmaster app detect new app has been installed on device? whenever install new app, popup asking if want move app sd card. i trying code similar behaviour cannot find way it. there action_package_added broadcast intent, application being installed doesn't receive this. <receiver android:name=".myreceiver"> <intent-filter> <action android:name="android.intent.action.package_added" /> <data android:scheme="package" /> </intent-filter> </receiver>

java - jpanel implementing button behavior -

i want create radio button has more components default jradiobutton. i'm wondering best method is, should subclass jradiobutton adding components or better subclass jpanel , add behavior of radio button shown below. ---------jpanel--------------- - titel (label) - - radiobutton (jradiobutton) - - description (label) - ------------------------------ the whole panel should focusable , should provide feedback when clicked or has focus. help. none of above. don't extend components unless genuinely need extend functionality, not merely decoration. don't confuse containment hierarchy class hierarchy. don't defeat existing focus subsystem unless plan provide own. if want alter appearance of panel when radio button's focus changes, in focus listener attached button. background color of opaque panel bound property, setbackground() should sufficient.

Stuck on Java Recursion Puzzle -

i new java , have decided learn recursion. there puzzle must solve using recursive method. puzzle list on integers start @ first element , goal reach last element, zero. have move right or left in list , number of times can determined element on. cannot move outside list either, , cannot use sublist. method suppose see if given puzzle solvable. current code has stackoverflow , have no idea how fix it there few problems algorithm. the last thing method 'issolveable' returns forward or backwards solveability. instead of returning, try forward solveability first, if fails, try backwards solveability. the 'beenon' list isn't passed each issolveable() method invocation empty each time method called. can create 1 on first call , pass along each time call method. also arn't checking if out of bounds quite right. list.size() 1 greater actual index of last position in list, since lists start @ 0, not 1. last index board.size() - 1 public static bool

jquery - How to make the select box value back to the default value -

here want make select box value default value. $(".reportingto").change(function() { var reportingtovalue = $(this).val(); var reportingtoid=$(this).attr('id'); $('select[id^="reportingto"]').each(function() { if(reportingtoid!==$(this).attr('id')&& reportingtovalue===$(this).val()){ alert("duplicate found"); $(reportingtoid).val( $(reportingtoid).prop('defaultselected') ); } }); if default value first/top one, solution work you. // replace $(reportingtoid).val( $(reportingtoid).prop('defaultselected') ); // $('#'+reportingtoid).prop('selectedindex',0);

c# - Binding a DataGridColumn to a property in the containing UserControl -

i want bind custom datagridboundcolumn property in containing usercontrol . property contains information tells column how generate content. this seemed easy @ first, data context in data grid changed, , can't seem reference containing user control. here tried: elementname doesn't work, since column isn't in same name scope. using x:reference , has worked me in similar situations, gives initialization error. using findancestor doesn't work, since column isn't part of same visual tree. the column doesn't seem have property such owner gets containing datagrid . i can think of few ways solve problem, , they're messy or unsatisfactory: trying find reference through code in column. goes against point of having column, reusing in few different contexts. create static resource dummy dependency property value bound user control using x:reference extension, , bind column static resource, finding required property using path . this i'm do

c - combine fork execl wait -

i have create prog1 take 1 argument number of children have create. (example "./prog1 5" - create 5 children) each of children generate random number 1 20. number given execl start prog2 (in same folder) take argument random number. prog2 should sleep random number time. after should return random number parent. created still don't work properly. prog1: #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <sys/wait.h> int main(int argc, char *argv[]) { int n, i, pid; int u = getppid(); int procesy = 0; pid_t proc_id; n = atoi(argv[1]); for(i = 0; < n; i++) { proc_id = fork(); if(proc_id==0) { srand(getpid()); u = 1 + rand()%20; execl("./prog2", "prog2", u,0); } else { procesy++; } } if(u == getppid()) { for(i = 0; <

url - Php Redirect to a webpage (html) -

i've seen use of header in php redirect page. i've used method in code below , redirect error given below code. i need know went wrong code. here code (php) : <?php /** * created phpstorm. * user: priyabrata * date: 3/18/14 * time: 8:58 pm */ function connect_to_db($uid, $pass){ $con=mysqli_connect("localhost", "root", "12345", "mydb"); if (mysqli_connect_errno()){ echo "failed establish link!!"; }else{ echo mysqli_connect_error(); } $result=mysqli_query($con, "select `pwd` `login_table` `uid` = "."'".$uid."'"); if (!$result){ echo "error!!"; exit(); } while($xx = mysqli_fetch_array($result)){ if ($xx['pwd'] == hash("md5", $pass)){ header("location:../html/login-existing-users1_success.htm"); exit(); }else{ echo "

slider - How to get high quality of images in Opencart's slideshow -

i using original slideshow in opencart. when upload images quality doesn't vary, in slider qualities lower original images. to want, you'll need upload banners @ right size , change code doesn't resize it. open /catalog/controller/module/slideshow.php , find code 'image' => $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']) change to 'image' => https_server . 'image/' . $result['image'] note assumes recent version of opencart - older versions better off using 'image' => https_image . $result['image']

ruby on rails - trouble with ALL of the backbone association plugins -

there basic setup of rails backbone app keeping of major backbone associations solutions working. even identical simple models/collections shown in (rather limited) docs, running same problem several different potential solutions (relational, jjrelational, backbone-association). for reason when goes set "relational stuff" backbone model definition, dying when tries "this.__set(models, options)" (each of them has different syntax basic operation -- of them show super class "set" method undefined!) there must app setup or selection of gems etc. causing this, i've run out of ideas. here context: rails 4 "scaffold" generated app backbone-rails added , jquery rails , jquery ui added. where "set" method come , cause missing? each of these different associations add-ons, have found basic model definitions , how i'm using them work fine long leave "relations" block of model commented out. commented out, associa

c - How to free a calloc'd pointer without removing value from hashtable/linked list? -

i'm setting , loading hashtable, using linked lists. each item, calloc struct pointer, enter item array itself, or associated linked list if array index taken. all works beautifully, valgrind telling me have "definitely lost" @ line calloc'ing struct item. now, i'm new c, familiar objective-c. in pre-arc days, alloc object, put in array, release it. array retain object. once needed pull item out of array, need retain first. otherwise, lost array no longer retaining object. so, guess question is: how array/linked list retain "objects", can free alloc'd item after entering array or linked list? // global array struct_item** hashtable; // declare struct typedef struct struct_item { char item1[size + 1]; struct struct_item* next_item; } // later... dynamically allocate hashtable hashtable = calloc(sizevar, sizeof(struct_item); // later, inside of loop... // alloc struct item go array/linked list (valgrind error happening here) stru

add image above listview in Android -

i've added listview activity. uses simple layout file follows: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" android:layout_gravity="center" > <textview android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@+id/label" android:drawableleft="@drawable/greencircle" android:textsize="20sp" /> </linearlayout> then add during "oncreate()": string[] values = new string[] { "new contact", "list contacts", "edit settings"}; // use custom layout arrayadapter<string> adapter = new arrayadapter<string> (this, r.layout.activity_

html - javascript object : current or method? -

this code: var x = document.getelementbyid("x"); this html: <p id="x">text</p> this next javascript: x.innerhtml = "newtext" alert(x.innerhtml) so happen? x save information when using var x = document.getelementbyid("x") , variable x change not html <p> id x ? since x reference dom element, it'd modify innerhtml of id - x. demo: jsfiddle var x = document.getelementbyid("x"); x.innerhtml = "newtext"; alert(x.innerhtml); //same below alert alert (document.getelementbyid("x").innerhtml);

matlab - Finding indexes, intersection and then ranking in a matrix? -

i have matrix follows: a = [1 0 0 0 0 0 0; 1 1 0 0 0 0 0; 1 0 1 0 0 0 0; 1 1 0 1 1 0 0; 1 1 0 1 1 0 0; 1 0 1 0 0 1 1; 1 0 1 0 0 1 1] of wish create following table: x - each rows index of cols having 1 y - each cols index of rows having 1 z - intersection set s.no x y z rank(comparing x & z) 1 1 1,2,3,4,5,6,7 1 2 1,2 2,4,5 2 ii 3 1,3 3,6,7 3 ii 4 1,2,4,5 4,5 4,5 iii 5 1,2,4,5 4,5 4,5 iii 6 1,3,6,7 6,7 6,7 iii 7 1,3,6,7 6,7 6,7 iii of above table, x , y columns have been found of matlab code provided sir luis mendo previous question. code follows: [ii jj] = find(a); %// find row , col indices (ii , jj respective

java - "Cannot instantiate the Type Main" -

i keep getting error every time create new object class name: "cannot instantiate type main" this code: import javax.swing.*; import java.util.scanner; import java.applet.applet; import java.awt.*; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.keyevent; import java.awt.event.keylistener; import java.awt.geom.ellipse2d; public abstract class main extends jpanel implements actionlistener, keylistener{ timer t = new timer(5, this); double x = 0, y = 0, velx = 0, vely = 0; public main() { t.start(); addkeylistener(this); setfocusable(true); setfocustraversalkeysenabled(false); } public void paintcomponent(graphics g) { super.paintcomponent(g); graphics2d g2 = (graphics2d) g; g2.fill(new ellipse2d.double(x, y, 40, 40)); } public void actionperformed(actionevent e) { repaint(); x += velx; y += vely; } public void up() { vely = -1.5; velx = 0; } public vo

addclass - jQuery - Check if div has not class after add class -

i want jquery check div if has not class after add class: here add class code: $('#test').each(function (e) { $(this).click(function () { $(this).addclass('rotate'); }); then, want check if #test div has not .rotate class: $('#test').not('.rotate').mouseenter(function () { $('#test').removeclass('rotate'); }); but not working. assuming use classes rather id s (since id s must unique in document), sounds you're saying want add rotate class elements when they're clicked, , remove when elements receive mouseenter . delegated handling best bet that: // clicking on .test isn't .rotate adds .rotate $("body").on("click", ".test:not(.rotate)", function() { $(this).addclass("rotate"); }); // mouseenter on .test.rotate removes .rotate $("body").on("mouseenter", ".test.rotate", function() { $(this).removec

c# - How to get dataset from Getpaged? -

Image
what problem in code ? service.billviewservice bvs = new service.billviewservice(); db.billview bv = new db.billview(); dataset ds = new dataset(); ds = bvs.getpaged("invno=" + n, null, 0, 10000, out x).todataset(); try bvl2 = bvs.getpaged(" date = '" + today + "' , userid = " + specuserid + "", null, 0, 1000, out x).todataset(false);

java - How to handle file uploads when other validation errors are thrown -

i have xpage fileupload control , fields. use serverside validation (some of fields need lookups etc. validate content). if user specifies file uploaded , 1 of other fields fails validate (showing message user) fileupload control loses client name (and file) - meaning user have select file again upload it. any ideas how solve this? can uploaded temp. file "kept in memory" in e.g. view bean - , "injected" when validation doesn't fail other fields? this question related same issue asked here: how can "keep" uploaded image on form validation error? - not give solution above (although discuss temp. file). you should change ui , give user special button uploading files (maybe in modal dialog). here small example xpage: <?xml version="1.0" encoding="utf-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core"> <xp:this.data> <xp:dominodocument var="document1" formname=&q

Spring-boot Thymeleaf Multipart file upload -

i trying create page allows user select file uploaded springmvc controller. here controller: @restcontroller public class customerdatacontroller { @requestmapping(value = "/customerfile", method = requestmethod.post) public @responsebody string handlefileupload(@requestparam("myfile") multipartfile file) { if ( !file.isempty() ) { string name = file.getname(); try { byte[] bytes = file.getbytes(); bufferedoutputstream stream = new bufferedoutputstream( new fileoutputstream( new file( name + "-uploaded" ) ) ); stream.write( bytes ); stream.close(); return "you uploaded " + name + " " + name + "-uploaded !"; catch ( exception e ) { return "you failed upload " + name + " => " + e.getmessage(); } } else { return "the selected file empty , not

Django Tastypie: Imlementing Many To Many "through" relationships -

i have searched issue lot , gone through bunch of related questions on stack overflow, there doesn't seem definitive answer how implement many-to-many relationships "through" intermediate model (or maybe missed it). i have model named sample has many-to-many relationship region. there intermediate model connects two, named sampleregion. not saving information on intermediate model, might in future. here models: class sample(models.model): sample_id = models.bigintegerfield(primary_key=true) description = models.textfield(blank=true) objects = models.geomanager() regions = manytomanyfield(region, through='sampleregion') class meta: db_table = u'samples' def save(self, **kwargs): # assign sample id create requests if self.sample_id none: try: id = sample.objects.latest('sample_id').sample_id + 1 except sample.doesnotexist: id = 1 self.sample_id = id

javascript - Jquery year picker not working as expected -

i have created simple jquery year-picker, jelp of post , added custom code make yearpicker show specific value selected. code html <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <select name="yearpicker" data-id="2010" class="yearpicker"> </select> <select name="yearpicker" data-id="2006" class="yearpicker"> </select> javascript $(function () { (i = new date().getfullyear() ; > 1900; i--) { $this = $('.yearpicker'); if ($this.attr("data-id") != i) { $this.append($('<option />').val(i).html(i)); } else { $this.append($('<option selected/>').val(i).html(i)); } } }); what want is, bind property named "data-id" selection control in end , when script runs want element selected in front end. , have multiple selection contr

python - Using Class method to add a Class variable -

the following code adds 2 pretty tables mytableclass . tables initiated in class constructor. create 2 class methods addtable , addtablerow adding additional tables , data rows specifying newtable name. syntax need this? wrote code in class methods place holder. from prettytable import * class mytableclass(object): def __init__(self): self.table1 =prettytable(["student name", "score test 1"]) self.table2=prettytable(["student name", "score test 2"]) def addtable (self, newtable, **kwargs): #what syntax make newtable class variable of mytableclass? self.newtable = prettytable(kwargs.values()) def addtablerow(self, newtable, **kwargs): #what syntax use newtable add data added table? self.newtable.add_row(kwargs.values()) def main(): m = mytableclass() m.table1.add_row(["kenny", 86]) m.table1.add_row(["jackson", 72]) m.table1.add_row([&qu

sql server - How to retrieve image from database to datagridview in c# winforms -

i using sqlserver 2008 r2 database backend in c# windows application. stored images built-in datatype image in database instead of storing in blob or byte . want retrieve image in datagridview database,but giving error parameter not valid . can me out ?? thanks in advance.

ios - Assigning a local @property for a UIView -

i have uiview .h , .m files , in main view controller have popuprectangle *rectangeview = [[popuprectangle alloc] initwithframe:cgrectmake(0, 538, 320, 30)] this allows me show rectangle, instead of doing in each function of view controller, want assign uiview local @property - available each function. how done please ? myclass.h @interface myclass : uiviewcontroller @property (nonatomic, strong) popuprectangle *rectangeview; // public version @end myclass.m @interface myclass() // if don't want public remove if .h , add here instead @end @implementation myclass - (void)viewdidload { // alloc initwithframe here // _rectangeview getter rectangeview _rectangeview = [[popuprectangle alloc] initwithframe:cgrectmake(0, 538, 320, 30)]; } - (void)somerandommethodimadeup { // we're calling getter rectangeview again in different way, we're calling ivar. [[self rectangeview] sethidden:no]; } @end as has been mentioned since k

javascript - Jquery - How to remove text after link inside last item in list? -

i need removing text jquery after link inside last item in list. thank help. html: <ul id="mylinks" style="text-align: left; margin-left: -25px;"> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="display: inline;"><a href="#">text</a>|</li> <li class="small" style="disp

Sql Server - Using id of updated row as argument in delete statement -

i have trigger this: create trigger action_voided on action after update begin if update (voided) begin delete user_actions action_id = ? -- here need id of action updated on voided column end end: and need hold on id of row updated trigger, , use id argument of delete statement. doing research can't figure how use inserted/deleted tables combination make work. thank help! not sure if solve problem if want "id" column of row getting updated, can use inserted magic table here. following should modified trigger you. have not tested please pardon syntax errors if any. if let me know modify answer accordingly. create trigger action_voided on action after update begin if update (voided) begin delete user_actions action_id in (select id inserted) end end: hope helps.

sql - pls tell me how to make this query into a single query -

select ac1.acct_code, ac1.period, ac1.month, ac1.year, ac1.prd_bdgt, ac2.acct_code, ac2.period, ac2.month, ac2.year, ac2.prd_bdgt account ac1, account ac2 ac1.acct_code='075200' , ac1.year=1994 , ac1.period between 1 , 6 , ac2.acct_code=ac1.acct_code , ac2.year=1995 , ac2.period =ac1.period union select ac3.acct_code, ac3.period, ac3.month, ac3.year, ac3.prd_bdgt, ac4.acct_code, ac4.period, ac4.month, ac4.year, ac4.prd_bdgt account ac3, account ac4 ac3.acct_code='075200' , ac3.year=1995 , ac3.period between 7 , 12 , ac4.acct_code=ac3.acct_code , ac4.year=1996 , ac4.period=ac3.period use or : select ac1.acct_code, ac1.period, ac1.month, ac1.year, ac1.prd_bdgt, ac2.acct_code, ac2.period, ac2.month, ac2.year, ac2.prd_bdgt account ac1, account ac2 ac1.acct_code='075200' , ac

selenium - Table data identification using Xpath in mozilla browser -

i trying identifying table data below htmlcode <!-- can use /goo.html have application context sensitive --> <!-- add custom tag lib's required of project down below --> <div id="specialhandlingtablewrapper" style="height: 401px;"> <div id="specialhandlingtableheader" style="width: 636px; position: relative; top: 0px; z-index: 10; vertical-align: top; height: 170px;"> <table id="specialhandlingselectiontable" class="table table-striped table-hover table-striped data-table"> <thead> <tbody> <tr> <td class="itemnamecell">sod catalog test code1 not inbound</td> <td class="skucell">sod_catalog_special_handling</td> <td/> <td/> <td/> </tbody> </table> </div> i need 3rd column data , below xpath written same @findby(xpath = "//table[@id='specialhandlingselectiontable' , class='