Posts

Showing posts from 2014

asp.net mvc - ASP MVC3 ActionLink not rendering variables -

i trying use asp mvc3 action link navigate view (same controller). view attached model uses compound key primary key. below action link it's written on view @html.actionlink("edit agent", "agentedit", "banklistmastercontroller", new { @agentid = int.parse(item.agentid), @id = item.id}) however when rendered renders following http://localhost:2574/banklistmaster/agentedit?length=24 which throws error: the parameters dictionary contains null entry parameter 'agentid' of non-nullable type 'system.int32' method 'system.web.mvc.viewresult agentedit(int32, int32)' in 'monet.controllers.banklistmastercontroller'. optional parameter must reference type, nullable type, or declared optional parameter. parameter name: parameters here controller method measure: public viewresult agentedit(int agentid, int id) { string compare = agentid.tostring();

multilingual - Django multi-lingual site : how to? -

i want have website in 3 languages , allow user change preffered language somewhere in template. models need translating. found few libraries perhaps should use : https://code.google.com/p/django-multilingual/ traslating models https://pypi.python.org/pypi/django-localeurl/1.4 language prefix in url's https://docs.djangoproject.com/en/dev/topics/i18n/ translating static parts of site however can't understand how these come together. perhaps give me rundown of steps translate website. you can use i18n_patterns instead of django-localeurl if use django 1.4. or later. i18n_patterns set active language based on url prefix. django i18n serve translated messages in python code , templates based on active language . (you have makemessages , compilemessages create , compile translations). for translations in model there lot of libraries, majority of them use active language serve field translation. prefer django-modeltranslation , allows translating of

ruby on rails - Why are my HAML named routes empty? -

i'm trying create pages in haml, partly working. html produces correct, apart 1 thing. have: %ul#menu %li = link_to 'home', root_url i expecting back: <a href="/">home</a> instead, producing: <a href>home</a> upon looking further, seems of named routes returning blank string , not route meant to. happening on of them not root. if try changing made-up name, 'test_path' then, expect, error saying method doesn't exist, it's not case of not being able find it, it's not returning anything. in rails console able correct route know it's working, , rake routes gives me: about /about(.:format) welcome#about contact /contact(.:format) welcome#contact faq /faq(.:format) welcome#faq plans /plans(.:format) welcome#plans root / welcome#index can pretty major i

java - get wrong output of a recursive method -

public static int getindexof(char ch, string str) { if (str == null || str.equals("")) { return 0; //base case }else{ char first = str.charat(0); if (ch != first) { return -1; //returns -1 when character cannot found within string }else{ int rest = str.length() - 1; if (str.charat(rest) == ch) { return rest; } return lastindexof(ch, str.substring(0, rest)); //recursive case } } } this method returns index of input character of input string. however, when run in interaction plane, returns wrong number. example, when enter 'a' , "peach", supposed return 2, returns -1. method should return -1 when character cannot found in string. can tell me how deal it? thank you! well why don't step through logic , see happens. getindexof('a', "peach") method goes in, string isn

css - Possible to get Zurb Foundation 4 select drop-downs to work on mobile browsers? -

i can't scroll options in foundation 4 select drop-down on any mobile browser. makes foundation's select drop-down pretty useless. there way work? same problem here. way (afaik) solve not making use of custom-forms , build own dropdown like amazon does: <span id="nav-search-in" class="nav-sprite nav-facade-active" style="width: auto;"> <span id="nav-search-in-content" style="width: auto; overflow: visible;">all</span> <span class="nav-down-arrow nav-sprite"></span> <select id="searchdropdownbox" class="searchselect" style="top: 0px;"> <option value="search-alias=aps" selected="selected">all departments</option> <option value="search-alias=watches">watches</option> </select> </span> set select's opacity 0 (see other styles on webpage) , t

php - CURL posting to another domain SSL Certificate Error -

i attempting use curl https address of api. api displays string result on page posting , not return me domain. i'm not sure if there way figured curl solution. could possible occuring on localhost? error receiving: ssl certificate problem, verify ca cert ok //set url, number of post vars, post data curl_setopt($ch,curlopt_url, $url); curl_setopt($ch,curlopt_post, count($fields)); curl_setopt($ch,curlopt_postfields, $fields_string); //execute post $result = curl_exec($ch); var_dump(curl_error($ch)); result: string 'ssl certificate problem, verify ca cert ok. details: error:14090086:ssl routines:ssl3_get_server_certificate:certificate verify failed' (length=146) by default, php attempts certify peer's certificate. if you're sure don't care, can see if curl request can fire, testing: curl_setopt($ch, curlopt_ssl_verifypeer, false); before execute curl call. the proper way set curl call use server's existing ca certificates using

Can specifying a taskaffinity cause a new process to be created in Android -

so have simple application. activity 1 activity 2 (affinity :mytask - launchmode=standard) activity 3 (affinity :mytask - launchmode=standard) broadcast receiver service br receives intent starts service service magic launches activity 2 launch activity 3 after while. now observing when activity 2 started, see 2 process ids app. if navigate activity1 -> activity 2. see 1 process id. my questions are: can specifying taskaffinity cause new process created in android? how starting activity service different regular scenario when activities have task affinity? about question 1: with default config, specifying taskaffinity not cause new process created in android, unless specifying attribute android:process different default config. about question 2: starting activity service, must set new_task flag in intent, , activity started in system if there task same affinity has existed, if activity launch in task, otherwise launch in new task.

java - How can i shorten this algorithim for finding Prime Numbers? -

just wondering if me on this. code working possible shorten/remove unnecessary code algorithim while keeping method same? have taken out things don't need unsure if else can taken out. thanks in advance! public static void listprimes(int maxnum) { (int = 2; < maxnum; i++) { boolean isprime = true; (int j = 2; j <= math.sqrt(i); j++) { if (i > 1 && j < && % j == 0) { isprime = false; break; } } if (isprime) { system.out.println(i); } } } ok, not shorten, rather speed up. note there more efficient methods finding prime numbers. apart outputting value, math.sqrt(i) expensive operation (as numbers start getting large, take increasingly greater percentage of processing time), may want consider putting variable before loop. only 2 , uneven numbers prime, can hard-code 2 , skip numbers. i > 1

php - jQuery Fileupload filter display according to mySQL query -

hi have saved mysql database files uplaoded using jquery-php fileupload answer thread guide. questiion is, possible show images database according users uploaded imgs? since save users along filename.? dont have idea on how it, or whant , insert codes, or possible. edited: have idea initialize loading of image protected function get_file_object($file_name) { if ($this->is_valid_file_object($file_name)) { $file = new stdclass(); $file->name = $file_name; $file->size = $this->get_file_size( $this->get_upload_path($file_name) ); $file->url = $this->get_download_url($file->name); foreach($this->options['image_versions'] $version => $options) { if (!empty($version)) { if (is_file($this->get_upload_path($file_name, $version))) { $file->{$version.'_url'} = $this->get_download_url( $file->name

java - Composite primary key with many to one relation ship does not support mapping error -

i have 3 entities form association relationship having composite primary keys foreign key of other tables. these implementation of these entites: @entity @table(name = "studentscourses", schema = "gpa") @namedquery(name = "getallstdcrs", query = "select sc studentscourses sc") @idclass(studentcourseid.class) public class studentscourses implements serializable { private static final long serialversionuid = 1l; @id @column(name="studentid", insertable=false, updatable= false) private int studentid; @id @column(name="crsid", insertable=false, updatable=false) private int crsid; @manytoone @joincolumn(name="studentid") student student; @manytoone @joincolumn(name="crsid") course course; public studentscourses() { super(); } public void setstudentid(int studentid) { this.studentid = studentid; } public int getstudentid() { return studentid; } public void setcrsid(int crsid) { this.

osx - Where is Java Installed on Mac OS X? -

i downloaded java 7u17 on mac os 10.7.5 here , installed it. in order jni programming, need know java installed on mac. i thought inside /library/java/javavirtualmachines/ folder, there folder called 1.7.0.jdk or something, found folder empty. confirmed running ls /library/java/javavirtualmachines/ in terminal. i've tried searching find out if installed somewhere else, doesn't seem turning up. could please tell me java installed on mac? use /usr/libexec/java_home -v 1.7 command on terminal shell figure out java 1.7 home directory

asp.net - Sql server should be in the same system when hosting Web service in IIS -

i created wcf service in using entity framework sql server located in system. created web-application , consuming service , having no trouble entity framework. when host web service in iis getting exception in entity framework saying underlying provider failed on open . goggled nothing works. as folks mentioned iis user network service user credentials while trying log in sql server. change application pool settings in iis. step 1: open internet information service manager step 2: click on application pools in left navigation tree. step 3: select version pool. in case, using asp .net v4.0. if dont have version, select defaultapppool. step 4: right click on step 3, , select advanced settings. step 5: select identity in properties window , click button change value. step 6: select local system in built-in accounts combo box , click ok. that's it. run application. works well. also check : http://stack247.wordpress.com/2011/03/02/entity-framework-exception-the-underl

Objective C in Windows -

this question has answer here: objective c windows 13 answers pardon me silly question. know there possibility run following program in windows #import<foundation/foundation.h> int main(int argc,const char* argv[]) { nsautoreleasepool *pool =[[nsautoreleasepool alloc]init]; nslog(@"hello world") [pool drain]; } i know there objective c compilers available windows want know there support <foundation/foundation.h> yes. 1 possibility compile gcc using gnustep framework.

Testing for XSS vulnerabilities when URl contains hidden fields -

i checking xss vulnerabilities portal. examples found on internet says that, if have url http://www.yoursite.com/index.html?name=george try encoding http://www.yoursite.com/index.html?name=<script>alert('you found xss vulnerability')</script> and if find alert , show portal xss vulnerable. question url doesn't contains variable , using hidden fields url looks http://[myip]:8080/appshop-v1/appstoreregistration.html and doesn't changes on post or operation .how can insert script in such scenario , check vulnerabilities. the basic safety tells should not trust input coming user , can use tools fiddler , manipulate hidden field value also. if using value output on portal name etc...do html encode before outputting it. xss not limited querystring , can coming user. advisable should not store sensitive information in hidden field because end user can see , change .

html - Footer not getting placed at correct place -

i not in css. trying make html structure not able footer @ correct place. here link can see , test code. can please suggest something. must dont want footer div position:fixed option. remove position of id #placeholder , footer_area , add css #placeholder { background-color: #fafafa; border-radius: 5px 5px 5px 5px; margin: 0 auto; padding-bottom: 10%; width: 70%; } .footer_area { background-position: 0 0; border-radius: 5px 5px 5px 5px; clear: both; color: #333333; font: 12px/25px arial,helvetica; height: 10%; margin: 40px auto 0; padding-top: 10%; text-align: center; width: 70%; }

Codeigniter image resize not work properly -

i want resize uploaded image ratio of 400 x 350. use below code this. $config = array( 'image_library' => 'gd2', 'source_image' => $img_data['full_path'], 'new_image' => $this->upload_path. '/thumbs', 'maintain_ration' => false, 'width' => 350, 'height' => 400 ); $this->load->library('image_lib', $config); $this->image_lib->resize(); codeigniter give me image ratio of 400 x 340. see if help. here link class required accomplish task looking for http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

sql - Mysql query having multiple calculation getting slower -

i have mysql views used report. i.e calculated how many cod orders, prepaid orders, cod order amount, prepaid order amount, grand total , few more calculations in day , join on 5 tables. getting slower. there better way such kind of requirement other using view. or how make such kind of requirements faster select date_format(`orders`.`placed_date`,'%y-%m%-%d 00:00:00') `orderdate`, date_format(`orders`.`placed_date`,'%y-%m%-%d') `orderdt`, count(distinct `orders`.`order_id`) `orderscount`, sum(`order_item`.`quantity`) `qunty`, sum((`order_item`.`quantity` * `order_item`.`a_unitprice`)) `price`, count(distinct (case `payment_type`.`a_name` when 'cod' `orders`.`order_id` end)) `codorderscount`, count(distinct (case `payment_type`.`a_name` when 'prepaid' `orders`.`order_id` end)) `prepaidorderscount`, round(sum(if((`payment_type`.`a_name` = 'cod'),round((((((`order_item`.`quantity` * `order_item`.`a_unitprice`) - ifnull(abs(`g

Getting exception on android facebook code -

getting exception in android facebook code on util class on line 215 here print stack: 04-05 11:08:34.015: e/androidruntime(13527): fatal exception: main 04-05 11:08:34.015: e/androidruntime(13527): android.os.networkonmainthreadexception 04-05 11:08:34.015: e/androidruntime(13527): @ android.os.strictmode$androidblockguardpolicy.onnetwork(strictmode.java:1117) 04-05 11:08:34.015: e/androidruntime(13527): @ java.net.inetaddress.lookuphostbyname(inetaddress.java:385) 04-05 11:08:34.015: e/androidruntime(13527): @ java.net.inetaddress.getallbynameimpl(inetaddress.java:236) 04-05 11:08:34.015: e/androidruntime(13527): @ java.net.inetaddress.getallbyname(inetaddress.java:214) 04-05 11:08:34.015: e/androidruntime(13527): @ libcore.net.http.httpconnection.<init>(httpconnection.java:70) 04-05 11:08:34.015: e/androidruntime(13527): @ libcore.net.http.httpconnection.<init>(httpconnection.java:50) 04-05 11:08:34.015: e/androidruntime(13527): @ libcore.net.h

How to port a firefox extension to google chrome? -

if create firefox extension, run in google chrome changes? found google chrome extension developing at, http://developer.chrome.com/extensions/ looks different xul. mean these application not browser compatible? ie have different language, correct? if different how develop these 3 browser compatible application? there no xul support in google chrome. in order port extension different browser should extract common part of it, works solely web content , not rely on browser specific features. part can shared among extensions (mush same can use jquery , other libs on extensions regardless platform). the other parts of extension, including dealing ui, must customized using specific apis of every browser. example, google chrome should use popup pages or options pages ui. html+css+javascript, not xul.

android - Soundpool not working -

i'm doing simple game , since need short sound effects, thought soundpool appropriate. it's not working! don't sounds! have checked code on , on again , compared several other examples, still not working! i'm confused , need work. here code. have missed or in way? preciated help! thanks! soundpool = new soundpool(4,audiomanager.stream_music, 0); soundpoolmap = new hashmap<integer, integer>(); soundpoolmap.put(0, soundpool.load(this, r.raw.bonk2, 1)); soundpool.play(0, 1f, 1f, 1, 0, 1f); soundpool.release(); in case, have mentioned sound id 0, instead should mention sound id of loaded sound using load() method. for example: soundpool = new soundpool(10, audiomanager.stream_music, 0); soundpool.setonloadcompletelistener(new onloadcompletelistener() { @override public void onloadcomplete(soundpool soundpool, int sampleid, int status) { loaded = true; } }); soundid = soundpool.load(this, r

Xpage extlib Dialog keepComponents true and JSF component -

i have problem dialog control extention library: i have created java custom control wich searches views, collects data , displays it. works nice if place on xpage. but want display data in dialog used dialog control extention library. using dialog control without configuration works fine takes time control search views , display data every time open dialog.so reduce waiting time user wanted use option "keepcomponents="true" dialog control. now if open dialog first time perfekt if open secound time displays content first opening in addition error controlrenderer wich tells me not viewname control. error stacks every time open , close dialog. i found post on openntf had same issue multiple content in dialog when using option didnt answers question. bug of component? should forget option , cache data in bean? why can't renderer viewname component? the answer follows assumes phrase "java custom control" in question refers jsf component dev

Android Intents - use of Context argument -

for intent constructor - intent(context context, class myclass) what context argument specify ? also, ever need set context of other application ? according context documentation : interface global information application environment. abstract class implementation provided android system. allows access application-specific resources , classes, up-calls application-level operations such launching activities, broadcasting , receiving intents, etc. or in other words class provides access application. also, ever need set context of other application ? no, context of applciation provided android. normally, 'normal' applications not need bother context. unless need activate application application or send message between 2 running applications. if want launch application not need context though, not have context of application. instead, can ask android it (using application name), in form on intent : intent launchintent = getpackagemanager(

Problems in fully uninstalling Python 2.7 from Windows 7 -

some months ago, installed python 2.7 on laptop (my os windows 7). after, decided use python xy 2.7.3 instead of 'pure' python; so, suggested, removed python 2.7 , tried install python xy 2.7.3. however, when tried run .exe file installation, warning window appears telling me python 2.7 installed on computer. tried install different version of python xy (2.6) , went fine; however, i'd prefer use latest version of python xy. actually, can't figure out went wrong whie uninstalling python 2.7; have clue? can tell followed 'normal' procedure programm uninstalltion; control panel -> programs -> remove program thanks in advance stefano run regedit, backup , delete registry keys: hkey_local_machine\software\python\ hkey_current_user\software\python my problem occurred when changing canopy python(x,y). so, delete folders left behind when uninstalling. https://support.enthought.com/entries/23580651-uninstalling-canopy

php - Magento - how to create new product type based on bundle product -

i have problem how create new product type based on bundle product. i create module , extends mage_bundle_model_product_type in namespace/modulename/model/product/type/myproducttype.php. if going admin , create new product type, product simple product not bundle product. in config.xml is <catalog> <product> <type> <formula translate="label" module="bank"> <label>formula product</label> <model>bank/product_type_formula</model> <price_model>bank/product_type_formula_price</price_model> </formula> </type> </product> </catalog> in formula.php is <?php class xxxx_bank_model_product_type_formula extends mage_bundle_model_product_type { public function isvirtual($product = null) { return true; } } ?> i don't know why. can me ?

entity framework - How to handle cascading deletes on inherited tables? -

Image
i've run problem on delete cascade when using inherited tables. i've got following tables (model first) now if want delete entry in entity1. using (var ctx = new myentities()) { var first = ctx.entity1set.first(); ctx.deleteobject(first); ctx.savechanges(); } simple... savechanges throws following exception. the delete statement conflicted reference constraint fk_entitya_inherits_baseentity". conflict occurred in database "mydb", table "dbo.baseentityset_entitya", column 'id'. statement has been terminated. how fix this? update i noticed difference between how vs2010 , vs2012 model designer outputs sql. vs2010 : -- creating foreign key on [id] in table 'baseentityset_entitya' alter table [dbo].[baseentityset_entitya] add constraint [fk_entitya_inherits_baseentity] foreign key ([id]) references [dbo].[baseentityset] ([id]) on delete no action on update no action; go -- cre

objective c - How to set Main Interface field blank? -

i used mainwindow-ipad main interface in project. set window dynamically in application:didfinishlaunchingwithoptions: self.window = [[[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; so don't need value in main interface field in ipad deployment info. when try clear field becomes mainwindow. use mainwindow.xib iphone. want leave main interface blank. can do? if use storyboard, solution uncheck "is initial view controller". property in deployment info still set, launching fails because cannot find default view controller in storyboard. instead code execute in didfinishlaunchingwithoptions executed, result window start intended interface.

paypal - Payment Gateway actions -

i'm developing asp.net site , want integrate payment collection. user buys credits , can action depending on balance. dont want integrate payment gateeway, complex. paypal has 2 options standard , pro. prefer standard. two issues: the user logged site. can use same credentials payment gateway without user typing in details again (or @ least limit) when comes payment section using non-integration method? after makes pament via payment gateway, want user able carry out action (as have balance). if payment made , verified add x credits application. possible without integrated solution? i havent yet decided on payment provider yet, open suggestions. think paypal fit though. hope can assist pls? thanks you can use paypal apis these easily. make sure rbi let it, name indian, guess doing paypal account of india. before taking step must contact paypal support via email / phone. 'coz on developer site http://developer.paypal.com lot of great apis when come use 

knockout.js - Improving CodeCamper with pagination -

i've been watching john papa's awesome video on pluralsight building spa. now, i'm trying implement pagination sessions page , i'm not sure if i've done right way it. i'd appreciate feedback if has attempted similar. here's i've done. sessions.html <section> <footer> <ul class="pager"> <li> <button class="btn btn-info btn-small" data-bind="click: previous, enable:canprev"><i class="icon-angle-left"></i>previous</button> </li> <li> <button class="btn btn-info btn-small" data-bind="click: next, enable: canprev">next<i class="icon-angle-right"></i></button> </li> </ul> </footer> </section> sessions.js var currentpage = ko.observable(), activate = fu

sql server - Assigining primary key column value to foreign key column -

i have 2 tables called visitormaster , supportvisitor . in visitormaster have column called visitorid1 primary key (but not identity column). in supportvisitor have column called visitorid2 acts foreign key visitormaser table.but requirement want last generated column value of visitorid1 inserted in visitorid2 of supportvisitor table. how achieve this.. please help?? i'm thinking best bet ensure wrap insert visitormaster table transaction , within transaction obtain value of visitorid using data you've inserted query , putting supportvisitor before either committing or rolling lot. you use trigger triggers nasty things can have kinds of unintended consequences since operate more or less invisibly i'd steer clear of them. ultimately though i'd ask why have got non-identity surrogate pk in 1 column? it's pretty bad bit of design. either use natural key (combination of forename, surname, timestamp or whatever makes natural unique key) or u

Yii create BaseController for Layout -

i reading link " how implement multiple page layouts in application " easy until says: use controller layout , have better create basecontroller in protected/components/basecontroller.php ,it easy , created php file content: abstract class basecontroller extends ccontroller { public $crumbs=array(); public $portlets=array(); public $portlets2=array(); } and put these lines main.ph in components section: 'basecontroller'=>array( 'class'=>'application.components.basecontrollert', ), and when use in layout: $this->portlets it return property "homecontroller.portlets" not defined. which means inside main controller variable. how solve problem ? all layout code written according link link . you forgot controllers must extends class. read : http://www.yiiframework.com/wiki/28/#hh1 then can derive base class each individual concrete controller class

jaxb unmarshalling creates duplicate list of objects : How to unmarshall objects in lists? -

jaxb unmarshalling creates duplicate list of objects : how unmarshall objects in lists? xml file , code shown below while unmarshalling reading elements getting duplicate list using jaxb annotations , final out put duplicate list <data_reading> <load_survey> <interval_settings value="30" xunit="mins" /> <measurement name="energy_real" xunit="kwh" /> <reading interval="00" value="000.010" /> <reading interval="01" value="000.000" /> <reading interval="02" value="000.050" /> <reading interval="03" value="000.080" /> <reading interval="04" value="000.010" /> </load_survey> </data_reading> these classes @xmlaccessortype(xmlaccesstype.field) public class loadsurvey { @xmlelement(name="interval_settings&q

git pull one version but push another -

in git bash on local branch wrote: git pull production master i checked files , seem same ones in remote server.. everything's ok. afterwards wrote: git add . git commit -m 'ggggg' and here weird part: response was: "nothing commit working directory clean". this strange because before pulled remote branch many files different you can guess comes next- check if indeed local branch in sync remote 1 (and seem looking @ files) wrote: git push production master and ruined remote branch pushing old version (: so.. missing here? the command git pull changes working directory contents of remote. when completes working directory consistent git index/repository. thus, there nothing add nor commit . essentially, git pull add , commit automatically you. the problem may seeing result of being on branch other 'master'. pulled 'master' branch 'foo'; merged smoothly; pushed 'foo' 'master' , chan

c# - MEF not providing object -

update: this mvc plugin project, using mef controllers , actions @ run time. http://www.fidelitydesign.net/?p=104 i added new project , in class added export of type being composed. [export(typeof(icontroller)), exportmetadata("name", "clocks")] public class clockscontroller : controller { public xmlactionresult index() { var p = devicelogic.getunassigned; } [import(typeof(devicelogic))] devicelogic devicelogic { get; set; } } this gets composed in project: [export] public class importcontrollerfactory : defaultcontrollerfactory { [importmany] private ienumerable<partfactory<icontroller, icontrollermetadata>> controllerfactories; } application start [importmany] private ienumerable<importcontrollerfactory> controllerfactories; controller factories null, until compose parts container.composeparts(this); thats working fine, decided try , emulate devicelogic appear in project im ha

c# - mvc edditorfor disable -

i using code below allow users name added want admin user able add user name manually. common user view username apperars fro them, how go making interlinked data in editttor can viewd in label current code put in editor @html.editorfor(model => model.username) code changed @if (viewbag.isadmin == false) { @html.labelfor(model => model.username, new { id = "username" }) } else { @html.editorfor(model => model.username) } rendered code <label id="username" for="username">username</label> <input id="username" class="text-box single-line" type="text" value="" name="username" data-val-required="please enter user name." data-val="true"> @if (viewbag.isadmin) { @html.editorfor(model => model.username) } else { @model.username @html.hid

c++ - GPIO programming in C for raspberry PI -

i ve got gpio program in python .. me in getting equivalent c or c++ program run on raspberry pi .. the python code import rpi.gpio gpio import time # blinking function def blink(pin): gpio.output(pin,gpio.high) time.sleep(1) gpio.output(pin,gpio.low) time.sleep(1) return # use raspberry pi board pin numbers gpio.setmode(gpio.board) # set gpio output channel gpio.setup(11, gpio.out) # blink gpio17 50 times in range(0,50): blink(11) gpio.cleanup() thanks in advance! :) #include <header.h> // contatining delay function void blink(int pin) { //program pin (which gpio) high //delay function //program pin (which gpio) low //delay return 0; } main() { // use raspberry pi board pin numbers gpio.setmode(gpio.board) //check fun def , find out doing , code accordingly // set gpio 11 output channel // blink gpio11 50 times for(i=0;i<50;i++) blink(11); gpio.cleanup() //

c# casting to and from interface types with generic types -

i have class mockrepository implements interface irepository , have class technology implements interface iidentifiable . i want cast object mockrepository<technology> irepository<iidentifiable> , cast again after operations complete. possible? code compiles when try run invalid cast exception. short answer no. if have interface imyinterface<t> compiler create new interface each type of t use , substitute values of t. to give example: i have interface: public interface imyinterface<t> { public t value {get; set;} } i have 2 classes: public class foo {} public class bar : foo {} i define following public class orange : imyinterface<foo> {} public class banana : imyinterface<bar> {} the compiler automatically create 2 new interfaces using specific name convention, i'm going use different names highlight different public interface randominterface { foo value { get; set; } } public interface alternati

codeigniter 2 - Text abbreviation from a string in PHP -

i trying create webshop scratch using codeigniter 2.x. store have products it's own manufacturers such glock, colt, kalashnikov, boker, cz, kizlyar, groundzero , etc... i need create unique sku (stock keeping unit) name each products mixed product.id , product.manufacturer . there no problem it, i.e.: sku product id=13 , manufacturer=groundzero , name=striker ii becomes: groundzero-0013 i need generate abbreviation sku becomes this: grzr-0013 or gnzr-0013 any solution? i coded following sku generator depending on specs mentioned, may change $l make more unique (in way): echo sku_gen('zeroground', 13, 2).'<br>'; // zrgr-0013 echo sku_gen('zeroground', 13, 3).'<br>'; // zrgrn-0013 echo sku_gen('glock', 14, 3).'<br>'; // glc-0014 echo sku_gen('cz', 15, 3).'<br>'; // cz-0015 echo sku_gen('kizlyar', 20).'<br>'; // kz-0020 function sku_gen($string,

ios - Looping through all cells in UICollectionView -

i have uicollectionview , want add animation each cell. currently i'm using for(uicollectionview *cell in collectionview.visiblecells){ //add animation cell here } but applies animation visible cells , scroll down , cell no longer visible animation stops. how loop through cells in uicollectionview ? i go in different way, probably. if want cells animate, set property shouldanimate = yes . in collectionview:cellforitematindexpath: check property , apply animation if needed (or remove it). after setting property, reload visiblecells: [collectionview reloaditemsatindexpaths:collectionview.indexpathsforvisibleitems] . now, since animation provided when cell requested through datasource-protocol, animation when scroll.

javascript - Migrating from asp.mvc application to node.js application with a focus on design -

i looking alternative platforms migrate existing application onto, started out prototype using asp.mvc majority of code javascript simple asp mvc web service looking @ taking forward seems sensible scrap current microsoft stack , go nodejs giving more freedom of , how host our application, can reuse of models , code in both web service , front end, although end being small amount. this quite large question encompassing many parts put out there anyway sure helpful lots of other people looking @ how can move .net/java to node.js. of these statically typed languages have lots of patterns , practices used, such inversion of control, unit of work, aspect oriented programming etc seems bit strange moving towards platform doesn't seem require structure in area... have concerns migrating super structured , tested world new seemingly unstructured , dynamic world. so here main things in mvc , want in node.js not quite sure best way achieve same level of separation or functionality.

javascript - one dropdown, 2 radios, 2 inputs -

ok, hard explain in native language try clear possible. i have 1 dropdown different options. after choosing 1 of them, user need check 1 of 2 radio buttons give results in 2 different input fields. example - if choose option 2 dropdown, , check radio button 1, input 1 shows value , input 2 shows other value. <select id="single"> <option>select item</option> <option data1="140x200" data2="1">80x190</option> <option data1="140x200/220" data2="2">80x200</option> <option data1="140x220" data2="3">80x210</option> </select> <input type="radio" id="radiobutton1" name="radiobutton" value="enkel" /> <label for="radiobutton1">enkel</label> <input type="radio" id="radiobutton2" name="radiobutton" value="dubbel" /> <label for=&quo

CSS: How to move hint box (a:hover) to the left? -

i have hints in boxes, wich made this: css code: a span { display:none; } a:hover span { position:fixed; display:inline; border: 1px solid #0000ff; margin: 0px 0px 0px 10px; padding: 5px; color: #000000; background: #faffc3; opacity:.90; } html code, hint between span tags, , inside a element: <div> text, <a href="#">link<span>hint.<br>second line of hint.</span></a> , text, , <a href="#">link<span>hint</span></a>. </div> is possible move hint's box right side of link (default position), left side using css properties? ps. sorry english. a { position:relative; } span { display:none; } a:hover span { position:absolute; display:inline; border: 1px solid #0000ff; margin: 0px 0px 0px 10px; padding: 5px; color: #000000; background: #faffc3; opacity:.90; right:0; margin-right: 105%; } demo

apache - How can I decrease the memory usage when upload a big file use Apache2? -

i need upload files >500m. apache2 store in memory , dump disk. how can let apache2 write disk directly? probably need implement module buffer, can adjust parameters according i/o filters stack size. detailed description here: http://httpd.apache.org/docs/2.4/mod/mod_buffer.html and overview filters - http://httpd.apache.org/docs/2.2/filter.html for file uploads should exist appropriate modules apache2 - https://modules.apache.org/ or maybe better upload big file in chunks...

java - "Clean" way to interrupt a thread which could be doing something -

ok, let's have thread executes while() loop. during loop, , go sleep: public void run() { while (some_condition) { dosomelongjob(); // long job try { thread.sleep(a_bit); // sleep } catch (interruptedexception ie) { handleinterruptionbutdonotexitloop(); } } } some questions: if interruption comes during execution of dosomelongjob , method continue natural end? (i suppose yes long no-one checks thread.interrupted() i'd confirm); after catching interruption, interrupted() status reset false? in conclusion, thread can interrupted n times long thread status reset? there way reset manually thread status in order handle interruption during execution of dosomelongjob ? to answer questions: when interruption mean interruptedexception? if so, think should move dosomelongjob inside try handle possible exception. it not reset false, have manually. to reset interrupted status, please cal

SQL injection in PHP, sprintf and numerical values -

this question has answer here: how can prevent sql injection in php? 28 answers i'm trying make queries safe sql injection , luckily, variables targeted integers or floats, wondering if, in case, enough use sprintf() (not using mysqli_real_escape_string()). made few tests, , moment looks good, since parses input float/integer, no sql statement should executed. there way hack this? looks easy , wonderful me :d why don't use prepared statements? give better protection fron sql injection plus may improve query performance if reused.

ruby on rails - How to map id to name in active admin index? -

i using active admin. have project , user model many many relationship between them. in user model have project_leader boolean column. , in project model have project_leader integer column. allowed select 1 project leader each project. , id of user project leader stored in project project_leader column. how map id of user name active admin index? solved: in project model defined method following. def get_associated_user p = self.project_leader user = user.find(p).full_name end and active_admin index called method object.get_associated_user

objective c - UIImageView UIViewContentModeScaleToFill - image Streches when using this -

this question has answer here: difference between uiviewcontentmodescaleaspectfit , uiviewcontentmodescaletofill? 3 answers i using uiviewcontentmodescaletofill fill image in imageview . image looks streched . how fix this? you can't fill in imageview , @ same time have preserve aspect ratio. if want image not stretched use: uiviewcontentmodescaleaspectfit find more details here

tex - Toolchain for Topic Maps data export -

i planning typeset data stored in topic map. topic map can exported in variety of xml , json topic maps formats. use context typesetting. it's possible use xslt printable version of data, perhaps there better solutions. can suggest tmql tools instance? or maybe different approach? almost 3 years have passed , since have managed finish big project has sparked question, think can share of experiences. the topic map created in topincs program , first idea export topic map in 1 of common formats, transform , typeset output of transformation. in end have used native topincs api generate source text context. quite simple topincs generates set of functions each topic type can used in definitions of web services. of course, might possible define number of web services needed. have settled 1 exports complete text context commands included ready typesetting. for project have set toolchain in data output topincs service yaml file , used directly middleman program generates

c# - gridview data export to excel in asp.net -

i tried transfer grid view data excel .... output blank excel sheet.how solve problem?is there code transfer grid view value excel sheet data base? protected void btnexcel_click1(object sender, eventargs e) { response.clear(); response.buffer = true; response.addheader("content-disposition", "attachment;filename=gridviewexport.xls"); response.charset = ""; response.contenttype = "application/vnd.ms-excel"; stringwriter sw = new stringwriter(); htmltextwriter hw = new htmltextwriter(sw); gvdetails.allowpaging = false; gvdetails.databind(); gvdetails.headerrow.style.add("background-color", "#ffffff"); gvdetails.headerrow.cells[0].style.add("background-color", "green"); gvdetails.headerrow.cells[1].style.add("background-color", "green"); gvdetails.headerrow.cells[2].style.add("background-color", "green"); (

vb.net - Changing the location of an existing VBA Reference from C:\Windows\system32\ to a shared drive -

Image
i've been trying while reference file loaded externally no avail. to specific trying load "microsoft date , time picker control 6.0(sp4)" resides in c:\windows\system32\mscomct2.ocx however people run macro containing element don't have "mscomct2.ocx" file on pcs thought move mscomct2.ocx shared location , reference code use shared 1 instead (so have access it) i tried doing when trying load reference "browse" different location didn't load - because had in c:.. so thought ok... remove file c:\ can reference shared file. - deleted it. open workbook again , @ references - cant find "microsotft windows common controls-2.6.0(sp4)" - great! , proceed add manually browse shared drive. when 2 references of "microsotft windows common controls-2.6.0(sp4)" being added - 1 c:\(which not there) , 1 shared drive. activex control rereferences always guid-based. vb ide shows current location of file listed in registry o

How to add a basic signup form to a Concrete5 page template -

i'm new concrete5 , have found ton of information on adding contact forms, editable area of page. what need form page template. it's name+email+submit button form appear on every page template. on submission, 'thanks' message... that's it! i've tried copy/pasting code outputted page content default.php template no luck that. in advance help. you should create (global) editable area in template, , add contact block otherwise. e.g.: <?php $a = new globalarea('contact form'); $a->display(); ?>