Posts

vb.net - Alternative to the T-SQL AS keyword -

please see code below: imports system.data.sqlclient imports system.configuration public class form1 private _constring string private sub form1_load(byval sender object, byval e system.eventargs) handles me.load dim objdr sqldatareader dim objcommand sqlcommand dim objcon sqlconnection dim id integer try _constring = configurationmanager.connectionstrings("testconnection").tostring objcon = new sqlconnection(_constring) objcommand = new sqlcommand("select person.urn, car.urn person inner join car on person.urn = car.urn , personid=1") objcommand.connection = objcon objcon.open() objdr = objcommand.executereader(connectionstate.closed) while objdr.read id = objdr("urn") 'line 19 loop objdr.close() ...

ios - CFRelease causing crash in iPad application -

i trying merge 4 images make 1 uiimage. when going cfrelease, crashing. if don't this, giving memory leak , crashing. how resolved? see below code. referenceview.frame = cgrectmake(0, 0, 1024, 768); referenceview.hidden = no; [self.view insertsubview:referenceview belowsubview:selfview]; imgview1.image = delegate.imagecroped; imgview2.image = [uiimage imagenamed:@"videobg.png"]; imgview3.image = [uiimage imagenamed:@"videochar.png"];; imgview4.image = smileview.image; imgview1.frame = cgrectmake(456, 311, delegate.imagecroped.size.width-30.8, delegate.imagecroped.size.height-40); imgview2.frame = cgrectmake(0, 0, 1024, 768); imgview3.frame = cgrectmake(392, 187, imgview3.image.size.width, imgview3.image.size.height); imgview4.frame = cgrectmake((smileview.frame.origin.x-((smileview.frame.origin.x > 530) ? 30 : 15)), (smileview.frame.origin.y+((smileview.frame.origin.y <= 307) ? 95 : 50)), smile...

python - Setting Tkinter default widgets kwargs -

how change default tkinter kwargs values widgets? i know can set general tkinter theme tk_setpalette(theme) computes , overwrites default values , tries use colors best matches new theme more control. for example, let's want change background color of tkinter widgets, i'd like: import tkinter tk color = 'blue' #this in constant or setting modules class custombutton(tk.button): def __init__(self, root, **options): tk.button.__init__(self, root, bg=color, **options) then if @ point want change background color blue red i'd need edit setting.py module. (background example, want change **kwargs) i'm sure there's better way , somewhere let's set default widgets values without overriding every single widget in wrapper class... i know asked couple of years back, same issue stumbles upon thread, here example of how incorporate generalised settings widgets: my_options = {"bg" : "gray60", "font" :...

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

i have php code pulls info database. uses prepared statement, works fine written below: <?php $n = '5'; if ($stmt = $connection->prepare("select title items id = ?")) { $stmt->bind_param("s", $n); $stmt->execute(); $stmt->bind_result($title); while ($stmt->fetch()) { echo $title; } $stmt->close(); } ?> and let's echo "batman". however, when move placeholder here: "select ? items id = 5" and change: $n = 'title'; instead of echoing "batman", echoes "title". not possible use placeholder select parameter? what have done this: select "title" items id = 5 you cant use prepared statement bindings identifiers, parameters.

python remove duplicates from 2 lists -

i trying remove duplicates 2 lists. wrote function: a = ["abc", "def", "ijk", "lmn", "opq", "rst", "xyz"] b = ["ijk", "lmn", "opq", "rst", "123", "456", ] in b: if in a: print "found " + b.remove(i) print b but find matching items following matched item not remove. i result this: found ijk found opq ['lmn', 'rst', '123', '456'] but expect result this: ['123', '456'] how can fix function want? thank you. here what's going on. suppose have list: ['a', 'b', 'c', 'd'] and looping on every element in list. suppose @ index position 1: ['a', 'b', 'c', 'd'] ^ | index = 1 ...and remove element @ index position 1, giving this: ['a', 'c', 'd...

PHP - include(); makes blank line -

hey when add include file @ tag creates blank line (grey) : http://puu.sh/40mvi notice: have seen few questions didn't helped me. <?php require("connection/mysql.php"); ?> <?php @session_start(); ?> <?php if(!isset($_session["language"])) { header("location: ./language/index.php"); } else { include("./language/".$_session["language"]); } ?> <?php if ( isset($_session["bay_username"]) ) { header('location: account/'); }?> <!doctype html> language file <?php // noconnect $lg["ncon_header"] = "bayyak powered sunucularına şu bağlanılamıyor."; $lg["ncon_text"] = "lütfen biraz sonra tekrar deneyiniz. en yakın zamanda sorunu çözeceğiz. İnternet bağlantılarınızı kontrol ediniz. diğer aygıtlarda da aynı hatayı alıyorsanız lütfen <em>error@bayyakpowered.com</em> adresine bu sorunu bildirin....

mysql - Order by date ASC, but DESC within group -

i have 2 tables. imagine first 1 directory, containing lot of files (second table). the second table (files) containing modification_date. now, want select directories , sort them modification date asc (so, latest modification topmost). instead of displaying folder, want display oldest mofified file (so, modification desc, group folder_id) sorting files modification date no problem. my query looks (simplified) this: select f.*, d.* files f left join directories d on f.directory_id = d.id order f.modification_date desc this gives me files in modification order (newest topmost) - now, want group files within folder, see oldest modification (they have "seen" attributes, taking account no big deal, once modification has been seen, second oldest displayed, etc...) how can sort result by modification_date desc , sort modification_date asc after grouping it? example: directories: id | name 1 folder 1 2 folder 2 files id | name | d_...

maven - How to use profiles or targets to get the values from xml properties file using a template file -

using maven or ant wanted values xml file , replace variables using targets/profiles. properties.xml looks this: <?xml version="1.0" encoding="utf-8"?> <variables> <variable id="title"> <book.01>abc</book.01> <book.02>def</book.01> <ebook.03>ghi</book.01> <ebook.04>klmn</book.01> </variable> <variable id="author"> <book.01>john</book.01> <book.02>jack</book.01> <ebook.03>simi</book.01> <ebook.04>laura</book.01> </variable> </variables> using maven or ant if select "book.01" target or profile, want replace values in template.xml values of "book.01" properties.xml current template.xml looks this: <?xml version="1.0" encoding="utf-8"?> <projects> <mbean code="org.jboss.namin...

javascript - Cant find variable Angular JS -

i following railscasts #405 on angular js , code uses follows app = angular.module("raffler", ["ngresource"]) app.factory "entry", ["$resource", ($resource) -> $resource("/entries/:id", {id: "@id"}, {update: {method: "put"}}) ] @rafflectrl = ["$scope", "entry", ($scope, entry) -> $scope.entries = entry.query() $scope.addentry = -> entry = entry.save($scope.newentry) $scope.entries.push(entry) $scope.newentry = {} $scope.drawwinner = -> pool = [] angular.foreach $scope.entries, (entry) -> pool.push(entry) if !entry.winner if pool.length > 0 entry = pool[math.floor(math.random()*pool.length)] entry.winner = true entry.$update() $scope.lastwinner = entry ] i tried implement similar in application practically same code issue when drawwinner function called browser logs error "cant find variable entry"...

.net - dropdown selected value is getting lost when inside a hidden asp:panel -

i have web form consisting of few asp:panels. 1 panel visible @ time. user fills forms next panel becomes visible. in second panel there dropdown list. i setting selectedvalue of dropdownlist on page load, if not page postback. when second panel becomes visible, dropdownlist not preselected. everything else prepopulated except dropdown list. there other dropdown lists on other hidden panels, prepopulated appropriately. furthermore, if move dropdownlist outside panel, works intended, meaning, selectedvalue prepopulated. if remove line panels set visible = false, dropdownlist gets populated fine. as add code hide panels , show them 1 one, selected value not there. here code protected sub page_load(sender object, e system.eventargs) handles me.load if not page.ispostback ... dropdownlist1.selectedvalue = .item("city") hideallpanels() ... end sub protected sub linkbutton2_click(byval sender object, byval e system.eventargs) handles linkbutto...

java - How should I use EasyMock's @Mock annotation (new in version 3.2)? -

it looks easymock version 3.2 supports using annotations setup mock objects. new easymock (and java in general) , trying understand how use this. these annotations new or provide alternative way things? documentation says: since easymock 3.2, possible create mocks using annotations. nice , shorter way create mocks , inject them tested class. here example above, using annotations: ... then there listing shows use of @testsubject , @mock annotations, don't understand how works. seems if magically sets private field of class under test mock object. in of cases, want make mock objects return pre-defined values use in junit test cases (don't care verifying ones called, how many times called, etc). example, tests want create fake httpservletrequest object this: public class sometest { // construct mock object typical http request url below private static final string request_url = "http://www.example.com/path/to/file?query=1&b=2#some-fragment...

Retrieve serial number from USB memory (Windows environment c++) -

i need retrieve serial number usb memory, namely hard disk's serial number manufacturer assigns. reason cannot use getvolumeinformation() suggested in other threads. need have "unique" number i kindly ask if can share example in c++ , windows environment (visual c++) thanks! you can check out article:- http://oroboro.com/usb-serial-number/ #include <winioctl.h> #include <api/usbioctl.h> #include <setupapi.h> define_guid( guid_devinterface_usb_disk, 0x53f56307l, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b ); void getdeviceinfo( int vol ) { usbdeviceinfo info; // device handle char devicepath[7] = "\\\\.\\@:"; devicepath[4] = (char)( vol + 'a' ); handle devicehandle = createfile( devicepath, 0, file_share_read | file_share_write, null, open_...

python numpy set elements of list by condition -

i want set specific element of list specific value low overhead. example if have : a = numpy.array([1,2,3,0,4,0]) want change every 0 value 10; in end want have [1, 2, 3, 10, 4, 10] in matlab can a(a==0) = 10, there equivalent in numpy? remarkably similar matlab: >>> a[a == 0] = 10 >>> array([ 1, 2, 3, 10, 4, 10]) there's nice "numpy matlab users" guide @ scipy website. i should note, doesn't work on regular python lists. numpy arrays different datatype work lot more matlab matrix python list in terms of access , math operators.

iphone - Sending NSString to viewController returns a null -

i sent nsstring viewcontroller, tried log viewcontroller, , turned null. code below edit: im deleting code , showing code application. because still getting (null) habitviewcontroller.h #import <uikit/uikit.h> @interface habitviewcontroller : uitableviewcontroller { nsstring *cellname2; } @property(nonatomic,retain) nsstring *cellname2; @end habitviewcontroller.m @synthesize cellname2; - (void)viewdidload { [super viewdidload]; nslog(@"%@",cellname2); } detailviewcontroller.h #import <uikit/uikit.h> @interface detailviewcontroller : uiviewcontroller { nsstring *cellname; } @property(nonatomic,retain) nsstring *cellname; @end detailviewcontroller.m #import "detailviewcontroller.h" #import "habitviewcontroller.h" @end @implementation detailviewcontroller @synthesize cellname; #pragma mark - managing detail item - (void)viewdidload { [super viewdidload]; cellname = @"hello w...

android - Facebook page's status updates -

i'm using facebook sdk 3. how can public status of special page in facebook without authentication? how can put list of of facebook page's status updates in android? i think can want facebook graph. go , read out documentaion paging section. find out answer.!! heres link, may help.: facebook graph api

c# - openfile dialog cancel crash -

i making basic word processor in c# training. making open file part of it. can open text file without issue. when open open file dialog , cancel it, crashes :/ private void opentoolstripmenuitem_click(object sender, eventargs e) { openfiledialog1.showdialog(); var openfile = new system.io.streamreader(openfiledialog1.filename); getrichtextbox().text = openfile.readtoend(); } i know because streamreader has nothing read not sure how solve this. thanks in advance! edit: thank you! worked :) you need check result of dialog: private void opentoolstripmenuitem_click(object sender, eventargs e) { if (openfiledialog1.showdialog() == dialogresult.ok) { using (var openfile = new streamreader(openfiledialog1.filename)) { getrichtextbox().text = openfile.readtoend(); } } } i've added using statement ensure file closed when you're done reading it. you can simplify code further using file.readalltext instead of mes...

php - Does the number of remote requests affects performance? -

i have photobook making site , i'm trying improve loading , saving performance. the photobook making tool displayed in web browser, done in flash, , remote calls database operations done through amfphp. the algorithm saving photobook says: foreach(page in photobook){ foreach(component in page){ //make remote call saves component in database } } this means if photobook has 30 pages, 10 components(photos) per page, tool create approximately 300 simultaneous connections without counting uploads connections. firefox example, seems ready create queue process requests. does affects performance @ all? will create queue controls number of simultaneous remote calls? is worth it? thank can give me. every request remote server result in time increase script execution. 3 queries database faster 3 remote requests. so yes performance heavily impacted 300 remote requests. best solution either paginate, or serialize of data in xml. though carefu...

linker - Compiling Glew and SDL in C++ with Code::Blocks -

i've spent last 24 work hours trying compile, using multiple searches , tutorials (some need link dynamically while others need statically), can not work. i'm relatively new compiling , linking appreciated. here code(as can tell comments tired last night coding this): #define no_sdl_glext #define glew_static #include "gl/glew.h" #include "sdl/sdl.h" #include "sdl/sdl_opengl.h" int main (int argc, char* args[]){ //loads sdl video module sdl_init(sdl_init_video); //creates sdl surface opengl draw sdl_surface* surface = sdl_setvideomode(800,600,32, sdl_hwsurface | sdl_doublebuf | sdl_opengl ); //sets caption... sdl_wm_setcaption("opengl",0); glewexperimental = gl_true; glewinit(); //main event loop, bread , butter ladies , gentlemen sdl_event windowevent; while (true){ if (sdl_pollevent(&windowevent)){ //if close appplication, causes stop running :d ...

gruntjs - Hard cache busting of assets w/ Compass -

i have hard cache busting compass, i.e. have hash-suffixed assets. compass using soft cache busting adding ?v parameter in query string, apparently not supported every cdn service, , avoid , encode file hash directly in filename ( myfile-2q7de.png ). is possible ? current approach copy assets, hash them all, write mapping file , use in minimal sass extension real file path it's non-hashed path. works great, except spritesheets : makes compass add hash sprites class names, makes them unusable : .sprite-myfile-2q7de { ... } i should add i'm using grunt this. compass adds hash cache buster in generated sprite sheets (eg icons-sf6a3361a01.png ). for other images, can use following code in config.rb , found in documentation : asset_cache_buster |path, real_path| if file.exists?(real_path) pathname = pathname.new(path) modified_time = file.mtime(real_path).strftime("%s") new_path = "%s/%s-%s%s" % [pathname.dirname, pathn...

python - find a number between a range of numbers -

i have file1 has ranges this 10 20 50 60 70 100 150 170 .... .... file2 15 55 80 160 .... .... i want read ranges in file1 , in file2 , values between them final output: 15 value between 10 , 20 55 value between 50 , 60 .... .... if want results other print them out, can create dictionary maps ranges (from file1) numbers within ranges (from file2.) ranges = [] open('file1') f: line in f: ranges.append(line.strip().split(' ')) ranges = [tuple(int(_) _ in r) r in ranges] in_range = {range_: set() range_ in ranges} open('file2') f: line in f: num = int(line.strip()) range_ in ranges: if range_[0] < num < range_[1] # between low , high in_range.add(num) # print in_range