Posts

Showing posts from July, 2013

.net - Accessing properties between calls using NSIS CLR.dll -

i writing installer using nsis needs parse block of json. to achieve hoping able call .net dll parse json , in nsis script call properties on class retrieve data need. however, appears nsis clr.dll has problem state of class not maintained between calls. my test .net class follows: namespace nsistestdll { public class testclass { private bool _configured; public void configure() { _configured = true; } public string name { { if (_configured) { return "john doe"; } return "unconfigured"; } } } } and part of nsis script calls is: file "nsistestdll.dll" clr::call /nounload "nsistestdll.dll" "nsistestdll.testclass" "configure" 0 clr::call /nounload "nsistestdll.dll" "nsistestdll.testclass" get_...

Efficient way to run multiple scripts using javax.script -

i developing game i'd have multiple scripts implement same structure. each script need run in own scope code doesn't overlap other scripts. example: structure.js function oninit() { // define resources load, collision vars, etc. } function onloop() { // every loop } function clickevent() { // clicked me } // other fun functions now, lets have: "badguy.js", "reallyreallybadguy.js", "otherbadguy.js" - above in terms of structure. within game whenever event takes place, i'd invoke appropriate function. the problem comes down efficiency , speed. found working solution creating engine each script instance (using getenginebyname ), doesn't seem ideal me. if there isn't better solution, i'll resort each script having own unique class / function names. i.e. badguy.js var badguy = new object(); badguy.clickevent = function() { } i don't think need create new scriptengine every "guy". ca...

asp.net - Filter IList<T> -

list<paymenttype> paymentoptions = _paymentmethods; _paymentmethods public property , i'd filter copy of , store in variable paymentoptions list<int32> noinvoice = new list<int32>(){ 16, 4 , 6 }; foreach (paymenttype pt in paymentoptions) { if(noinvoice.contains(pt.id)) { paymentoptions.remove(pt); break; } } but if run second time, variable _paymentmethods not contain removed item anymore. it seems go reference instead of value... prefer not copy list array should use linq or there other way? edit: have now: list<paymenttype> paymentoptions = shopcontroller.currentshop.paymentmethods; list<paymenttype> paymentoptionsfiltered = new list<paymenttype>(); if (havetofilter) { list<int32> noinvoice = new list<int32>() { 16, 4, 6 }; foreach (paymenttype pt in paymentoptions) { if (!noinvoice.contains(pt.id)) { paymentoptionsfiltered.add(pt); ...

exchangewebservices - Exchange Webservices Managed API - using ItemView.Offset for FindItems() hits performance of LoadPropertiesForItems method -

i'm doing little research on possible application of ews in our existing project written heavy use of mapi , found out disturbing performance of loadpropertiesforitems() method. consider such scenario: we have 10000 (ten thousands) messages in inbox folder we want approximately 30 properties of every message see if satisfy our conditions further processing messages retrieved server in packs of 100 messages so, code looks this: itemview itemsview = new itemview(100); propertyset properties = new propertyset(); properties.add(emailmessageschema.from); /* add necessary properties... */ properties.add(emailmessageschema.sensitivity); finditemsresults<item> findresults; list<emailmessage> list = new list<emailmessage>(); { findresults = folder.finditems(itemsview); _service.loadpropertiesforitems(findresults, properties); ...

Is making simple website in "java spring hibernate" is overkilling -

initially php programmer , using joomla build websites . build websites in joomla in few days. i learning java spring hibernate last 3 months , have build simple user registration logins , members area using spring mvc , hibernate annotation etc. now want ask whether onwards should use spring mvc build site because have learned or me in future. because still feel same site can build in few days in php is case in future can come on same level php can build simple site in java in few days or no matter experience have java still going take longer php always can java cms make life easier because want bye php. mean if want make 5 page portfolio website can build in java cms in 1-2 days if "simple website" mean normal page categories, articles , navigation (i.e. not web-application), yes: building grounds java + spring + hibernate overkill (i.e. low-level tools, you'd have build lot yourself). i'd stick tools built specific task, namely kind of cms s...

java ee - Deploying war issue with spring frame work -

i getting exception when trying deploy project on linux machine, using spring , hibernate framework project. following error in catalin.out using catalina_base: /usr/share/tomcat5 using catalina_home: /usr/share/tomcat5 using catalina_tmpdir: /usr/share/tomcat5/temp using jre_home: created mbeanserver id: oovd91:gmddgare.0:leeginweb1.inetu.net:1 using catalina_base: /usr/share/tomcat5 using catalina_home: /usr/share/tomcat5 using catalina_tmpdir: /usr/share/tomcat5/temp using jre_home: created mbeanserver id: onrubt:gmddgel2.0:leeginweb1.inetu.net:1 11-apr-11 8:21:38 org.apache.catalina.core.aprlifecyclelistener lifecycleevent info: apache tomcat native library allows optimal performance in production environments not found on java.library.path: /usr/lib/gcj-4.1.2 11-apr-11 8:21:38 org.apache.coyote.http11.http11baseprotocol init info: initializing coyote http/1.1 on http-8080 11-apr-11 8:21:38 org.apache.catalina.startup.catalina load info: initialization ...

jsf - Using Properties from ResourceBundle in ManagedProperty -

i have jsf validator i'm building has properties in have loaded resourcebundle. however, i'm not quite sure how work this, isn't loading properly. ideas on how can make work? i've tried using @postcontruct it, i'm getting following error in eclipse: access restriction: type postconstruct not accessible due restriction on required library /system/library/java/javavirtualmachines/1.6.0.jdk/contents/classes/classes.jar so, i'm not sure best way work this. sample of i'm talking below... the validator... @facesvalidator("usernamevalidator") public class usernamevalidator implements validator { @managedproperty(value="#{props_usernamepattern}") private string usernamepattern; @managedproperty(value="#{props_minusernamelength}") private int minusernamelength; @managedproperty(value="#{props_maxusernamelength}") private int maxusernamelength; public void validate(facescontext ...

what is JCR in java and spring -

i have been learning java spring hibernate mvc 3 months , got pretty idea of . have not understood jcr means. i mean e.g in simple webiste in spring mvc part can done in jcr jcr alternative persistence mechanism used in place of jpa (hibernate), hides jdbc application. in theory, java classes have in model might remain same have now. however, if classes in model came because needed model lower-level data structures jpa, these classes might not needed jcr. you'd need reason replace existing use of jpa jcr. example, may have discovered using jpa requires jumping through lot of hoops , doing things you'd not need do. having said that, jcr has advantages , capabilities not otherwise found in jpa: jcr supports structured data, unstructured data, , in between. jcr allows flexible schema , can nosql-ish. jpa structured, fixed schema. jcr hierarchical - use cases extremely hierarchical, , doing relational model can difficult/expensive jcr has built-in events mo...

c++ - unordered_map with forbidden collisions -

i want implement performance-optimized variant of unordered_map works in several phases: initialization: insert 100 elements std::map preparation: magic, converting std::map variant of std::unordered_map work: perform large (unbounded) number of lookups; insertions/deletions forbidden in order make "work" phase fast possible, choose hashing function has no collisions given set of keys (gathered @ initialization phase). i measure how performance improvement can trick. going experiment, possibly going production code. does standard library have facilities implementation (e.g. finding how many collisions given unordered_map has; or changing hashing function)? or should make own implementation instead? here "collision management" api: size_type bucket_count() const; size_type max_bucket_count() const; size_type bucket_size(size_type n) const; size_type bucket(const key_type& k) const; local_iterator begin(size_type n); local_ite...

c# - Automatically assign authentication token in .NET -

i have implemented forms authentication .net membership provider want users able login facebook. once authenticated facebook, want automatically assign .net authentication token user. have httpmodule detecting fb authentication attempts manually generate authentication token have come short. i tried formsauthentication.setauthcookie formsauthentication.getauthcookie + response.cookies.add new formsauthenticationticket(...) la msdn in httpmodule vs page plus few other desperate attempts. nothing seems work. how done? proposed way using wif

alter box using php -

please i have web page on there sign in . once enter login detail , click on submit button , goes next page loginauthentic.php page , check database , if user exit redirect main page again . now want once redirected main page . on main page should display message or alert box " login in " and alter box or message should come in front image on main page should visible in background not sure understand completley, if want change content depending on whether user logged in or not, need save login status in session use simple conditional detect whether session variable set , echo out correct markup. if($_session['logged_in']){ echo 'something'; } else { echo 'something else'; } however not know if asking...

iphone - TableViewController for scrolling horizontally -

i need tableviewcontroller scrolls horizontally instead of vertically. is there 1 available? because have use scrollview might memory hungry after while! we have used uiscrollview each cell , scroll them when either of them scrolled. our app has loads of data in tableview , doing fine. can try approach.

ubuntu - Error with dev_appserver.py of Google App Engine -

i 'm trying use google app engine on ubuntu got these errors of python sdk traceback (most recent call last): file "google_appengine/dev_appserver.py", line 78, in <module> run_file(__file__, globals()) file "google_appengine/dev_appserver.py", line 74, in run_file execfile(script_path, globals_) file "/home/user/downloads/google_appengine/google/appengine/tools/dev_appserver_main.py", line 118, in <module> google.appengine.tools import appcfg file "/home/user/downloads/google_appengine/google/appengine/tools/appcfg.py", line 68, in <module> google.appengine.tools import appengine_rpc file "/home/user/downloads/google_appengine/google/appengine/tools/appengine_rpc.py", line 27, in <module> import fancy_urllib file "/home/user/downloads/google_appengine/lib/fancy_urllib/fancy_urllib/__init__.py", line 341, in <module> class fancyhttpshandler(urllib2.htt...

jms - HornetQ Unable to validate user -

i using jboss 6 final on ubuntu hornetq i have created new queue on server named message buffer queue using admin panel. i following error: unable validate user: guest check type consume address jms.queue.messagebufferqueue here files: package org.jboss.ejb3timers.example; import java.text.dateformat; import java.text.simpledateformat; import java.util.enumeration; import java.util.hashtable; import java.util.uuid; import javax.jms.connection; import javax.jms.connectionfactory; import javax.jms.message; import javax.jms.messageconsumer; import javax.jms.messageproducer; import javax.jms.objectmessage; import javax.jms.queue; import javax.jms.queuebrowser; import javax.jms.queueconnection; import javax.jms.queueconnectionfactory; import javax.jms.queuesession; import javax.jms.session; import javax.naming.context; import javax.naming.initialcontext; public class testclass { connectionfactory hconnection=null; queue q=null; connection hconn=null; contex...

visual c++ - C++ calling a ref-class function (mixed code) -

i have application (cli) references mixed-dll. dll implements "ref" class static functions. here (partial) code ref-class public ref class aaa { public: static bool write(system::string^ sz); // not accessible!!! public: static bool tracerect(const crect& rc); }; within exe, in c++ code, i'm trying call both functions: // works aaa::write("hello"); // doesn't !!! crect rc(0, 0, 12, 234); aaa::tracerect(rc); how can access second function? it's because native types (in case, crect) treated private default. so, while method accessible, parameter type rc not accessible. can make accessible using make_public: http://msdn.microsoft.com/en-us/library/ms235607.aspx search c3767 , make_public , you'll find plenty of other info on topic.

iis 7.5 - Setting Default WebPage in IIS 7.5 -

i'd hd problem in machine intranet iis server installed , i've reinstalled software. i've restored site data new iis now, when type server address in browser in client or server machine, doesn't find page ("default.aspx"). can allow "directory browsing" , click file but, obviously, don't want alternative, neither obligating users type "default.aspx" in end of url. maybe it's simple configuration, i've cannot found in iis. put following in site's or application's web.config file: <system.webserver> <defaultdocument> <files> <add value="~/default.aspx"/> </files> </defaultdocument> </system.webserver>

c# - Timer on Server Side? -

i want have timer update global variable every 10 sec, put timer in global.asax.cs: void application_start(object sender, eventargs e) { timer atimer = new timer(); atimer.interval = 10*1000; atimer.tick += atimer_tick; atimer.start(); } void atimer_tick(object sender, eventargs e) { // update data } but weird thing nothing happen after 10 sec. wonder if possible that? thanks in advance. use system.timers.timer instead of system.windows.forms.timer the former uses elasped event handler , function expected anywhere in application. latter tailored winforms , should used on form1_load() not on application start.

objective c - Two class methods, same name, different signatures: How to force compiler to use intended one? -

how force compiler select desired method set of class methods sharing same name? /* use +[myclass port](uint16 (*)(id, sel), * not +[nsport port](nsport *(*)(id, sel)). */ uint16 port = [[self class] port]; i have objective-c class class method: + (uint16)port; nsport has convenience constructor signature conflicts this: + (nsport *)port; sending +port class results in compiler warning: uint16 port = [[self class] port]; w: multiple methods named '+port' found w: using '+(nsport *)port' w: found '+(uint16)port' fail: compiler has chosen wrong method signature. type inference fail: using [[(myclass *)self class] port] not cadge using right method. eta: here workaround using now: #import <objc/runtime.h> class c = [self class]; sel s = @selector(port); typedef uint16 (*portimp)(id, sel); portimp myclassgetport = (portimp)class_getmethodimplementation(c, s); uint16 port = myclassgetport(c, s); it in that: it h...

c - PIC/non-PIC code errors when cross compiling -

this totally outside area of expertise, forgive me if seems rather elementary. i've never worked c, bit new me. i've been tasked cross-compiling the isc's dhcp implementation mips. have compiler (mipsel-linux-gcc) , other assorted tools , compiles fine fails when linking on every file: bad value: failed merge target specific data of file ... linking pic files non-pic files -fpic , -fno-pic changed nothing. there simple solution this, or need start rewriting chunks of software? input appreciated, i'm @ bit of loss. my configure line follows: ./configure cc=mipsel-linux-gcc cpp=mipsel-linux-cpp --host=mips --build=i686-pc-linux-gnu something's wrong libraries you're linking in. make sure have standard library compiled pic, , link it, not system's.

asp.net - Use trace.axd for a single page -

is there way use trace.axd handler tracing single page on site? i'm trying monitor in production, don't want tracing output page, want limit output specific page. edit: prefer have running record of requests aggregated, trace.axd does. you can enable page-level tracing (it not use trace.axd, output still in page) trace.isenabled can enable page-level tracing programmatically, can show trace information in page if conditions met (for instance have parameter in querystring can yourpage.aspx?displaytraceinfo=true ). way not risk having users see trace information in page.

ocr - c# A generic error occurred in GDI+ -

i have problem when drag select region of image in picturebox more 2 times , run scanning. ocr system. region ocr(tab4_component) //when user selecting, regionselect = true private bool regionselect = false; private int x0, x1, y0, y1; private bitmap bmpimage; private void loadimagebt_click(object sender, eventargs e) { try { openfiledialog open = new openfiledialog(); open.initialdirectory = @"c:\users\shen\desktop"; open.filter = "image files(*.jpg; *.jpeg)|*.jpg; *.jpeg"; if (open.showdialog() == dialogresult.ok) { singlefileinfo = new fileinfo(open.filename); string dirname = system.io.path.getdirectoryname(open.filename); loadtb.text = open.filename; picturebox1.image = new bitmap(open.filename); bmpimage = new bitmap(picturebox1.image); } } cat...

sql - Magento modify/add columns to model resource -

i have module flat table may need add columns , remove columns from. know can done in setup, have import data table nightly web service. web service may change column names. first of all, know how alter table structure in magento without using raw sql? second, know best way this? i haven't yet mastered eav data pattern used in magento someday learn. appreciated. i had same thought (or similar) while ago. alter table in magento setup script without using sql ivan's answer particularly , still refer often. essential reading.

c# - convert mdi application to mvvm wpf application -

i have winform application want convert wpf it has main form (mdi) , children can call each other well. i read mdi not practice according mvvm. saw application have , feel want (e.g:prism- told complicated beginners , small application need). do know small wpf project follow mvvm rules , has , feel of mdi application? thanks asaf mdi gui design pattern. mvvm programming design pattern. 2 aren't related @ all. can either 1 or both together. it true, however, many gui design experts frown upon mdi that's entirely because of usability end-user... not because of underlying code. perhaps if describe or provide mockup of ui want create can provide guidance on how implement in wpf.

Pass by Value and reference Java -

i trying write copy method can used copy bean bean mapping property names. if source object cloneable object m cloning , trying return calling method. in calling method change made in called method not reflecting you might understand if u @ below code public class main { public static void main(string[] args) { hashmap<object, object> source = new hashmap<object, object>(); source.put("test1", "test1"); source.put("test2", "test2"); source.put("test3", "test3"); hashmap<object, object> destination = new hashmap<object, object>(); main m = new main(); main.beancopy(source, destination); system.out.println("caller - " + destination); } public static void beancopy(object source, object destination) { if (source.getclass() == destination.getclass() && cloneable.class.isinstance...

Oracle SQL from Java using Spring returns nothing, and doesnt throw exception -

i have java code uses spring connect , execute sql on oracle db. have query takes long time execute (20 minutes or more). have executor service , has thread execute query , process results. if put timeout db , spring, system time out correctly return nothing else before that. if run query sql plus, return values. time out set 3 times takes execute on sql developer. any ideas!? assuming spring query using bind variables, using bind variables when execute query in sql*plus/ sql developer? or using literals? what version of oracle using? have checked see whether query plans 2 environments different?

xpath - Automating a javascript button click -

so have button code this: <div style="text-indent: 0pt; visibility: inherit;" id="button5061"> <a title="continue" href="javascript:if(%20button5061.hasonup%20)%20button5061.onup()" name="button5061anc"> <img width="82" height="25" border="0" style="cursor: pointer;" alt="continue" src="images/continueoff.gif" name="button5061img"> </a> </div> and need click javascript. right using firefox extension chickenfoot allows me script site javascript interpreter custom commands. http://groups.csail.mit.edu/uid/chickenfoot/api.html i have tried selecting xpath (//div/a[@title='continue']/..) finds it, when click() nothing happens. here of things have tried: click(find(new xpath("//img[@alt='continue']/.."))) click(find(new xpath("//img[@alt='continue']/../.."))) click(...

JavaScript Animation Problem (Fat cats dancing) -

i not sure why cats not moving @ all. pretty sure suppose too. can point me if suppose , or did wrong thanks. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>fat cat dancing</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <script type= "text/javscript"> <![cdata[ var cats = new array(3); var fatcat = 0; var direction; var begin; cats[0] = "fatcat0.gif"; cats[1] = "fatcat1.gif"; cats[2] = "fatcat2.gif"; function dance() { if (fatcat == 0) direction = "right"; else if (fatcat == 2) direction = "left" if (direction == "right") ++fatcat; else if (direction == "l...

ruby on rails - Not sure how to optimize active record association -

i have piece of code gets associated object id, otherwise initializes new object. def pick_for_game(game_id) picks.find_or_initialize_by_game_id(game_id) end the picks collection typically have several hundred items in it. 2 use cases are: i want call method 15-30 games i want call method games seems current approach ok use case a, absolutely terrible use case b. make method complicated based on whether or not picks has been eagerly loaded following: def pick_for_game(game_id) if picks.loaded? new_pick = proc { pick.new |p| p.game_id = game_id end } picks.detect(new_pick) |p| p.game_id == game_id end else picks.find_or_initialize_by_game_id(game_id) end end however, picking 1 approach on other cases have merit other making code little cleaner? other solutions problem? assuming pick model, if know list of game_ids can fetch existing picks specified games in 1 query , initialize new picks remaining game_id...

PHP SQL Injection Prevention -

possible duplicate: how prevent sql injection in php? i working video streaming website college library. using php , mysql. have not used parameterized queries in project. came know sql injections. code done , have submit project in next 2 days,how can assure code not sql injection prone? converting whole thing in parameterized interface can't ? should avoid sql injections on website ? plz ! the basic idea prevent sql injections (if not using prepared statements) escape data . when inject expected integer value sql query, make sure it's integer, using intval() . when have decimal/numeric field in table, use floatval() . and when have string (char, varchar, text) field in table, use function provided api escape strings : mysql_real_escape_string() mysqli_real_escape_string() pdo::quote()

ruby on rails 3 - Why include? gives me wrong results in Rails3? -

i guess i'm doing wrong... i've got 2 models in rails3: user container each container has multiple users , need test whether specific user belongs specific container. user.rb has_many :user_containers has_many :containers, :through => :user_containers container.rb has_many :user_containers has_many :users, :through => :user_containers i wrote helper should test user's "membership", returns false: def allow_access?(container, user) container.users.include?(user) end however, running in rails console just container.users.include?(user) returns correctly true... missing something? thanks

Java Constructor help -

Image
//******************************************************* // account.java // // bank account class methods deposit to, withdraw from, // change name on, , string representation // of account. //******************************************************* import java.util.random; public class account { private double balance; private string name; private long acctnum; //---------------------------------------------- //constructor -- initializes balance, owner, , account number //---------------------------------------------- public account(double initbal, string owner, long number) { balance = initbal; name = owner; acctnum = number; } //---------------------------------------------- // checks see if balance sufficient withdrawal. // if so, decrements balance amount; if not, prints message. //---------------------------------------------- public void withdraw(double amount) { if (balance >= amount) balance -= amount; else ...