Posts

Showing posts from February, 2011

objective c - UIImageView Clip Subviews in code -

i have been able behavior want using xcode , attributes inspector. have found lot of information here on stackoverflow. problem cannot resolve cropping image in code uses pixels rect have in points. help! this trying do: have image full size on iphone. want capture portion of center of image. want portion size of rectangle. in xcode, created view uiimageview uiimageview view mode = center , clip subviews checked. then, in code set image. voila! image cropped @ center , displayed in rectangular shaped view. can please me in code? i've been trying different approaches days....feeling pretty dumb now. thank in advance help.

vb.net - Accessing the key/value of a dictionary -

how access key/value of dictionary? have code: try if keystrokedictionary.containskey(letter) keystrokedictionary.keys.equals(letter) end if catch ex exception msgbox(ex.message) end try return letter letter single letter gets passed in string value. keystrokedictionary dictionary information looks this: {[65, 0]} {[66, 1]} {[67, 2]} where key first number , value second number. since code isn't looking @ key/value right, it's not returning letter, , therefore not working. .equals() not assignment operator, comparison function. try letter = " "; if keystrokedictionary.containskey(letter) letter = keystrokedictionary.values(letter) end if return letter

php - how to refresh Select2 dropdown menu after ajax loading different content? -

i'm using select2 in combination of dropdown menus. have 1 menu "countries" , 1 "states/provinces". depending on country chosen, "states/provinces" dropdown changes in content. states/provinces pulled ajax database , displayed way: $display_output = '<select style="width:350px;" tabindex="2" name="state" id="state" data-placeholder="choose country..."> '; $display_output .= '<option value="" selected>select state</option> '; while ($state_details = $this->fetch_array($sql_select_states)) { $display_output .= '<option value="' . $state_details['id'] . '" ' . (($selected_value == $state_details['id']) ? 'selected' : ''). '>' . $state_details['s.name'] . '</option>'; } $display_output .= '</select>'; so far, good. provinces change correctly

laravel - Complicated Eloquent Relationships -

i have many-to-many relationship, users , roles, have worked out fine. however, have table relate well, called leads. user , user's role can assigned lead. so example, i've created role , let's call 'manager'. now, when managing users, i'd need able assign different users different roles many-to-many relationship (a role can have many users, user can have many roles). assign role of 'manager' user a. now, when modifying leads, i'd able assign role_user lead (in example, i'd assign user lead), i'd first need assign role lead (manager), , able assign user of role lead. currently, i've got many-to-many relationship setup users , roles, using pivot table name role_user . i've got many-to-many relationship setup on pivot table, role_user , , leads , using pivot table named lead_role_user . models + controller - http://paste.laravel.com/d6h my error: call undefined method illuminate\database\query\builder::roles() it

Model has 2 foreign keys. Cant insert foreign key into the table of an other table. mysql database. ruby on rails app -

i having problems rails application. have 3 tables( skill, version, , skillversion). skillversion has 2 foreign key columns skill , version) have form skillversion , every time add skill associated version, should add skill , use version drop down list(gets list version table). issue: when submit form. adding new version row in version table different id. dont want add different row if similar version exists. after submitting skillversion table, should id of existing version , add version_id column in skillversion. please , let me know if need more information. attaching relevant code project. right now: doesnt add value skillversion table model/skill.rb class skill < activerecord::base has_many :skillversions end model/skilversion.rb class skillversion < activerecord::base belongs_to :skill belongs_to :version end model/version.rb class version < activerecord::base has_many :skillversions end controllers/skillversions_controller.rb def crea

gettext - get a char inside a span of a div -

<div id = "board_code"> <div> <span>r</span> <span>o</span> <span>w</span> <span>1</span> </div> <div> <span>r</span> <span>o</span> <span>w</span> <span>2</span> </div> </div> i trying string ' 2 ' used comparison char { [ ( < ' " i tried this: alert($('#board_code > div').eq(1).eq(3).text(); output is: blank when tried this: alert($('#board_code > div').eq(1).eq(0).text(); output is: row2 $("span").last().text() that work, i'm not sure if it's enough needs. http://jsfiddle.net/6r2np/1/ $("#board_code span").last().text() that 1 might better. http://jsfiddle.net/6r2np/2/

how can I delete partial entry in excel -

my excel sheet looks this: 147(abc) 133(2011) 177(1a0) this how want change: 147 133 177 yes, possible formula. like: =left(a1,find("(",a1)-1) (copied down) a1 reference adjusted if necessary. (then copy results, paste special values on top , can delete source data.)

ajax - Issue with $(document).ready -

i'v got 2 questions. first. how can reduce code? $('#m').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/main.php').fadein('normal'); return false; }); $('#b').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/blog.php').fadein('normal'); return false; }); $('#p').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/portfolio.php').fadein('normal'); return false; }); $('#l').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/lebenslauf.php').fadein('normal'); return false; }); $('#k').click(function() { var href = $(this).attr('href'); $('#con').hide().load('inc/kontakt.php').fadein('normal'); retur

How to make python tkinter root close itself only? -

i have number of roots (frames) in program. how set command os's exit button (the x @ top of panel)? want make can close 1 pane, not entire program. found code making own exit button on frame itself, don't want have reset position of buttons have. edit: forgot mention i'm using ubuntu edit2: root3 = tk() root = tk() root2 = tk() this how i'm initializig objects 3 frames (i don't have enough reputation post images). looked @ toplevel , think bryan oakley means should this: frame1 = toplevel() frame2 = toplevel() frame3 = toplevel() however, doing makes fourth (empty) frame appear, while 3 need still intact widgets need present. could explain difference between using tk() , toplevel() , how each meant used? i attempted use fredrik's solution received following error: traceback (most recent call last): file "gui_robot_control.py", line 823, in <module> root.protocol("wm_delete_window", root.destroy()) file &

excel - Rolling Date Macro -

i'm using office 2003 create rolling forecast. have starting point , end point time interval (yr/month yr/month) need populate automatically @ intervals (i need macro can assign button or of sort). not know how code vb, , i'm having trouble trying formulate way record along these lines. so, use help. to start, need interval 201308-201412 every month need drop past month (eg next month interval become 201309-201412) once start of interval became 201404, end of interval jump 201512. this process continues on, past month dropped beginning of interval. once 201504 becomes beginning of interval, 201612 becomes end of interval (what had been 201512 before past month dropped). also, because lines getting deleted/added depending on month, there way make lines inserted again avoid overlapping data? (i using tm1, , have dbrw formulas traveling these dates- if you're familiar citrix/tm1) let me know if can explain else. thank you! i don't think need ma

c - Use GDateTime instead of localtime_r -

what advantage of using gdatetime instead of localtime_r in code: char time_str[100]; time_t t; struct tm lt; t = time(null); localtime_r(&t, &lt); strftime(time_str, 100, _("%y%m%d-%h%m%s"), &lt); gdatetime appears component of gnome library (glib). documented in glib, gdatetime structure (and set of methods) working date/time data, capable of representing (with microsecond precision) date/time 0001-01-01 00:00:00 9999-12-31 23:59:59.999999 . therefore, if (a) you're using glib (or willing pull in entire glib library 1 thing), and (b) need or have use increased range and/or precision provided gdatetime, then , advantage of using gdatetime instead of localtime_r have increased range and/or precision provided gdatetime.

refactoring - Eclipse refactor (rename) doesn't work anymore -

i don't know happened eclipse, lately can't refactor work. i rename method or field using refactor tool, seem try refactor; can see according name changes ok in same file i'm working on, but when it's done computing change, turns name was! don't know why. tried google it, didn't find answer relevant case, has experienced it? know how fix this? i suspect has svn plugin; it?

php - Saving values from checkboxes in my db -

i trying store values checkboxes inside database. far, able store last checkbox choice. afterwards, tried following someone's example, got confused. how ensure data being stored inside database? in table, column want contain information named "categories". rest, below (2 of them only) <tr> <td><input type="hidden" name="categories" value="categories">categories</td> <td> <div class="checkbox";> <label class="checkbox_label"> <input name="cats" value="accessoires" type="checkbox" class="checkbox1"/> accessoires </label> </div> <div class="checkbox";> <label class="checkbox_label"> <input name="cats" value="

python - Passing a list from an imported module -

i have file function defined, imports , organizes data list of lists. returns list of lists, , functions fine within same file (if write main function , call import function, no problems). def import_viscosity_data(size_of_header): ... return (list_of_lists) i'm trying call function file in same directory, using following: import load_files print(load_files.import_viscosity_data(7)) unfortunately, keeps returning 'none', , if try length of returned array, throws error:typeerror: object of type 'nonetype' has no len() i'm guessing it's passing me reference list, , actual list gets deleted function terminates, i'm not sure how resolve problem. appreciated! here's code: import os import tkinter tkinter import filedialog #import decimal decimal import * def import_viscosity_data(size_of_header): ### function imports viscosity data multiple files, skipping ### header passed inof form shearrate '\t' viscosity , p

controller - Setting rails routes to url path -

i'm new rails , having problems routes. when link gets submitted, should go ' http://example.com ' although goes localhost:3000/links/www.example.com running ruby 3.2.8 , ruby1.9.3p194. not sure how info needed. here's it's at. in view have: <p> <h1><%= @link.title %></h1> <%= link_to @link.url, @link.url %><br /> <p>posted by: <% @link.user %> @ <%= @link.created_at %></p> </p> my controller set as: class linkscontroller < applicationcontroller def show @link = link.find(params[:id]) end before_filter :authenticate_user! def new @link = link.new end def create @link = link.new(params[:link]) respond_to |format| if @link.save format.html { redirect_to @link, notice: 'link created.' } format.json { render :json => @link, status: :created, location: @link } else format.html { render :action =

Lua Corona SDK Conflicting Event Listeners -

[solved] looking, figured out. needed un-nest return true statements in of if conditions. i have started learning lua week, , have started program 2d side-scroller game using corona sdk. in game, player's character moved pressing buttons displayed on screen virtual game pad. these buttons work perfectly, however, problem have a runtime:addeventlistener("tap", onscreentap) event listener calls shoot() function fire projectile player whenever tap registered. results in projectile firing every time lift touch 1 of movement buttons. is there way can stop shoot function calling when finish touching 1 of movement keys? have tried display.getcurrentstage:setfocus() and putting return true at end of movement functions nothing seems work. you can use basics in every touch function have.. or touch events. combining touch events in single function may solve problem. function inbounds( event ) local bounds = event.target.contentbounds if even

python - Spectral Hashing of images for matching with hamming distance -

i looking python implementation of spectral hashing or semantic hashing algorithm images. works on hamming distances can store in database mysql or postgresql. i have read using gist determine descriptors of image , using spectral hashing, lsh or rbm. however, don't know how implement in python. so far have found lsh code in python, don't know if generates binary hash hamming distances. i have tried phashing, doesn't work nicely object recognition in images. i don't want large arrays of keypoint descriptors have calculate euclidean distance, slow or need special data structures match other images. thanks you can try package: https://github.com/wanji/hdidx . implements product quantization algorithm proposed herve jegou :)

Cannot populate POJO with JSON using Jackson -

i'm trying populate pojo json doesn't match in way , having trouble getting resolved. can't change json since external service maybe able modify pojo if needed. below example json: {"sparse":[{"pixid":1,"pixname":"swe","description":"unknown"},{"pixid":2,"pixname":"pumnw","description":"power supplement"}],"status":0,"message":null} below pojo: @jsonignoreproperties(ignoreunknown = true) public class pix { @jsonproperty("description") private string description; @jsonproperty("pixid") private int pixid; @jsonproperty("pixname") private string pixname; // getters , setters } and here code conversion: objectmapper om = new objectmapper(); om.configure(deserializationconfig.feature.accept_single_value_as_array, true); om.configure(deserializationconfig.feature.fail_on_unkn

Rails - Iterating through records witin a method -

i have method iterates through various models, printing out model attributes: def self.get_attributes(options = {}) options[:model_name].find(:all, :conditions => {:generated_at => options[:start_date]..options[:end_date]}).each |p| puts p.options[:col_name] end to call method: start_date = datetime.strptime(params[:start_date], '%m/%d/%y').beginning_of_day.strftime("%y-%m-%d %h:%m:%s") end_date = datetime.strptime(params[:end_date], '%m/%d/%y').end_of_day.strftime("%y-%m-%d %h:%m:%s") get_attributes({:model_name => revenue, :col_name => "revenue", :start_date => start_date, :end_date => end_date}) i have tried passing in column name string , variable. when passed variable undefined variable exception. above, undefined method 'col_name' exception. how can interpolate column name within above method? you represent column/method name symbol (e.g. :revenue ) , invoke __send__ in: p.__se

debugging - How to find out what is throwing an exception using windbg -

i have c# windows service throwing exception. have launched service using windbg , have let run until exception thrown. when debugger stops do: prefer_dml 1 !threads. prints out threads , click on exception in question. i click on _message , displays: 0:018> !dumpobj /d 0105e134 name: system.string methodtable: 79b9f9ac eeclass: 798d8bb0 size: 120(0x78) bytes file: c:\windows\microsoft.net\assembly\gac_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll string: object reference not set instance of object. then do: !clrstack , following: 06f8e090 04d48299 ad.intellex.driverservice.servercomponentmanager.stopcrossfire() 06f8e098 04d48214 ad.intellex.driverservice.windowsservice.onstop() 76b5e8\system.serviceprocess.ni.dll 06f8e108 04d48177 ad.intellex.driverservice.windowsservice. unhandledexceptioneventhandler (system.object, system.unhandledexceptioneventargs) 06f8e4cc 791421db [gcframe: 06f8e4cc] 06f8e568 791421db [gcframe: 06

javascript - Can i check value of onclick="" with jquery? -

i working on ajax / php pagination system , having problem adding class active right link style selected. so question can value of onlclick="" jquery? my links shown as: <li><a href='#' onclick='fetchresults(" + adresultsdata.pages[i] + ");'>" + adresultsdata.pages[i] + "</a></li> now want see number inside onclick="fetchresults()" add class highlightactivepage if current active link/page. example: lets clicked on link 5, is: <li><a href='#' onclick='fetchresults(5);'>5</a></li> i have function check/output current page is: adresultsdata.current_page aka paginationhtml += pagespan.innerhtml = "<br>page " + adresultsdata.current_page + " of " + adresultsdata.number_of_pages; is somehow possible add class "highlightactivepage" a-tag same value adresultsdata.current_page ? sorry if seems bit messy,

checkout - Checked out an old revision in git, then returned to latest revision, but deleted files from old revision are still in local directory? -

while using git, checked out specific revision in master branch: checkout <branch hash> . i did take @ previous files, made no changes. attempted reset current state latest revision. unfortunately attempted several commands because wasn't sure if worked; commands included: checkout master . checkout head . reset head --hard i wasn't sure if worked @ first because of behavior indicated previous file of old revision present. i realized modified , new files indeed restored current revision, files deleted between old revision , current revision still in local directory. supposed occur? imagine no 1 want old, deleted files present after returning current revision, , yet appears case. i wondering if did wrong occur or if there command can use remove these unwanted files of temporarily checked out revision? see: git: when checking out alternative branch, want clear ignored files i believe you're looking git clean command. if quick git clea

objective c - Set UIAlert to appear after x amount of IBAction presses -

is there simple way of setting piece of code check amount of presses before using uialertview, for example, if ibaction has been pressed 30 times, show uialertview, can alert, it's figuring how count 30 presses? thanks both, have gotten little further, here code, using count int here; it works, aim if user has purchased upgrade count ignored... @ moment, if user upgrades, still uialert on every 30 presses - (ibaction)setrandomtext { selectedrecnumber = (arc4random() % kmaxrecords); nsstring *text = [alltext objectatindex:selectedrecnumber]; [randomtext settext:text]; count++; if (![mkstoremanager featurebpurchased] ) { if(count == 30) { count = 0; uialertview *alert = [[uialertview alloc]initwithtitle:@"limit" message:@"reached limit!" delegate:self cancelbuttontitle:@"no" otherbuttontitles:@"ok",nil]; [alert show]; [alert release]; }else{ } }

system verilog - systemverilog cast peculiarity -

my question regarding using $cast in sv. if search word cast in code below, have on purpose added '!' check unsuccessful casting. in event of unsuccessful cast, wanted see happens when call made bobsquare.bob(); surprised @ time=1ms when call_bob called handle polygon 'p', function 'bob' in square class called perform display statements. how can possible? ran cadence's irun , debugged sv class browser , see @ time=1ms, bobsquare not allocated mem space , has null pointer. thanks! class figure; endclass class polygon extends figure; virtual function void draw(); $display("polygon::draw"); endfunction endclass class square extends polygon; virtual function void draw(); $display("square::draw"); endfunction function void compute_area(); $display("square::compute_area"); endfunction function void bob(); $display("square::i bob"); $display("%t", $realtime);

android - Uncaught TypeError: Object #<Object> has no method 'exec' at file:///android_asset/www/js/webSocket.js:51 -

i using websocket programming here. https://github.com/knowledgecode/websocket-for-android.but after following steps getting error.i using cordova 2.7 .can please tell me how sove prolem uncaught typeerror: object #<object> has no method 'exec' @ file:///android_asset/www/js/websocket.js:51 here html file.. <html> <head> <meta charset="utf-8" /> <meta name="format-detection" content="telephone=no" /> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> <link rel="stylesheet" type="text/css" href="css/index.css" /> <title>hello world</title> </head> <body> <div class="app"> <h1>apache cordova</h1>

gradle - astyanax cassandra: The type org.apache.cassandra.thrift.Cassandra$Client cannot be resolved. It is indirectly referenced from required .class files -

my internship needs me familiar cassandra. downloaded astyanax cassandra from: https://github.com/netflix/astyanax after building astyanax source via commands: git clone git@github.com:netflix/astyanax.git cd astyanax ./gradlew build i created new java project , copy+paste sample code here: https://github.com/netflix/astyanax/blob/master/astyanax-examples/src/main/java/com/netflix/astyanax/examples/astcqlclient.java now problems arose. did fix path configuration, importing .jar files generated gradlew build. 1 (long)line of code highlighted red dash: context = new astyanaxcontext.builder() .forcluster("test cluster") .forkeyspace("test1") .withastyanaxconfiguration(new astyanaxconfigurationimpl() .setdiscoverytype(nodediscoverytype.ring_describe) ) .withconnectionpoolconfiguration(new connectionpoolconfigurationimpl("myconnectionpool") .setport(9160) .setmaxconnsperhost(1) .setseeds("127.0.0.1:9160") ) .withasty

php - PayPal IPN Stuck at Payment Verify -

i have been working time on this, , have yet find solution. attempting paypal ipn work, have yet successful @ doing so. first, having trouble connecting ssl, went without now. after that, seemed getting other issue. went ahead , added debug, , have found getting stuck @ verify check. know going on. below paypal ipn, , below that, button code. <?php include("inc/database.php"); $debug = true; $header = ''; $req = "cmd=_notify-validate"; foreach($_post $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $header .= "post /cgi-bin/webscr http/1.1\r\n"; $header .= "content-type: application/x-www-form-urlencoded\r\n"; $header .= "host: www.sandbox.paypal.com\r\n"; // www.sandbox.paypal.com test site $header .= "content-length: " . strlen($req) . "\r\n\r\n"; if ($debug) { $ourfilename = "pdebug.txt"; $ourfilehandle = fope

testing - Provide annotations (similiar to testNG in Java) to group Python Selenium Tests -

i'm refactoring suite of selenium tests written in python. when did java few years back, used testng annotate , group tests (smoke test, regression, etc). ant script allowed user run set of tests, using testng directive select group execute. is there similar selenium w/python? tia

email - Is there any IMAP packages published on Dart pub? -

i know there's mailer package sending emails need comprehensive imap library javamail one, supports gmail extensions can retrieve conversations , email contents/attachments thread. is google planning publish package gmail support or there planning write 1 himself? no, far know, there no imap package. referenced in comments, there mailer package on pub lets send email smtp.

How can i fill color for dataseries below or above the threshold using Flot? -

how fill color below or above threshold. threshold plugin changes line of color need fill color on dataseries (eg: below : 5 or above :5 ) when line drawing on canvas using flot line chart. can suggest me. thanks are saying fill color doesn't change above/below threshold, or want show fill if above/below threshold? if former, works me setting fill true in series options: $.plot("#placeholder", [{ data: d1, threshold: { below: 5, color: "rgb(200, 20, 30)" }}], { series: { lines: { show: true, fill: true } } }); see fiddle working example.

c# - MMORPG's and Game Clients -

i want know how make client of mmorpg's see out there have client reads game files launches game. know clients written in c++, unfortunately don't language, know c#. i'm not looking make entire client, since me , friends want make small 2d game, need client reads external data files holds sound, images, etc, , calls server, once receives response sends ip , launches client. since i'm not great drawer got stuck creating client. made small function calls server port , checks if online: public static void serverstatus() { try { tcpclient client = new tcpclient(); networkstream stream; streamwriter writer; binaryreader reader; ipaddress ip = ipaddress.parse("string ip"); client.connect(ip, 8484); if(client !=null) { stream = client.getstream(); reader = new binaryreader(stream); writer = new st

actionscript 3 - Loading a TLF text inside a symbol -

i got symbol has tlf text placed, , need retrieve information of text , use it. thing is, everytime kind of text on stage, weird result, in content of currenttarget of load result, instead of children of movieclip maintimeline__preloader. <- this?, , why tlf text break symbol?. do guys know of way this?. thanks. (the classic text works, but, don't informatino it, i'd have info font used, style, etc, think tlf text used this, correct me if im wrong). frankly, tlf text horrible beast , messes swf if not used absolutely correctly. luckily can details on formatting used in classic text using gettextformat method so: var textfield:textfield; var textformat:textformat; textformat = textfield.gettextformat(0,0); //replace these numbers in text want read formatting trace(textformat.color) trace(textformat.font) trace(textformat.bold) trace(textformat.italic) //etc

ssis: How to format output value to have 0.0000 in front -

i have sql statement selected value 0.0000 tables. however when file generated in ssis, value become .000. is there anyway format value 0.000? if need write script component how go doing it? try converting value string before writing file. assume name of field, derived column be a < 1 ? "0" + (dt_str,10,1252)a : (dt_str,10,1252)a

c# - Streamwriter crashes when writing to existing file -

here code have writes couple of files: streamwriter writer = new streamwriter(@"c:\totalstock\data\points\" + stockname.toupper() + ".txt"); for(int = 0; < lines; i++) { writer.writeline(linedata[i]); postgui.send((object state) => { progressbar2.performstep(); }, null); } writer.close(); when delete text files , run code there no issue, when close application , run once more program gives me following error. causes error , can stop it? error: an unhandled exception of type 'system.io.ioexception' occurred in mscorlib.dll additional information: process cannot access file 'c:\totalstock\data\points\ibm.txt' because being used process as marc_s pointed out, error occurs because file trying edit opened application. if don't have file opened in other editor/viewer, problem may program itself. if several instances of same code run concurrently , require access same file, in multithread en

Asp.net website running error -

on running asp.net website deployed in local iis , got message user-agent: * disallow: / . why did message? how can overcome problem , run website successfully? thanks in advance this entry in robots.txt file. translated, means this: the user-agent: * means section applies robots. disallow: / tells robot should not visit pages on site. note: check in top-level directory robots.txt file , either remove or change configuration allow access.

java - CSS file not found if dynamically loaded with JSF -

i have problem dynamically loaded css files in jsf application running on tomcat 7. if load css file on static way like <link href="mystyle.css" rel="stylesheet" type="text/css"> all ok , web page looks fine. if trying load css file dynamically like <link href="#{pagemanagerbean.getcssfile()}" rel="stylesheet" type="text/css"> where pagemanagerbean.getcssfile() returns "mystyle.css", css file not loaded. browser gets tomcat "404 - not found". if doing browser refresh css file found , web site looks fine.

php - Doctrine2 Duplicate key name error -

i'm trying use doctrine2 migration , schema update symfony2's console. entities being generated no problems via: php app/console doctrine:generate:entities myproject also, able create database , build schema scratch no problems given following commands: php app/console doctrine:database:create php app/console doctrine:schema:create whenever modify, remove, or add in entity, regenerate entities with: php app/console doctrine:generate:entities myproject the problem however, whenever want update schema following error: [doctrine\dbal\dbalexception] exception occurred while executing 'create index idx_f7129a80a76ed395 on user_user (user_id)': sqlstate[42000]: syntax error or access violation: 1061 duplicate key name 'idx_f7129a80a76ed395' [pdoexception]

class - Change PHP Object Instance to a Parent -

i have class base has property called load object of class load. load class has function called view includes pages. need call, this similar codeigniter's $this->load->view("test.php"); load class class load { public function view($page){ //this function loads views display include($page); } public function model($class){ //loads model classes } public function library($class){ //loads libraries } } base class class base { function __construct(){ $this->load = new load(); } } index page $base = new base(); $base->load->view("test1.php"); this1.php echo "testing1\n"; $this->load->view("test2.php"); test2.php echo "testing2"; the output should be testing1 testing2 what want think follow factory pattern. (at least, that's mean if want $view variable contain instance of load class) make constructor

sql - how to make mysql sub query -

i have big table,now table subdivided several date e.g. the original table userlogintable +---------+------------+---------+ | userid | logintime | others | +---------+------------+---------+ | 1 | 2013-03-12 | .... | +---------+------------+---------+ | 2 | 2013-05-12 | .... | +---------+------------+---------+ | 1 | 2013-06-12 | .... | +---------+------------+---------+ | ... | ... | .... | +---------+------------+---------+ now table is: userlogintable_date(yyyymm) userlogintable_201303 +---------+------------+---------+ | userid | logintime | others | +---------+------------+---------+ | 1 | 2013-03-12 | .... | +---------+------------+---------+ userlogintable_201304 +---------+------------+---------+ | userid | logintime | others | //this table not have userid=1 +---------+------------+---------+ | 2 | 2013-04-01 | .... | +---------+------------+---------+ i used select count(*) userl

javascript - Parsing Json in Ajax, error -

code : $.ajax({ type: "post", url: "api url", data: json.stringify(user), datatype : "json", success: function(apiresponse) { var session = apiresponse.sessionid; console.log ("session : "+ session); $.ajax({ type: "get", url: "another url", datatype : "jsonp", contenttype: "jsonp", success: function(apiresponse) { console.log (apiresponse); jquery.each(apiresponse,function(){ console.log (apiresponse); }); }, error: function(apiresponse) { alert("error : " +apiresponse); } }); }, error: function(apiresponse) { alert(&

Getting polymorphism to work in a C++ map without memory leaks? -

it's been long 3 time since programmed in c++. polymorphism isn't working: map<string, base> converts armybase , navybase objects base objects when add them map , getdescription() returns empty string rather values set via armybase::setdescription() , navybase::setdescription() . here's extremely rough pseudo-code: class base { protected: string str__description; // pardon non-standard style public: virtual string getdescription() { return str__description; } void setdescription( string str__description ) { str__description = str__description; } } class armybase: public base { public: string getdescription() { return str__description + " (army)"; } } class navybase: public base { public: string getdescription() { return str__description + " (navy)"; } } it sounds map<string, base*> causes memory leaks , i'd rather not upgrade mid-project use shared_ptr . wo

Android: write bytes to image file on SD Card -

i'm trying create image file on sd-card, building bytes server sending towards me after calling web-service (basically: download file). managed "something" on client-side, , try write bytes file, using: fileoutputstream fout = null; bufferedoutputstream bos = null; try { fout = new fileoutputstream(returnedfile); bos = new bufferedoutputstream(fout); bos.write(bytestowrite); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (exception e) { e.printstacktrace(); } { try { if (bos != null) { bos.close(); fout.close(); } } catch (ioexception e) { e.printstacktrace(); } } but image file broken (its size > 0kb, broken). ended opening file on computer text editor, , saw of initial file data (before being sent), differs final one. i'm guessing there kind of encoding misstakening or that. appreciate idea of how m

node.js - Using Underscore or lodash in Nodejs for realtime computations ? Performance? -

i'd use lodash in nodejs project pluck,intersection,zip etc.. have mongodb collection 'onlineusers' , has 'params' array in every user(doc) .the redundant job app find intersection on params array of 1 user rest of users , find user2 user1 has interesected params . there might around 500-600 onlineusers want scale upto thousands. dont know if aggregation framework helps making array intersections using underscore or lodash in realtime finding intersections of 100 or 1000s arrays normal ? need response less 2s atleast . anyone benchmarks(pluck , intersection) great

c# - How to stop server process during a post on client side? -

i develop asp .net/c# mvc4 application users can click on button (post) let server running algorithm`. the process can long (several minutes) , if user closes window/stop loading server keeps running and, in application, insert data in db. i asked myself how possible stop server process application ? mean, if user realizes doesn't want run process anymore , likes stop insertion in database , how can ? you can create static class/singleton in service layer methods run , stop long process . in controller can make actions manage singleton user requests.

clojure - Use function in macro -

i have function load correctly namespace : (defn load-module [module-name] (use module-name) ) and "equivalent" macro doesn't work : (defmacro load-module-macro [module-name] `( (use '~module-name) ) ) i don't understand problem. moreover, want use macro load module choose in configuration. in config.clj define var namespace of logger module contains "save-data" function. want load specified logger in core program. can choose logger use directly in configuration file (logger on disk, logger in database...). best way ? edit : error message illegalargumentexception don't know how create iseq from: java.lang.character clojure.lang.rt.seqfrom (rt.java:505) no, in fact don't want use "use" directly in code @ all. use modifies entire namespace called in , break code in ways hardly predictable. instead should is: implement logging interface (protocol), write "meta-constructor" dispa