Posts

Showing posts from July, 2015

objective c - Checking for iOS Location Services -

i have view map , button (like maps app once) allows user center , zoom current location on map. if can not use locationservicesenabled method (always returns yes), should create bool attribute check if didfailwitherror method called , know if can call button method? thanks reading. edited: this code not work me. using simulator. getting yes when asking locationservicesenabled. // gets user present location. - (ibaction)locateuser:(id)sender { if([cllocationmanager locationservicesenabled]) { cllocationcoordinate2d coordinate; coordinate.latitude = self.mapview.userlocation.location.coordinate.latitude; coordinate.longitude = self.mapview.userlocation.location.coordinate.longitude; [self zoomcoordinate:coordinate]; } else { [[[[uialertview alloc] initwithtitle:@"warning." message:@"location services disabled." delegate:nil cancelbuttontitle:@"ok" otherbutto

pointers - In C, what does a variable declaration with two asterisks (**) mean? -

i working c , i'm bit rusty. aware * has 3 uses: declaring pointer. dereferencing pointer. multiplication however, mean when there 2 asterisks ( ** ) before variable declaration: char **apointer = ... thanks, scott it declares pointer char pointer . the usage of such pointer such things like: void setcharpointertox(char ** character) { *character = "x"; //using dereference operator (*) value character points (in case char pointer } char *y; setcharpointertox(&y); //using address-of (&) operator here printf("%s", y); //x here's example: char *original = "awesomeness"; char **pointer_to_original = &original; (*pointer_to_original) = "is awesome"; printf("%s", original); //is awesome use of ** arrays: char** array = malloc(sizeof(*array) * 2); //2 elements (*array) = "hey"; //equivalent array[0] *(array + 1) = "there"; //array[1] printf("%s",

javascript - calling e.stopImmediatePropagation() from onclick attribute -

how event object onclick attribute? i have tried: <a href="something.html" onclick="function(e){e.stopimmediatepropagation();}">click me</a> also, have tried this: <a href="something.html" onclick="console.log(this);">click me</a> but console shows <a> element. i think you'd have define function in <script/> tag elsewhere. would bad use like: <script type="text/javascript"> $('#something_link').click(function(e) { e.stopimmediatepropagation(); }); </script> <a href="something.html" id="something_link">click me</a>

wpf - Get Displayed Text from TextBlock -

Image
i have simple textblock defined this <stackpanel> <border width="106" height="25" margin="6" borderbrush="black" borderthickness="1" horizontalalignment="left"> <textblock name="mytextblock" texttrimming="characterellipsis" text="textblock: displayed text"/> </border> </stackpanel> which outputs this this me "textblock: displayed text" string text = mytextblock.text; but there way text that's displayed on screen? meaning "textblock: display..." thanks you can first retrieving drawing object represents appearance of textblock in visual tree, , walk looking glyphrundrawing items - contain actual rendered text on screen. here's rough , ready implementation: private void button1_click(object sender,

Where should I put global methods and variables in an Android app? -

when i'm writing method or using member variable, find need share them across app. should go? i can subclass activity, falls on use mapview , forced use mapactivity, not activities inherit subclass. there way around this? where inheritance isn't applicable, tending put generic methods , member variables subclass of application object, i'm finding it's creating mess of code every class needs either grab access application object through via context, or have pass down. i suspect better off creating myapplication.getinstance() , keeping in singleton, instead of passing application object down through app classes. before wanted see guys had say. if want access "global singleton" outside of activity , don't want pass context through involved objects obtain singleton, can define, described, static attribute in application class, holds reference itself. initialize attribute in oncreate() method. for example: public class applicationcontro

vb.net - VB10, Auto-Implemented Properties and COM -

i finished class we're using tie access wcf services. of course means .net classes (and of properties) need visible com. given i'm using vb10 , contact class has 20 properties went ahead , used auto-implementing properties. much surprise, properties not accessible within vba in access. tried marking properties comvisible (which didn't have in past standard properties) , still didn't work. after changing auto properties standard properties worked. public property firstname string became public property firstname string return _strfirstname end set _strfirstname = value end set end property my understanding 2 should equivalent. according i've read on msdn, auto-implementing properties take care of creating backing field , getter / setter , intents , purposes should same. clearly they're not, else going on behind scenes? they are. sample code: <comvisible(true)> _ <classinterface(classinterfa

c# - Updatepanel gives full postback instead of asyncpostback -

i have run seems famous problem: updatepanel fires full postback instead of async postback. normal solution give controls add dynamically id, have done, still full postback instead of async postback... here's code: html: <asp:updatepanel id="itemsupdatepanel" runat="server" updatemode="conditional" childrenastriggers="false"> <triggers> </triggers> <contenttemplate> <asp:listview id="playeritems" runat="server" groupitemcount="5" onitemdatabound="playeritems_itemdatabound"> <layouttemplate> ... listview stuff ... </asp:listview> </contenttemplate> </asp:updatepanel> the interesting part c# code behind (method playeritems_itemdatabound), following: imagebutton imgbtn = new imagebutton(); imgbtn.id = "itembtn"; imgbtn.width

internet explorer 7 - IE 7 - CSS Banner positioning problem -

this happens in ie7 - lose menu items on top. my banner being forced top - rather sitting below top nav. any clues on how force sit in correct place in ie7? http://www.jacksonenterprises.co.nz/ div.header has height 25 px. remove attribute or calculate properly.

actionscript - Connecting/Streaming to Flash Media Server from SWF -

i have access flash media server on cdn. want allow people connect server. currenty, need additional software connect fms. nicer if connect server browser. so assume need create swf file , connect file fms (with actionscript). the end result demo of jquery webcam plugin, swf file establish connection fms , stream video fms. http://www.xarg.org/project/jquery-webcam-plugin/ i need show dialog accept webcam connection , connect , stream video server. take @ chapter 4 of fms dev guide . in outline need following: create netconnection fms create netstream using connection attach camera , microphone stream (this automatically trigger webcam dialog) publish stream you need add various listeners pick on events such checking have connected fms before creating netstream , starting recording, etc. sample code: var nc:netconnection = new netconnection(); nc.connect("rtmp://myservername/nameoffmsapplication/"); var ns:netstream = new netstream(nc); c

c# - Can an attribute references an embeded resource? -

i'm working on application generates tree structure of nodes. there many types of nodes, each specific behavior , properties. want attribute each node type properties including display name, description, , 16x16 icon. here's code custom attribute created: public class nodetypeinfoattribute : attribute { public nodetypeinfoattribute(string displayname, string description, system.drawing.image icon) : this(displayname, description) { this.icon = icon; } public nodetypeinfoattribute(string displayname, string description, string iconpath):this(displayname,description) { string abspath; if (system.io.path.ispathrooted(iconpath)) { abspath = iconpath; } else { string folder = system.io.path.getdirectoryname(system.reflection.assembly.getexecutingassembly().location); abspath = system.io.path.combine(folder, iconpath); } try {

Rails, Appcelerator, and JSON -

i'm trying appcelerator mobile app pull in json rails app. here how i'm pulling in json in appcelerator: loader.open("get","http://xxx/mobile_api"); this works following urls: http://api.twitter.com/1/statuses/user_timeline.json?screen_name=mobtuts http://www.coovents.com/tit_json_local.php in rails app, generate json this: @locations_json = @locations.to_json render :text => @locations_json i copied text output rails app , created php text file (coovents) , works. the json generated app isn't working appeclerator, json generated twitter works fine. when copy json generated app , paste in separate file, works too. maybe because php serving "text/html"? try serving "application/javascript" or "application/json"?

iphone - simple UISearchBar and UITextView app -

i'd see tutorial shows uisearchbar uitextview type in uisearchbar , appears in uitextview type it. i've pulled hair out on , redesigning app text field , button because can't head around uisearchbardelegate , how integrates uisearchbar. apple has official example, except it's complicated. post detailing frustrations can found here: http://www.iphonedevsdk.com/forum/ip...html#post12603 if screencast, highly appreciate it! implement uisearchbar delegate method: -(void)searchbar :(uisearchbar*)thesearchbar textdidchange :(nsstring*)searchtext then use mytextview.text = searchbar.text whenever method gets called. tariq

javascript - Using factory methods as alternative to passing anonymous functions -

i watching video on node.js , saw speaker say, prefers instead of using anonymous call backs: var server = server.createserver(server.createreq(req,res)); i think nice named function parameters can passed instead of anonymous function closure. question 1: implementation of createreq returns anonymous function, wouldn't it? how better? can see being better because unlike closure @ createserver level, closure @ createreq level more contained - not store reference other unnecessary variables (non req,res). and speaker said, guess visualize realtionships better between different parts of code. question 2: there other benefits? a reason why might want call function returns function may starting multiple servers within same process, , want them share same request handler. another thing keep in mind each anonymous function must allocated on heap, , incurs garbage collection overhead. using named function instead of anonymous function, can reduce cost. for

c# - RiaServices DomainService Server side exception problem -

currently i'm working on silverlight project depend on ria linqtosql , i’m using .net version 4 sometimes when add few records client side contain missing data null or wrong reference server raise exception , throw client throwing domainoperationexception along error details explain refrence name, , that’s great. so can handle on client , popup appropriate message user , working on development computer. but when deployed project on remote server , found server not sending detailed error message along domainoperationexception. i read many threads issue , said it’s security reasons . , said if want exception hold detailed error message should add following web.config <behaviors> <servicebehaviors> <behavior> <servicedebug includeexceptiondetailinfaults="true" httphelppageenabled="true" /> <servicemetadata httpgetenabled="true" /> </behavior> </servicebehaviors> </behavi

SVG Element Grouping without <use> tag -

the svg <use> tag doesn't work in chrome. how group svg shapes rect,circle,path without using svg use tag ? edit: but when drag <g> element in iframe not move element <g> contain there other way child element , drag them loop????? use should work fine in webkit/chrome, want use grouping g element. see http://www.w3.org/tr/svg/struct.html#groups more information.

optimization - Why padding is used in Base64 encoding? -

possible duplicate: why base64 encoding requires padding if input length not divisible 3? quoting wikipedia : ...these padding characters must discarded when decoding still allow calculation of effective length of unencoded text, when input binary length not multiple of 3 bytes. ... but calculation of length raw data can done if strip padding character. | encoded |-------------------------------------- raw size | total size | real size | padding size 1 | 4 | 2 | 2 2 | 4 | 3 | 1 3 | 4 | 4 | 0 4 | 8 | 6 | 2 5 | 8 | 7 | 1 6 | 8 | 8 | 0 7 | 12 | 10 | 2 8 | 12 | 11 | 1 9 | 12 | 12 | 0 10 | 16 | 14 | 2 . . . so given real encoded size (third column) can correctly guess padded size b

How can I check the system version of Android? -

does know how can check system version (e.g. 1.0 , 2.2 , etc.) programatically? check android.os.build.version . codename : current development codename, or string "rel" if release build. incremental : internal value used underlying source control represent build. release : user-visible version string.

What is the best wysiwig HTML editor producing pretty diffs in SVN history? -

we have html documentation svn. users write documentation using wysiwyg editor nvu. history diffs producing nvu bad. mean when change 1 word in html file , save it, resulted file has different formating. if have svn history or trac timeline, cannot distinguish changed. there alternative producing files having aranged diffs when looking in history via svn or trac timeline? i use tool normalize html regardless of editor users have chosen, , tell run before commiting. ensure has been done, can block commits in svn pre commit hook. if, instance html supposed formed xhtml, write such hook xmllint --format make sure incoming xml matches of xmllinted one, or reject commit. way can force users run prepare script or similar before commit. http://wordaligned.org/articles/a-subversion-pre-commit-hook http://svnbook.red-bean.com/en/1.0/svn-book.html#svn-ch-5-sect-2.1

google app engine - Using Blobstore Python API over HTTPS generates 405 error when redirecting back -

don't know if it's i'm doing wrong or if there's bug (i think so, seen others having same problem) in blobstore.create_upload_url method. in app.yaml have url's property secure: always , action attribute of form element starts https:// when it's return api it's redirected non-https. there's bug file on google app engine issue tracker no response google. does know of work around? current solution have separate .py file handle response , direct original url on https. edit i use set action attribute: from google.appengine.api import blobstore view['upload_url'] = blobstore.create_upload_url ## pass view dict template , in template <form action="{{ upload_url }}" enctype="multipart/form-data" method="post"> </form> the output in html looks like: action="https://appid.appspot.com/_ah/upload/ammfu6bca9sfz5isqw6pnnb8xzry2ruolams2gfjfpewcz-vg9m_hqtor87wydnmo7zibqx9ninjorftikauolmh

google maps - Marker Clusterer, not zooming in when clicked -

i'm using marker clusterer default settings, on map using default settings. marker clusters display fine, unlike example in documentation, map not zoom in when cluster clicked. map centers on click on cluster not zoom! has else had problem before? dreendle: default zoomonclick setting true clicking cluster should zoom in. sure have not set zoomonclick false? there no script errors?

algorithm - String similarity score/hash -

is there method calculate general "similarity score" of string? in way not comparing 2 strings rather number (hash) each string can later tell me 2 strings or not similar. 2 similar strings should have similar (close) hashes. let's consider these strings , scores example: hello world 1000 hello world! 1010 hello earth 1125 foo bar 3250 foobarbar 3750 foo bar! 3300 foo world! 2350 you can see hello world! , hello world similar , scores close each other. this way, finding similar strings given string done subtracting given strings score other scores , sorting absolute value. i believe you're looking called locality sensitive hash . whereas hash algorithms designed such small variations in input cause large changes in output, these hashes attempt opposite: small changes in input generate proportionally small changes in output. as oth

Calling c function in a lib file from c++ -

i have call c function declared in lib file c++. instructions/attributes/configuration have set this? do have header file library? if should have extern "c" { blah blah } stuff in allow used c programs. if not, can put around include statement header in own code. e.g. extern "c" { #include "imported_c_library.h" }

ios4 - Multiple sources for UIPickerView on textfield editing -

what have far is @synthesize txtcountry,txtstate; int flgtextfield; - (bool)textfieldshouldbeginediting:(uitextfield *)textfield { [pickerview reloadallcomponents]; // make new view, or want here if(textfield == txtcountry || textfield == txtstate){ flgtextfield = textfield.tag; [uiview beginanimations:nil context:null]; //[pvstate setframe:cgrectmake(0.0f, 199.0f, 320.0f, 216.0f)]; [uiview commitanimations]; return no; } else { return yes; } } - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview; { return 1; } - (nsinteger)pickerview:(uipickerview *)thepickerview numberofrowsincomponent:(nsinteger)component { if(flgtextfield==1){ return [arrycountry count]; } else { return [arrystate count]; } } - (nsstring *)pickerview:(uipickerview *)thepickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { if(flgtextfield==1){ r

PHP regex optimize -

i've got regular expression match between <anything> , i'm using this: '@<([\w]+)>@' today believe there might better way it? / tobias \w doesn't match said, way, [a-za-z0-9_] . assuming using "everything" in loose manner , \w want, don't need square brackets around \w . otherwise it's fine.

connection - Problem: Android's isConnected() used to get current state of WiFi often returns false even when the device is connected -

my android app can function wifi connected internet. thus, use following code check if device connected: connectivitymanager conmgr = (connectivitymanager)getsystemservice(activity.connectivity_service); boolean wifi = conmgr.getnetworkinfo(connectivitymanager.type_wifi).isconnected(); however, when application launched , wifi connected internet, notification shown when wifi = false . have missed something, or check not accurate? i use code this: public static string getcurrentssid(context context) { final wifiinfo wifiinfo = getcurrentwifiinfo(context); if (wifiinfo != null && !stringutil.isblank(wifiinfo.getssid())) { return wifiinfo.getssid(); } return null; } public static wifiinfo getcurrentwifiinfo(context context) { final connectivitymanager connmanager = (connectivitymanager) context.getsystemservice(context.connectivity_service); final networkinfo networkinfo = connmanager.getnetworkinfo(connectivitymanager.type_wifi); if (networki

jquery - Searching HTML Table -

i have created table html , want integrate search box. how do that? can recommend jquery plugin or better complete tutorial? a quick , dirty approach, using jquery: $(document).ready( function(){ $('#searchbox').keyup( function(){ var searchtext = $(this).val(); if (searchtext.length > 0){ $('td:contains(' + searchtext +')') .css('background-color','#f00'); $('td:not(:contains('+searchtext+'))') .css('background-color','#fff'); } }); }); with following (x)html: <table> <thead> <tr> <td colspan="2"> <label for="searchbox">search:</label> <input type="text" id="searchbox" />

sql - Syntax Error in Join Operation in MS-Access when splitting and comparing records -

above error message occurs statement: select f.fullname summaryjudgment_finalforgottenwithmiddle ( (select left([aname],instr(1,[aname],",")-1)) lastname summaryjudgment_finalforgotten) & " " & (select right([aname],instr(1,[aname],",")+1)) firstname summaryjudgment_finalforgotten) & " " & (select summary_judgment.middle_initial middlename summary_judgment) ) fullname summaryjudgment_finalforgotten f inner join summary_judgment s on f.lastname = s.last_name && f.firstname = s.first_name; basically 2 tables (note have more fields 1 last or first name of different fields can similar): summaryjudgment_finalforgotten (table) aname (field) leventhal,raymond (data) summary_judgment (table) first_name(field) raymond (data) last_name (field) leventhal (data) middle_initial (field) p (data) ultimately, i'm trying create new table summaryjudgment_finalforgotten middle initial summary_judgment appended: leventhal,r

directory - Is it possible to create a shortcut to a flash disk in Windows CE? -

we switching devices, , flash disks name differently, our software's configuration files written directory hardcoded (not ever change vendors, right?) so...is possible create shortcut new flash disk name of old 1 such don't have change paths? thanks in advance help. unfortunately, no (well not easily). shortcuts files in ce simple text files of folowing format: 25#\program files\myapp.exe where number @ start number of characters in path following, including hash. can change target changing path text, there's no easy way "virtually map" 1 location another. now there is way achieve remapping, requires write, deploy , install file-system filter (fsf). fsf "forward" requests 1 location another. however, seems (to me anyway) you're going have configure fsf device-specific path, , it's easier change shortcuts. if problem solve, i'd create app reads registry storage driver profile determine name card, modify shortcut

c++ - trying to compile stir library: error: invalid conversion from ‘const char*’ to ‘char*’ -

first, i'm pretty new c++ , c easy on me :-) second, know question has asked many times in many forms before, figure how bend answers case ... i trying compile file called utilities.cxx stil library has kind of , "open source" license (not lgpl , don't know if can put here significant parts of it... the code has following function in it: char *replace_extension(char *file_in_directory_name, const char * const extension) { char * location_of_dot = strchr(find_filename(file_in_directory_name),'.'); // first truncate @ extension if (location_of_dot!= null) *(location_of_dot) = '\0'; strcat (file_in_directory_name,extension); return file_in_directory_name; } compiling gives error: g++ -o3 -ffast-math -dndebug -wall -wno-deprecated -i../lmf_v2.0 /includes -d_file_offset_bits=64 -i./include -dstir_simple_bitmaps -dsc_xwindows -o opt/buildblock/utilities.o -mmd -mp -c buildblock/utilities.cxx buildblock/utilities.cxx: in

How do I update the same value from either a selection list or a textfield on the same form (Rails 3)? -

my current solution involves passing both values 2 different variable names view controller , using logic in controller decide 1 use update. works, i'm thinking there has better way. advice? === view === <p>choose tutor list:&nbsp;<%= f.collection_select(:current_tutor, @tutors, :name, :name, {:include_blank => true}) %></p> <p>..or dd new tutor:&nbsp;<%= f.text_field :current_tutor_textfield %></p> === controller === respond_to |format| @student = student.where(:slug => params[:id]).first # here i'm deciding value passed update new_tutor unless params[:student][:current_tutor].blank? new_tutor = params[:student][:current_tutor] end unless params[:student][:current_tutor_textfield].blank? new_tutor = params[:student][:current_tutor_textfield] end if @student.update_tutor(new_tutor) format.html { redirect_to(students_path, :notice => 'student up

visual studio - Different binary file size after converting to VS 2010 -

when converted vs 2005 project vs 2010, projects still pointing compile .net 2.0 framework, dlls generated totally different file size. normal or concerned about? the difference in file size due changes in compiler shipped new version of visual studio. in theory, should more efficient. should not worry about, doesn't mean should forgo testing. microsoft publish information on "breaking changes" new version of visual studio, e.g., http://msdn.microsoft.com/en-us/library/cc714070.aspx vb, http://msdn.microsoft.com/en-us/library/bb531344.aspx c++, , http://msdn.microsoft.com/en-us/library/ee855831.aspx c#.

windows - Apache can't connect to http://localhost/. Port is changed to 81 -

i've installed apache2.2 , installed it, running had change listening port 81. thing cant connect through localhost. thing login window , when type in authentication information think windows login. get: error '8002801c' error accessing ole registry. /iishelp/common/500-100.asp, line 17 the computer winxp , i've opened ports out , no firewall blocking apache. seems machine has webserver running, iis. can uninstall through configuration screen. try http://localhost:81/ apache install.

java - Why does EntityManager.merge() prevent LazyInitializationException while EntityManager.find() don't? -

given following situation in web application: // entitymanager em, 1 per request spring's openentitymanagerinviewfilter // parent oldparent, previous request (and therefore persistence context) parent parent = em.find(parent.class, oldparent.getid()); list<child> children = parent.getchildren(); // mapped collection lazyloading (child child : children) { ... the call of list iterator causes lazyinitializationexception . confusing, because fetching of list of children occurs in same persistence context (or wrong?). but , using merge() , works. if 2 request sharing 1 persistence context. parent parent = em.merge(oldparent); list<child> children = parent.getchildren(); (child child : children) { ... // no exception!! what error in reasoning? addition i've proven error not caused parent.getid() . part of stacktrace: at org.hibernate.collection.persistentlist.iterator(persistentlist.java:138) that means iterator causes problem. , it's get

How to link a non-standard header file into a C compiler -

i'm trying use non-standard header file (http://ndevilla.free.fr/gnuplot). used in lots of codes in various different places on computer. have put header file , object file in every folder needed preprocessor directive: #include "gnuplot_i.h" in file. there way can put header file in 1 place can reference other standard header file. cheers. compile -i<directory> e.g. compile -i/usr/local/gnuplot/inc . also might worth reading on include paths , difference between: #include <include_file.h> and #include "include_file.h" linking in object file needs done explicitly same way c file, means (i believe) need full path. if archive proper library can use -l<library name> , -l<library path> instead. e.g. gcc -i/usr/local/gnuplot/inc -l/usr/local/gnuplot/lib -lgnuplot -o my_prog my_prog.c

c# - DateTime.Parse, Latvian culture settings -

i sending in string in dd/mm/yyyy format, being parsed lv-lv culture set per web.config globalization setting. i comparing date datetime.now see if in past. the problem is, datetime.parse converts string dd.mm.yyyy format, datetime.now has mm.dd.yyyy format, comparison fails. why datetime.now different output datetime.parse , on same thread culture? thanks! (update) code using: inputtext contains input form in dd.mm.yyyy format datetime date = datetime.parse(inputtext, cultureinfo.currentculture); // check it's not in past this.isvalid = (date.compareto(datetime.now) > 0); [datetime.now] in context in mm.dd.yyyy format using lv-lv cultureinfo [date] in dd.mm.yyyy format after datetime.parse a datetime not have formatting - point in time. if viewing it, means outputting it. use correct culture output date. datetime.tostring has overloads take format provider such cultureinfo : string formatted = datetime.tostring(new cultureinfo("l

wpf - What kind of compiler magic do we need more? -

i develop lot view models are: 1) have implement inotifypropertychanged bindable ui. 2) property setters have raise propertychanged on change. 3) propertychanged event has provide proper property name. if (like me) tied of writing this: public string name { { return _name; } set { if (_name != value) { _name = value; raisepropertychanged("name"); } } } then refactor method , forget update property name literal: string _fundname; public string fundname { { return _fundname; } set { if (_fundname != value) { _fundname = value; raisepropertychanged("name"); } } } and spend day debug why ui not refreshing , databinding doesn't work properly. then need kind of magic. what if need write this: [magic] // implicit transformation public string fundname { get; set; } or if have many properties: [magic] public class myviewmodel { public string

.htaccess - htaccess general rewrite but skip images -

i trying include file extensions being rewritten fi dont exit. (image types: jpg|gif|png ) currenty have: options +followsymlinks rewriteengine on rewritecond %{document_root}/$1 -f [or] rewritecond %{document_root}/$1 -d rewriterule (.*) - [s=1] rewriterule (.*) /index.php?id=$1 [l] i need skip request url ends in: .gif/.jpg/.png been looking everywhere.. can't find out how it. thanks! this should it: options +followsymlinks rewriteengine on rewritecond %{request_uri} !\.(gif|jpg|png)$ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule (.*) /index.php?id=$1 [l] this says, filename doesn't end gif jpg or png, , isn't file, , isn't directory, send index.php

Rails 3: Hash accessor in the model? -

i'm struggling stretch understanding of basic rails concepts beyond tutorial examples i've done. can't find q&a/docs/walkthroughs doing i'm trying do, there's chance i'm going wrong way. i have team object many tags. team table has few normalized fields, of characteristics of team stored tags, i.e team 'virginia cavaliers' has tags {[tag_name => 'conference', tag_value => 'acc'], [tag_name => 'division', tag_value =>'i']} etc. db design meant accommodate many types of teams in same table, tag table facilitating search teams arbitrary criteria. so far good. can't figure out how best access team attributes given team. class team < activerecord::base belongs_to :sport has_many :team_subscriptions has_many :users, :through => :team_subscriptions has_many :tags def tagvalue #set hash retrieve tag value name? @tagvalue = {} tags.each |t| @tagvalue[t.tag_nam

android downloading apk file from internet results in parsing error -

when try download file using following code , run apk file, results in "parsing error". clueless. appreciated. try { url url = new url("http://10.0.0.1/test.apk"); urlconnection conexion = url.openconnection(); conexion.connect(); int lenghtoffile = conexion.getcontentlength(); inputstream is=url.openstream(); fileoutputstream fos=new fileoutputstream("/flash/test.apk"); byte data[]=new byte[1024]; int count=0; long total=0; int progress=0; while ((count=is.read(data)) != -1) { total += count; int progress_temp = (int)total*100/lenghtoffile; if(progress_te

sql server 2005 - Is there a way to find most expensive queries within a particular time? -

i did ask before . here - run .net application , monitor sql queries being done , monitor compared sql profiler logs everything. so, know of tool or way can monitor queries application , find out expensive queries of session ? in applications connection string sql server, add (ottomh) application_name = 'abc app'. in effect should like 'server=yourservername;integrated security=sspi;application_name=abc app' once app running, can run sp_who2 in sql server management studio view connections - check there make sure application showing name rather generic name .net apps. *double check if app name or application_name* when setting trace flags in profiler, go events tab, , click on column filters. first 1 applicationname. set '%abc app%'

Rails - How to Redirect from http://example.com to https://www.example.com -

i'm looking learn how cleanup app's urls. app powered rails 3 on heroku. the desired url https://www.example.comite.com i'd redirect urls unlike above url. rails thing or dns? bad urls: https://example.comite.com http://www.example.comite.com http://example.comite.com and if trailing, http://www.example.comite.com/photo/1 url redirected path: https://www.example.comite.com/photo/1 dns records cannot define protocol domain, therefore can't redirect http:// https:// through dns. doing through web server configuration not portable, hard do, error prone , plain outdated. job best handled rails router. # beginning of routes.rb match "*path" => redirect("https://www.mysite.com/%{path}"), :constraints => { :protocol => "http://" } match "*path" => redirect("https://www.mysite.com/%{path}"), :constraints => { :subdomain => "" }

iis - Wordpress in a server farm with a CDN -

i have setup wordpress multisite blog load balanced on 5 servers (we're expecting lot of traffic). in windows , using iis 7 one issue had wp-content folder , synching servers. i attempted move wp-content dir shared drive , use virtual dir in iis, did not seem work, followed instructions here (http://codex.wordpress.org/editing_wp-config.php) ... not blog work when wp-content on different drive actual blog. therefore decided use vice versa synch folders. now being asked utilize cdn have, limelight (not amazon s3, cannot use plugin) host our images. want somehow synch cdn wordpress , utilize sort of plugin rewrite url's point cdn. i should add blog updated non technical people, therefore asking them upload files directly cdn not option. thanks in advance. no, codex instructions offloading image uploads in multisite just... no. i know won't using amazons3 plugins, does work multisite, , best can tell (becasue there no specifics docs yet) have @ plug

.net - TypeDescriptor.GetProperties return nothing from a class -

i have defined class testobject contains 2 simple properties num , name. trying use typedescriptor.getproperties() object of testobject class retrieve defined properties. but, doesn't return anything. public partial class _default : system.web.ui.page { protected void page_load(object sender, eventargs e) { object selobj = new testobject(); foreach (propertydescriptor pd in typedescriptor.getproperties(selobj)) { string cat = pd.category; } } } public class testobject { string name = "hello world"; int num { { return 100; } } string name { { return name; } set { name = value; } } } am missing simple here? appreciate help. make sure properties marked public

how to install a python package to windows? -

install python package windows. have tried run setup.py install on command prompt returned error: not create 'c:\program files\python...': access denied. please, help. Å pela my first question be, have administration rights when try run setup.py?

Java help reading from a file -

i have section of code dont know with. supposed show dialog box select file , when file selected outputs results in histograph. have working except can not figure out variable need put text2. private int[] countletters2() { // count 26 letters int[] count = new int[26]; //get contents file chooser.showopendialog(null); file f = chooser.getselectedfile(); try { filereader fr = new filereader(f); bufferedreader br = new bufferedreader(fr); string s; while((s = br.readline()) != null) { system.out.println(s); <------simply see if reader , buffer working } } catch(ioexception g) {} string text2 = ; <------------------------------------this problem //converts every letter uppercase text2 = text2.touppercase(); //count occurrence of each letter (case insensitive) (int = 0; < text2.length(); i++) { char character = text2.charat(i); if ((character >= 'a') && (character <= 'z

search - How add html and text files to Sphinx index? -

from sphinx reference manual: «the data indexed can come different sources: sql databases, plain text files, html files , mailboxes, , on» but can't find how add text files , html files index. quick sphinx usage tour show setup mysql database only. how can this? your should @ xmlpipe2 data source . from manual: xmlpipe2 lets pass arbitrary full-text , attribute data sphinx in yet custom xml format. allows specify schema (ie. set of fields , attributes) either in xml stream itself, or in source settings.

http - Detecting Byte-Range requests in .NET HttpHandler -

i have httphandler checks on incoming requests , in cases perform function. 1 of conditions needs checked whether request byte-range request . how done? you need range header in request object that's part of httpcontext passed processrequest method. there no range property in httprequest class, you'll have in headers . if there range of form: range: bytes=<start>-<end> where <start> , <end> integers. example, if wanted 64k middle of file: range: bytes=32768-98304 you'll have parse text numbers , handle accordingly.

How can I get a row count all replicated tables in SQL Server? -

i trying build report show row counts of replicated tables on subscriber , publisher? please help..thanks in advance. you enumerate publications sp_helppublication . you enumerate articles in publication sp_helparticle you find base object each published article you count rows in base objects (from step 3) you find destination object of each article you list subscribers sp_helpsubscription on each subscriber, count rows in destination objects (from step 3)

svn - Automating Repo Changes in Hudson -

i'm putting hudson setup , our build process has thrown bit of roadblock. have long been web shop doing more java projects now. every 2 weeks create tag of root folder after release previous tag production. new tag tested 2 weeks (and critical changes merged) while development continues on trunk. of commits not related java , java project not need built every time, java changes detected. what want setup hudson poll in-testing tag changes , build , deploy our testing server. however, since release every 2 weeks, testing repo url change along it. manually update repo url, want automate avoid human error. there way create sort of svn symlink url have script change point new tag when release? there scripting mechanism use run , automatically update hudson's repo cli? other ideas fix this? how reuse same tag every 2 weeks. following description of process use. when create release, copy trunk new tag , test until enough (about 2 weeks). release tag. proposed change

iPhone, how to send a data change event to the UIView from the application delegator? -

i setup network call in appdelegator class infomation back, , want show in frist uiview. how pass data uiview? i mean uiview may visible or may destroyed , replaced other one, if visible, how pass value it? is there publish/subscribe events mechanism in iphone sdk? you can few different ways, including using key-value observing or nsnotification s. the basic idea when load uiview , want register observer of key path/posted notification of app delegate. when deallocate view, should unregister observer.

mysql - Setting a default value for JOINS on multiple tables with possible empty resultsets? -

so i'm trying join on multiple same id , each table may or may not have entry id. select a.value, b.value, c.value, d.value tbl_a join tbl_b b on a.id=b.id join tbl_c c on a.id=c.id join tbl_d d on a.id=d.id a.id=123 obviously failing because if tbl_a doesn't have doesn't have entry, returns empty resultset , joins fail. i've tried sorts of left joins, outer joins , couldn't work. i've tried setting clause like: where a.id=123 or b.id=123 or ... didn't work either. i tried ugly union gives output in separate row. select count(*), "a", ifnull(a.value,0) tbl_a a.id=123 union select count(*), "b", ifnull(b.value,0) tbl_b b b.id=123 union etc... any ideas? add other 3 id fields where clause or , outer joins.

linux - Shellscript to monitor a log file if keyword triggers then execute a command? -

is there cheap way monitor log file tail -f log.txt , if [error] appears, execute command? thank you. tail -fn0 logfile | \ while read line ; echo "$line" | grep "pattern" if [ $? = 0 ] ... ... fi done

r - Testing cointegration of two stocks using Yahoo Finance data -

i trying perform co-integration test on 2 stocks, using data yahoo finance. have been reading there less complicated ways retrieve yahoo data. need retrieve 2 securities , define them stk1 , stk2 able adjust time frame of data retrieved. here have far. library(zoo) library(tseries) # read csv files data frames stk1 <- read.csv("http://ichart.finance.yahoo.com/table.csv?s=cat&a=8&b=1&c=2009&d=12&e=31&f=2010&g=d&ignore=.csv", stringsasfactors=f) stk2 <- read.csv("http://ichart.finance.yahoo.com/table.csv?s=dd&a=8&b=1&c=2009&d=12&e=31&f=2010&g=d&ignore=.csv", stringsasfactors=f) # first column contains dates. as.date converts strings date objects stk1_dates <- as.date(stk1[,1]) stk2_dates <- as.date(stk2[,1]) # seventh column contains adjusted close. use zoo function # create zoo objects data. function takes 2 arguments: # vector of data , vector of dates. stk1 &l

how to set current image location in vb.net -

how set current image location in vb.net if use drag , drop even. seems imagelocation doesn't work because tried outputting image location using messagebox. didn't show anything. how image location of file have drop picturebox transfer on directory? private sub pb_dragdrop(byval sender object, byval e system.windows.forms.drageventargs) handles pb.dragdrop dim filetomove string dim movelocation string try pb.image = image.fromfile(ctype(e.data.getdata(dataformats.filedrop), array).getvalue(0).tostring) filetomove = pb.imagelocation movelocation = "c:\pics\" + textbox1.text + ".jpg" '" if system.io.file.exists(filetomove) = true system.io.file.move(filetomove, movelocation) end if catch ex exception messagebox.show("error doing drag/drop") end try

unit testing - Specifying *stack-trace-depth* in Clojure tests -

what correct way set value of *stack-trace-depth* in clojure tests? bind around call run-tests or run-all-tests . for example: (binding [*stack-trace-depth* 5] (run-all-tests))

winforms - C# Visual Studio using resource files -

i'm trying add 2 image files solution, compiled .exe, can load them right there instead of absolute path on computer. i believe need use resource files in visual studio, never have before. if i'm on wrong track, please correct me. here's i've done far. in visual studio 2010 solution explorer, right click properties → open → resources → add resource → add existing file ... so have both images in properties → resources tab. how them out in c# code? i'm using c#, windows forms , visual studio 2010 . picturebox pic; pic.image = new bitmap( /* address now? */ ); you can them properties.resources.<name_of_your_resource>

ruby on rails - Restricting a portion of code through an association -

i have built ruby on rails app lets users track workouts. user has_many workouts. in addition, user can create box (gym) if gym owner. purpose filter activity of users such can see information related gym. users can specify if member of box through membership model. membership table collects @box.id , current_user.id in membership.box_id , user.id columns respectively. the user associates through following form in /views/boxes/show.html.erb view: <% remote_form_for membership.new |f| %> <%= f.hidden_field :box_id, :value => @box.id %> <%= f.hidden_field :user_id, :value => current_user.id %> <%= submit_tag "i member of box" , :class => '' %> <% end %> i display, in box show page users members of box. <% @box.users.each |user| %> <%= link_to (user.username), user %><br/> <% end %> i trying restrict form users not members of box not sure how write <% unless ... %> statement. h

uitableview - Problem with table view in iPhone -

here code creating cell cell.textlabel.text=[listdata objectatindex:indexpath.row ]; if(indexpath.row==1) cell.detailtextlabel.text=@"some text"; return cell; here total 20 rows , 8 rows visible @ time my problem detail text label repeated @ many rows when scrolling.... please help try this: cell.textlabel.text = [listdata objectatindex:indexpath.row]; if (indexpath.row == 1) cell.detailtextlabel.text = @"some text"; else cell.detailtextlabel.text = @""; return cell; table cells recycled, have reset every time.

java - How to make a servlet interact with the API of a website and also store the XML response? -

protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { string text = "some text"; response.setcontenttype("text/plain"); // set content type of response jquery knows can expect. response.setcharacterencoding("utf-8"); // want world domination, huh? response.getwriter().write(text); // write response body. } if use servlet , request variable have url of api of website . how capture response ? want know code , , right way go when trying build jsp page deals interacting api of website , showing data ? you're confusing things. httpservletrequest http request client (the webbrowser) has made reach servlet. httpservletresponse response should use send result client (the webbrowser). if want fire http request programmatically, should use java.net.urlconnection . urlconnection connection = new url("http://example.com").openconnection(); inputst

javascript - Simple key combo in jquery -

i'm looking catch simple key combos such ctrl + a . here's stab @ it: var isctrl = false; $(window).keydown(function (e) { if (e.keycode == 17) isctrl = true; if (isctrl && e.keycode == 65) alert('hi'); }); is , robust approach? if not, how can improve on it? since you're using jquery, try utilize library provides normalize keystrokes .ctrlkey , .which: if (e.which == 17 && e.ctrlkey) alert('hi');

Hibernate object Serialization -

why hibernate persistence object in java marked serializable because data objects crosses machine contains data access code. objects should serialized here , deserialized in distant machine used.

ant - Build fail in java -

i try build java application in command prompt, fails as.. compile-core: [javac] compiling 1085 source files c:\conet\app\build\core [javac] [javac] [javac] system out of resources. [javac] consult following stack trace details. [javac] java.lang.outofmemoryerror: java heap space build failed c:\conet\app\build.xml:324: compile failed; see compiler error output details. total time: 1 minute 5 seconds c:\conet\app> any solution type of problem. thanks since you're using ant, should increase available heap size compilation. add build.xml compilation target: memoryinitialsize="256m" memorymaximumsize="1024m" info taken here .