Posts

Showing posts from January, 2013

Wordpress admin menu not showing -

i'm building first worpess plugin. 'hammu dating' not showing in 'settings' panel in wp-admin. plugin activated in 'plugin' panel. followed instructions here . add_action( 'admin_menu', 'hammenu' ); function hammenu() { add_options_page( 'hammu dating opties', 'hammu dating opties', 'manage-options', 'hd_menu_1', 'hammu_options' ); } function hammu_options() { if ( !current_user_can( 'manage_options' ) ) { wp_die( __( 'no rights' ) ); } echo '<div class="wrap">'; echo '<p>nothing interesting here, yet</p>'; echo '</div>'; } note: part of plugin code the add_options_page(); function carries wrong capability slug: manage-options use manage_options instead. hope helps!

Knowing a google+ profile id, get number of circles for a user using the g+ API -

i tried searching google , stackoverflow, didn't found such way!! is there something, means in google+ api using can number of circles (public information) particular profile, have g+ id ? i went through that, found was, 1 can public information profile, when user has authenticated app. although in graph-api fb, afair can such public information (about posts, pages) without asking permission. i've updated question, if guys still think doesn't conform stackoverflow community, leave me comment , i'll delete it, instead of giving negative votes. (friendly request) [edit] the idea not number of circles particular user, number of circles in user. for e.g. https://plus.google.com/u/0/117907144223534027934 - in 353 circles https://plus.google.com/u/0/118337805761123404690 - in 15 circles the number of circles person has not public information. google+ not expose user's circle structure in way. however, if has been shared publicly, can retrieve

ClassNotFoundException: com.google.android.gms.maps.MapFragment with AndroidStudio -

i'm trying use google maps v2 on android app. i'm using android studio; followed steps indicated here: https://developers.google.com/maps/documentation/android/start#overview in androidmanifest.xml i've: <uses-sdk android:minsdkversion="12" android:targetsdkversion="16" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <!-- following 2 permissions not required use google maps android api v2, recommended. --> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-f

Python syntax: mutating/reducing a defaultdict? -

i wasn't sure term is, have word_set in form of defaultdict [(word, value), ...] came function parsed raw data. i have other functions: reduceval(word_set, min_val) , reduceword(word_set, *args) , etc removes pairs that: have value less min_val, have (word) in [args], respectively. pretty follow same structure, e.g. def reduceval(word_set, value): "returns word_set (k, v) pairs v > value)" rtn_set = defaultdict() (k, v) in word_set.items(): if v > value: rtn_set.update({k:v}) return rtn_set i wondering if there more concise, or pythonic, way of expressing this, without building new rtn_set or maybe defining entire function if learn use dict comprehensions don't need have separate functions of these different filters. instance, reduceval , reduceword replaced with: # python 2.7+ {w: v w, v in word_set.items() if v > value} {w: v w, v in word_set.items() if w in args} # python 2.6 , earlier dict((w

ios - UIImagePickerController is crashing on iOS5 but working fine on iOS6+ -

my following code working fine on ios6+ crashing on ios5 every 3rd time , yes working fine 2 time , crashing on 3rd. not doing fancy tapping same button again , again. button call method contains following line of code. self.imagepopover = nil; uiimagepickercontroller* imagepicker = [[uiimagepickercontroller alloc] init]; imagepicker.delegate = self; imagepicker.sourcetype = uiimagepickercontrollersourcetypesavedphotosalbum; uipopovercontroller *imagepop = [[uipopovercontroller alloc] initwithcontentviewcontroller:imagepicker]; [imagepop presentpopoverfromrect:self.profileimagebutton.frame inview:self.profileimagebutton permittedarrowdirections:uipopoverarrowdirectionany animated:yes]; self.imagepopover = imagepop; and , in - (void)imagepickercontrollerdidcancel:(uiimagepickercontroller *)picker { picker.delegate = nil; [self.imagepopover dismisspopoveranimated:yes]; } and following says in consol crash *** -[pluisavedphotosalbumviewcontroller hash]: message sen

javascript - How to make a form-filling google chrome extension -

i wondering if provide me links tutorials or explain (with example code), how go making simple google chrome extension (or in programming language or browser if impossible), how make extension can visit specific site, fill login form on site, click links , same sort of thing on linked site. thanks personally, not use chrome extension, maybe perl script. there extension called www::mechanize designed kind of stuff. you can find plenty of tutorials , examples, google it.

carrierwave - How to Create One Form Only in Rails to Submit two things Simple Form Carrier Wave -

i building rails platform reddit style type of community international students in boston area. still testing reception of idea. using simple form , carrierwave. got @student = student.new instance in signup method. got @uploader = student.new.picture in signup method (using carrierwave). idea every student has picture associated him or her. got carrierwave's picture feature mounted on student model. using carrierwave_direct gem directly upload pictures s3 storage on amazon. my signup.html.erb looks <div class = "signupform"> <%= simple_form_for @student, :html => {:multipart => true} |f| %> <%= f.input :last_name, label: '姓'%> <%= f.input :first_name, label: '名' %> <%= f.input :email, label: '电子邮件' %> <%= f.input :password, label: '密码' %> <%= f.input :college, label: '大学' %> <%= f.input :budget, label: '房间租金预算 (optional)' %> &

xml - You must write ContentLength bytes to the request stream before calling [Begin]GetResponse -

error: must write contentlength bytes request stream before calling [begin]getresponse. can advise why getting above error when running following code dim xml new system.xml.xmldocument() dim root xmlelement root = xml.createelement("root") xml.appendchild(root) dim username xmlelement username = xml.createelement("username") username.innertext = "xxxxx" root.appendchild(username) dim password xmlelement password = xml.createelement("password") password.innertext = "xxxx" root.appendchild(password) dim shipmenttype xmlelement shipmenttype = xml.createelement("shipmenttype") shipmenttype.innertext = "delivery" root.appendchild(shipmenttype) dim url = "xxxxxx" dim req webrequest = webrequest.create(url) req.method = "post" req.c

javascript - Understanding how to use NodeJS to create a simple backend -

i have been trying develop rather simple server in nodejs. basically, going simple api requires authentication (simple username/password style). not need kind of frontend functionality (templating etc.). problem is, can't seem head around approach of express/node. specifically, questions are: how wire in authentication? pass several handlers every route requires authentication, or there more elegant way this? how express middleware (like app.use(express.bodyparser()) ) work? alter contents of request or response object? specifically, if use body parser (internally formidable?), access request data supposed parse? when using authentication , have, say, credentials stored in database more information individual client associated, @ point extract information? i.e., when user logs in, fetch user record on login , pass on, or fetch in every handler requires information? ultimately, know of open source application take at? i'd see has simple authentication , maybe utili

javascript - Google Script parsing text -

i have google script program working parsing text. i'm having trouble finding right functions or regular expressions job done. should pull name out of email (which should first thing in email). here's i'm trying parse out far: derek antrican<br /> <br /> ==================================================================<br /> mobile text message brought at&amp;t<br /> basically want code take current string above, sort out first 1 or 2 full words (anything before html line break tag) , assign resulting string variable "parse". here's have far code: //var loc = body.findtext("\a\w*\s\w*"); //var ele = loc.getelement(); //var parse = ele.gettext(); i'm new both regular expressions , javascript, missing obvious. a simple method doesn't require regular expressions split on " <br " , take first element: var parsed_text = body.split('<br')[0];

android - Change a preference through a Dialog -

i want change preference in class if user selects 'ok' in output dialog. have implemented method in class: if (basalcor != basal) { fragmentmanager fragmentmanager = getfragmentmanager(); changebasaldialog dialogo = new changebasaldialog(basal); dialogo.show(fragmentmanager, "tagbasal"); if (dialogo.check == true) { string ok= "basal factor changed succesfully"; sharedpreferences.editor prefseditor = myprefs.edit(); if (basalmorframe == true) { prefseditor.putstring("basalmor", string.valueof(basal)); prefseditor.commit(); toast toast=toast.maketext(mymeasures.this, ok, toast.length_short); toast.show(); } if (basalniframe == true)

python - Extracting from File using Regular Expression -

i have text document extract phrases from. phrase "mmarc5_" followed 4 numbers. have far: with open("file.txt") f: re = (mmarc5_) re.findall(mmarc5_\d{4}", f.read()) i keep getting error: nameerror: name 'mmarc5' not defined. you forgot quotes: re.findall(r"mmarc5_\d{4}", f.read()) and line doesn't make sense, delete it: re = (mmarc5_) did import re module? import re

iis 7.5 - IIS 7.5 HTTP 500.19 Internal Server Error Config invalid -

i using windows 2008 r2 iis 7.5 , have mapped source of website network drive. when do, below error occurs. when pointing local c: drive website works. error summary http error 500.19 - internal server error requested page cannot accessed because related configuration data page invalid. detailed error information module iis web core notification unknown handler not yet determined error code 0x80070003 config error cannot read configuration file config file \\?\h:\excelautomation\1.0\src\docs\web.config requested url http://vmwws085381.msad.ms.com:80/index.html physical path logon method not yet determined logon user not yet determined config source -1: 0: the solution me open iis, click on site, , under advanced settings change physical path network share \\server\share\.. instead of using mapped drive. original source helped me arrive solution here: http://forums.iis.net/t/1157959.aspx

java - IndexOutOfBounds Exception when filling multidimensional array -

i have xml data looping through. store each "entry" in array spot in order see intent.putextras(). data has 3 elements: latlon,name,description. put each in array. setting so: markerinfo[i][0] = loc; etc... so: final list<xmldom> entries = xml.tags("placemark"); int = entries.size(); int j=0; (xmldom entry : entries) { xmldom lon = entry.tag("longitude"); xmldom lat = entry.tag("latitude"); xmldom name = entry.tag("name"); xmldom desc = entry.tag("description"); string cdatareplace = desc.tostring(); string description = cdatareplace.replace("<![cdata[", ""); description = description.replace("]]>", ""); final string firename = name.text(); final string firedesc = description; string g

How to debug a SAS program in batch job on UNIX using PUT statement or any other? -

i tried debug sas batch program on unix using /debug in data step, throwing error because /debug can used in interactive mode. error message: error: cannot open x display. check display name/server access authorization. error: unable initialize data step debugger environment. then started running sas code put ( all )(=); creating huge log file. there other way debug sas code not print error , n variables in log when there data error. thanks, kumar. you can debug intelligently; means, figure out can go wrong, , use put statements @ variables. you don't have limit log; example, might debug data (in do, data more 'wrong' program, after i've finished writing first iteration) creating dataset contains statement false given correct data, if contains rows, shows problem - proc print dataset obvious title ("error has data , should not because of * reason *"). in terms of resolving how data step not working particular program, can put th

Readable way to concat many strings in java -

i have code written in cryptic fashion. sure going maintenance nightmare other me understand. its mishmash of string concatenation, ternary operator , concatenating using + operator. so question how make statement readable? tb.settally_narration( tb.gettally_mode().equals("ca") ? "receipt no. " .concat(tb.gettally_receipt_no()) .concat(", "+tb.gettally_mode()) : "receipt no. " .concat(tb.gettally_receipt_no()+", "+tb.gettally_mode()) .concat(", "+tb.gettally_instrument_no()+", "+tb.gettally_instrument_date()+", "+tb.gettally_instrument_bank()) ); edit: realize question subjective. , feel belongs codereview stackexchange site. moved there? since first line of string appears same, write as: stringbuilder narration = new stringbuilder("receipt no. "); narration.append(tb.gettally_receipt_no())

jsp - JSTL fmt:parsedate of pubDate attribute in RSS 2.0 -

i need parse string in order convert date: tue, 3 sep 2013 19:47:52 +0200 i'm using <fmt:parsedate var="parseddate" value="${pubdate}" type="both"/> but result is: org.apache.jasper.jasperexception: javax.servlet.servletexception: javax.servlet.jsp.jspexception: in &lt;parsedate&gt;, value attribute can not parsed: "tue, 3 sep 2013 19:04:18 +0200" what's wrong this? <fmt:parsedate> going attempt parse date based on locale . can see via <fmt:formatdate> : <jsp:usebean id="now" class="java.util.date"/> <fmt:formatdate value="${now}" type="both"/> i'd recommend using explicit pattern: <fmt:parsedate var="parseddate" value="${pubdate}" pattern="eee, dd mmm yyyy hh:mm:ss z"/> (the patterns letters simpledateformat )

ios - Play a recorded video from Ustream -

i've seen other day there's 1 way play embed videos ustream on ios, i'm looking way play recorded videos, this, http://www.ustream.tv/recorded/15480382 , knows how? thanks in advance

wpf - Pack URI syntax in User Control -

Image
i have simple project files within same solution. getting weird issue when trying reference resources in user control specifically. same pack uri syntax works in mainwindow.xaml when used in user control giving error. here files folder structure: here mainwindow.xaml screenshot: summaryview.xaml (usercontrol) screenshot: try writing out name of assembly explicitly: "pack://application:,,,/fibre_reporting;component/resources/brushes.xaml"

text - Python: Searching for exact filename -

in searching html within current directory, if name contains substring assume file exists , continue operation instead of saying file doesn't exist. have file "protocolhttp.html" - in testing make sure "protocol.html" throws error, doesn't. continues operation of program. i make sure filename matches exactly. here's have: for file in glob.glob('*.html'): if protocolfile in file: open(file) f: contents = f.read() else: print "could not locate '" + protocolfile + ".html'" sys.exit(1) any ideas or further steps check validate this? i think code same thing as: if os.path.isfile(filename): open(filename) f: contents = f.read() else: print 'could not locate {0}'.format(filename) sys.exit(1)

Convert a paramaterized query into a view in SQL Server -

suppose had following table in sql server: date cola colb 1/1/2013 val1a val1b 1/1/2013 val2a null 1/1/2013 val3a val3b 1/2/2013 val1a null 1/2/2013 val2a val4b and, i'm looking see day-over-day changes colb - which, in case follows: date cola colb_today colb_prev_day 1/2/2013 val1a null val1b 1/2/2013 val2a val4b null 1/2/2013 val3a null val3b so, created complex query (joining table itself) has single input variable , calculated variable looking follows: declare @date date = '1/2/2013', @prevday date; set @prevday = (select top 1 date mytable date < @date order date desc); select @date 'date', t1.cola, t1.colb colb_today, t2.colb colb_prev_day (select * mytable date = @date) t1, full outer join (select * mytable date = @prevday) t2 on t1.cola = t2.cola which i'm loo

SQL server modulus operator to skip to every n'th row on a large table -

i have large table 100,000,000 rows. i'd select every n'th row table. first instinct use this: select id,name table id%125000=0 to retrieve spread of 800 rows (id clustered index) this technique works fine on smaller data sets larger table query takes 2.5 minutes. assume because modulus operation applied every row. there more optimal method of row skipping ? if id in index, thinking of along these lines: with ids ( select 1 id union select id + 125000 ids id <= 100000000 ) select ids.id, (select name table t t.id = ids.id) name ids option (maxrecursion 1000); i think formulation use index on table. edit: as think approach, can use actual random ids in table, rather evenly spaced ones: with ids ( select 1 cnt, abs(convert(bigint,convert(binary(8), newid()))) % 100000000 id union select cnt + 1, abs(convert(bigint,convert(binary(8), newid()))) % 100000000 ids cnt <

java - Send file inside JSONObject to REST WebService -

i want send file webservice, need send more informations, want send them json. when put file inside jsonobject error saying isn't string. question is, should take file , convert string, put inside json , on web service take , convert string file? or there simple way? here code: client: private void send() throws jsonexception{ clientconfig config = new defaultclientconfig(); client client = client.create(config); client.addfilter(new loggingfilter()); webresource service = client.resource("http://localhost:8080/proj/rest/file/upload_json"); jsonobject my_data = new jsonobject(); file file_upload = new file("c:/hi.txt"); my_data.put("user", "beth"); my_data.put("date", "22-07-2013"); my_data.put("file", file_upload); clientresponse client_response = service.accept(mediatype.application_json).post(clientresponse.class, my_data); system.out.println("stat

csv - mysql load data local infile syntax issues with set fields -

i'm trying use mysql's load data local infile syntax load .csv file existing table. here 1 record .csv file (with headers): prod, plant,pord, revn,a_cpn, a_crev,brdi, dte, ltme 100100128144,12t1,2070000,04,3db18194acaa,05_01,ala13320004,20130807,171442 the issue want 3 things done during import: a recordid int not null auto_integer primary_key field should incremented each row gets inserted (this table column , structure exists within mysql table) dte , ltme should concatenated , converted mysql datetime format , inserted existing mysql column named trans_ocr a created timestamp field should set current unix timestamp on row insertion (this table column , structure exists within mysql table) i'm trying import data mysql table following command: load data local infile 'myfile.csv' table seriallog fields terminated ',' optionally enclosed '\"' lines terminated '\n' ignore 1 lines (flex_

c# - Oracle ODAC error setting up website in IIS: type A cannot be cast to type B? -

i have website i've developed in vs2010 cassini. it's gone production aleady , i'm doing ie9 upgrades when load local iis (so can hit vm) this: problem getting database connection: [a]oracle.dataaccess.client.oracleconnection cannot cast [b]oracle.dataaccess.client.oracleconnection. type originates 'oracle.dataaccess, version=4.112.2.0, culture=neutral, publickeytoken=89b483f429c47342' in context 'default' @ location 'c:\windows\microsoft.net\assembly\gac_32\oracle.dataaccess\v4.0_4.112.2.0__89b483f429c47342\oracle.dataaccess.dll'. type b originates 'oracle.dataaccess, version=2.112.2.0, culture=neutral, publickeytoken=89b483f429c47342' in context 'default' @ location 'c:\windows\assembly\gac_32\oracle.dataaccess\2.112.2.0__89b483f429c47342\oracle.dataaccess.dll'. @ dblib.mydatabase.getconnection() any clue or how around it? looks old version of data access dll installed in gac. dll i

php - Use a variable twice in prepared statement -

i'm beginning use prepared statements sql queries in php , in starting have come question. i have function grabs user's id table @ login. want user able use either username or email address login. so sql statement is: select * `login` `username`=? or `emailaddress`=? now when in query username , emailaddress same because can either or. so when binding statements bind variable twice: bind_param('ss', $user, $user); so value username , emailaddress needs same. want $user value of both placeholders. my questions are: am doing correctly? is there more efficient way? yes, have bind twice. if opposed reason, rephrase query as: select * `login` l cross join (select ? thename) const l.`username` = thename or `emailaddress` = thename; this using subquery name parameter can referred multiple times in query.

windows - Installing Casperjs with codeigniter in WAMP -

i following http://net.tutsplus.com/tutorials/javascript-ajax/responsive-screenshots-with-casper/ in order started phantomjs , casparjs. following directions have phantomjs installed in codeigniter root so: --application --system --index.php --phantomjs.exe --casparjs folder i've tested phantom using phantomjs --version , gives correct version info appears installed after added: e:\easyphp-12.1\www\myproject\casperjs\batchbin to path. tried: e:\easyphp-12.1\www\myproject\casperjs\batchbin>casperjs.bat --version and got: 'phantomjs' not recognized internal or external command, myoperable program or batch file. how can fix this? you should need add folder contains phantomjs.exe path environment variable.

r - Set the color of each arrow and dot in a biplot(prcomp) -

i need more complex color labels pca biplot . using usarrests data example: want each variable (murder, etc) plots pre-defined colored arrow, , each observation (alabama, etc) plots pre-defined colored name. at time, seems me ggbiplot , resolve that, needs dev version of r installed. i try biplot(prcomp(), scale=t, center=t) , instead of vegan functions. i'm trying figure out way configure biplot(prcomp()) arrows color handling usarrests.pca$rotation[i:f,] , observations names color manipulating usarrests.pca$x[b:e,] , not being succeded. can help?

Replicate element in a list of vector if length(vector)==1 in R -

i have simple list of vectors , replicate element of every vectors have length of 1. mylist <- list(c(98, 102), c(175, 177), c(239, 240), c(146, 147, 168, 169 ), c(240, 242), c(363, 391), c(144, 146, 146), 197, 126, c(181, 192)) results <- lapply(mylist,function(x) if(length(x)==1) rep(x[1],each=2)) i in results expected replicates, how keep in results vectors of length >1 ? can't find correct way this. i'm pretty sure quite simple... thanx helping you can add else statement leave elements more values mylist <- list(c(98, 102), c(175, 177), c(239, 240), c(146, 147, 168, 169 ), c(240, 242), c(363, 391), c(144, 146, 146), 197, 126, c(181, 192)) results <- lapply(mylist,function(x) if(length(x)==1) rep(x[1],each=2) else x) which results in [[1]] [1] 98 102 [[2]] [1] 175 177 [[3]] [1] 239 240 [[4]] [1] 146 147 168 169 [[5]] [1] 240 242 [[6]] [1] 363 391 [[7]] [1] 144 146 146 [[8]] [1] 197 197 [[9]] [1] 126 126 [[10]] [1] 181

Is PHP up and functioning properly -

is there way verify php 5 functioning on linux centos. there default address check if php 5 , running php not "up" not service or similar. verify php installed, open terminal , type: php -v should output like: php 5.4.9-4ubuntu2.2 (cli) (built: jul 15 2013 18:23:35) copyright (c) 1997-2012 php group zend engine v2.4.0, copyright (c) 1998-2012 zend technologies xdebug v2.2.1, copyright (c) 2002-2012, derick rethans then know php working. to use php through browser need webserver such apache.

knockout.js - Update Event on Custom Binding Not Triggered -

this html : hi, guys, i new bie on knockoutjs world, feeling interested use in next project because seems powerfull framework. having obstacles understand on how knockoutjs custom binding works because fail make works on own codes. did small experiment on own codes below: this code on html file: <form id="form1" runat="server"> <div data-bind="schoolcalendar: student"> </div> <br /> <input type="button" data-bind="click: change" value="click"/> </form> this javascript : var student = function (firstname, lastname, age) { self = this; self.firstname = ko.observable(firstname); self.lastname = ko.observable(lastname); self.age = ko.observable(age); } var model = function (student) { self = this; self.student = ko.observable(student); self.change = function () { self.student.firstname

Android animation not working on ProgressBar -

i trying use animations in android project try doesnt work line using animate progress bar. progressbar progressbar = (progressbar)convertview.findviewbyid(r.id.pb_loading); progressbar.startanimation(animationutils.loadanimation(getsherlockactivity().getapplicationcontext(),android.r.anim.fade_out)); this xml. <progressbar android:id="@+id/pb_loading" android:layout_height="64dp" android:layout_width="64dp" android:indeterminate="true" android:indeterminatedrawable="@drawable/spinner" android:indeterminateduration="2000" android:indeterminateonly="true" android:layout_centerinparent="true" />

How are percpu pointers implemented in the Linux kernel? -

on multiprocessor, each core can have own variables. thought different variables in different addresses, although in same process , have same name. but wondering, how kernel implement this? dispense piece of memory deposit percpu pointers, , every time redirects pointer address shift or something? normal global variables not per cpu. automatic variables on stack, , different cpus use different stack, naturally separate variables. i guess you're referring linux's per-cpu variable infrastructure. of magic here ( asm-generic/percpu.h ): extern unsigned long __per_cpu_offset[nr_cpus]; #define per_cpu_offset(x) (__per_cpu_offset[x]) /* separate out type, (int[3], foo) works. */ #define define_per_cpu(type, name) \ __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name /* var in discarded region: offset particular copy want */ #define per_cpu(var, cpu) (*reloc_hide(&per_cpu__##var, __per_cpu_offset[cpu])) #define __get_

can't install rails on new mint os load error openssl -

september 3rd updated sudo apt-get install libssl-dev libssl-dev newest version. but still getting same error. root@lintong:~# gem install rails error: loading command: install (loaderror) cannot load such file -- openssl error: while executing gem ... (nomethoderror) undefined method `invoke_with_build_args' nil:nilclass i installed ruby compiling did not use rvm. asked how install ruby on mint without using rvm here installed ruby using apt-get install ruby 2.0.0 succeeded not using correct ruby version now when gem install rails got above error, dependencies missing? don't use linux development. doing first time because deploying vps (digital ocean) i think you're missing libssl-dev package. try installing package , recompiling ruby. may missing other packages well.

MySQL Query for certain date range -

i'm having following table data: table: seasons id --------------------------- 1 2013-08-30 2013-09-04 2 2013-09-05 2013-09-08 3 2013-09-09 2013-09-20 i need run query returns records within date range, example: return records affected 2013-09-04 2013-09-05 it like date range: | 09-04 - 09-05| seasons: 08-30 - 09-04 | 09-05 - 09-08 | 09-09 - 09-20 so should return first 2 records. i've tried query between seams need build several cases - or there simpler way? thankx it's amazing no 1 has noticed 2 years, the other answers wrong because didn't take account case when both start date , end date fall beyond scope of search range. consider range of date: start_date <<---------------------------- date range --------------------------->> end_date and range of our search: start_date <<---------------------------- date range --------------------------->> e

php - Need to create a custom blank page in drupal -

i've installed drupal have basic user registration layer. need code php code in blank page, how can achieve in drupal? need know must put php code. thanks lot edit. basically need drupal user authorization. after user logged system want show him table data. table managed jquery. for want think it's not necessary custom module, if so, it's not hard do, can allways use existing drupal modules mixed want. you need: display suite , login redirect module basically need drupal user authorization. after user logged system want show him table data. for purpose can use login redirect module redirect user page want. now need code php code in blank page, how can achieve in drupal? need know must put php code. for can use display suite . display suite or ds comes new new text format: "display suite code" . text format allow add custom code pages (javascript,php,etc)

c++ - Why isn't my std::set sorted? -

i have class store data looks this: class dataline { public: std::string name; boost::posix_time::time_duration time; double x, y, z; dataline(std::string _name, boost::posix_time::time_duration _time, double _x, double _y, double _z); //assign these, not going here bool operator < (dataline* dataline) { return time < dataline->time; } } then read in bunch of data , .insert std::set of objects: std::set<dataline*> data; data.insert( new dataline(newname, newtime, newx, newy, newz) ); //...insert data - out of order here then run through data , stuff while appending new elements set. boost::posix_time::time_duration machinetime(0,0,0); for(std::set<dataline*>::reverse_iterator = data.rbegin(); != data.rend(); ++it) { if(machinetime < (*it)->time) { machinetime = (*it)->time; } machinetime += processdataline(*it); //do stuff data, might add append list below for(std::vector<appendli

standards - signed as default in C -

once again, i'm teaching class answer students questions c. here's 1 don't know answer to: there rationale behind accepting signed default modifier c? 1 have thought unsigned natural choice. so, design decision? in terms of standard (since question tagged such), signed marked default because that's how c implementations came before standard. the original ansi/iso standard mandates codify existing practice rather create new language. hence behaviour of pre-standard implementations important factor, per rationale document: the original x3j11 charter mandated codifying common existing practice, , c89 committee held fast precedent wherever clear , unambiguous. the vast majority of language defined c89 precisely same defined in appendix of first edition of c programming language brian kernighan , dennis ritchie, , implemented in c translators of time. (this document hereinafter referred k&r.) if you're looking find out why pre-standa

android - Robotium Test to Extract Cookies from WebView -

my sign process produces cookies in webview, not in native code. tests depend on cookies retrieved webview need way extract data webview inside robotium test. how can done? here webview fragment: public class mywebviewfragment extends fragment { private cookiemanager cookiemanager; @viewbyid webview mywebview; @afterviews void theafterviews() { mywebview.getsettings().setjavascriptenabled(true); mywebview.getsettings().setdomstorageenabled(true); cookiesyncmanager.createinstance(getactivity()); cookiemanager = cookiemanager.getinstance(); mywebview.loadurl(theurl); mywebview.setwebviewclient(new webviewclient() { public void onpagestarted(webview view, string url, bitmap favicon) { if ((url != null) && (url.equals(theurl))) { string thecookies = cookiemanager.getcookie(url);

Android: Image width inside a webview -

i have simple webview inside image i want set width attribute of image tag "90%" if size image > of device width my displaymetrics says screen dimesions 720x1220 , correct. displaymetrics{density=2.0, width=720, height=1220, scaleddensity=2.0, xdpi=320.0, ydpi=320.0} now image 600x300 code skip image when rendered runtime image big , go outside screen dimensions (so webview shows horizontal bar). seems the webview (vewport??) works in dpi , not pixel, need test if image > 300 px resize image there way know dimension of viewport in pixel ? your html being zoomed webview . try this. <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width" /> http://developer.android.com/guide/webapps/targeting.html#viewportdensity

c++ - pretty printing boost::mpl::string<...> types in gdb -

i use boost::mpl::string<...> types extensively... enough really debugging have types pretty-printed in gdb . so... instead of gdb showing individual (multicharacter literal) components ... boost::mpl::string<1668248165, 778856802, 778858343, ..., ..., 0, 0, 0, 0, 0, 0> it display equivalent string value instead ... boost::mpl::string<"the way out through"> i've seen gdb macros , python scripts pretty-printing stl containers in gdb , couldn't find 1 pretty-printing boost::mpl strings. can this? update: i've added +100 bounty... i'm looking solution utilizes latest gdb support pretty-printing via python (as described here stl containers). here solution utilizing boost-pretty-printer ( https://github.com/ruediger/boost-pretty-printer/wiki ): file mpl_printers.py: import printers import re import string import struct @printers.register_pretty_printer class boostmplstring: "pretty printer boost::mp

ruby - Lauching openshift rails app - Error "Tracker must be set!" -

pardon lack of knowledge of rails app deployment, having error when push rails app openshift, error passenger: tracker must set! if want error message, visit: http://beta-happycard.rhcloud.com/ thank you! i don't see error on page anymore in future if see error check out rack-google-analytics .

c++ - While loop and bool make program end -

code analyzes integer , asks user if wants analyze integer @ end. have set in while loop run when 'again' true. @ end user inputs 'n' no, not run number. problem program runs again after again = false. how can fix loop? think main focus @ bottom switch posted in case on looked in main part of code. int main() { bool again = true; bool flag = false; int usernum; int count = 0; int userhold1, userhold2; userhold1 = 0; userhold2 = 0; char choice; while ( again = true ) { cout << "please enter positive integer: "; // getting number test cin >> usernum; cout << endl; ////////////////////////////////// finding factors cout << "the factors of " << usernum << " are: "; (int i=1 ; <= usernum/2 ; i++) { if( isafactor ( usernum , , flag) ) { cout << << ", "; count = count + i; // keeping track of sum of factor

retrieving images from server using ajax, jQuery. code not working -

i using following jquery code retrieve images folder on server. var dir = "/images"; var fileextension=".jpg"; $.ajax({ url: dir, success: function (data) { $(data).find("a:contains(" + fileextension + ")").each(function () { var filename = this.href.replace(window.location.host, "").replace("http:///",""); $("body").append($("<img src=" + dir + filename + "></img>")); }); } }); i error "failed load resource file:///d:/images" image folder in same path index.html located. idea wrong code. new ajax, appreciated. you need serve file using web server, example xampp or iis or similar. otherwise code try read directly filesystem , it'll blocked browser. check url in address bar when load index.html file, start file:///, need set development web se

why Server.Transfer changes the font in asp.net -

Image
i need show alert message "you have been redirected logout page" redirect logout page.i followed below snippet.while redirecting font style changes, not required. kindly me solve issue. regards, sathya s response.write("<script> alert('you have been redirected logout page!');</script>"); server.transfer("logout.aspx"); before server.transfer after server.transfer what changing font response.write , not server.transfer . use this: clientscriptmanager.registerclientscriptblock... check here

jQuery - Bootstrap Carousel Slid Event -

i'm trying make simple event handler on bootstrap carousel sliding, , test later if statements, i'm alerting current slide, keeps returning 0 (my first slide) though it's sliding 1 2, or 0 1 example, show 0. var slide = $('#mycarousel .active').index('#mycarousel .item'); $("#mycarousel").carousel() $("#mycarousel").bind("slid", function(){ alert(slide); }); i fixed own issue adding in html of slider div's following data-slide-number="1" further detail shown here: http://bootsnipp.com/snipps/carousel-extended

jquery - Menu div slideup outside click -

<a class="btn">click me </a> <div class="content"> content </div> $('.btn').click(function(){ $('.content').slidetoggle(); }); fiddle here working fine , question need slide div.content when click outside .btn button thanks try , more usable , simple code, think $('.btn').click(function(){ $('.content').delay(100).slidedown( function(){ }); }); $('html').click(function(){ if( $('.content').is(':visible') ) { $('.content').slideup(); } }); demo

mysql - Using select last_insert_id() from php not working -

i have this exact same issue , answer old, , i've read other places use of mysql_insert_id() depreciated , should avoided in new code. the database innodb , primary key table set auto_increment. can see i'm doing wrong here? should note i'm beginner , learning on own, apologize glaringly obvious. $query = "insert venues (province,city,venue)" . "values " . "('$province','$city','$venue')"; $result = $db->query($query); if ($result) { echo "$result row(s) sucessfully inserted.<br/>"; } else { echo "$db->error<br/>"; } $result = $db->query("select last_insert_id()"); echo $result->num_rows //returns 1 echo $result; //nothing beyond line happens update: using mysqli. the correct way last inserted id, when using mysql_* make call mysql_insert_id() . what reading partially correct - mysql_insert_id in process of being deprecated, it's

sql server - Error near Where in SQL command -

i have following code update 2 columns 2 tables. error near 'where'. but, don't see error in doing same. ? :) update mp set mi.accountid = ad.accountid [gsf].[dbo].[metainformation] mi inner join [gsf].[dbo].[allocationdetails] ad mi.accountdetailid = ad.accountdetailid you need on specify join condition: update mi set accountid = ad.accountid [gsf].[dbo].[metainformation] mi inner join [gsf].[dbo].[allocationdetails] ad on mi.accountdetailid = ad.accountdetailid you can't specify rowset alias on left hand side of assignment in set clause.

asp.net mvc 4 - how to get data from JSON without using script? -

i want data json file without using script code! iam using mvc4 , want put code in .cshtml file, how can this? ( iam using kendo function) example: @{ viewbag.title = "home page"; } <div class="chart-wrapper"> @(html.kendo().chart() .name("chart") .title(title => title .text("share of internet population growth, 2007 - 2012") .position(charttitleposition.bottom)) .legend(legend => legend .visible(false) ) .datasource(datasource=>datasource.read(read=>read.url("~/"))) .events(e => e.seriesclick("onserieshover")) .series(series => { series.pie(new dynamic[] { new {category="asia",value=53.8,color="#9de219"}, new {category="europe",value=16.1,color="#90cc38"}, new {c

jquery - Left navigation folds in even if current? -

i have left navigation animation on hover - can see here: http://www.wearewebstars.dk/frontend/test/boerneunivers2.html if ex: click second navigation item, "li" class: current - when leaving "li" item, collapses - because of javascript, shouldnt os "current" li. in script hover function should triggered if li not current 1 - see script here: $(".left-navigation ul li:not(.current)").hover(function( e ){ var ment = e.type=="mouseenter"; // boolean true/false //alert(ment); $(this).stop().animate({width: ment?'95%':35}, ment?100:0, function() { $(this).find("span.nav-text").css({ display: ment? "inline-block" : "none" }); }); }); your selector should this: $(".left-navigation ul li:not('.current')") i think self-explanatory ;) edit: try doing this: $(".left-navigation ul li:not(.current)").hove

firefox background color not working properly -

whenever change background , foreground color in firefox options,it works.but problem changes colors of many buttons , other elements in webpage.sometimes images/buttons not displayed.hence website becomes difficult use.also allows limited colors(no option add custom colors).what should do? ex , in below image of stack overflow there no logo of site! http://i.imgur.com/g6ba7s6.jpg edit-i have used add on called 'no squint'.it changes color correctly but,like firefox,it not allow select custom colors.you restricted few colors.this big problem!

screen - Android Layout folder is not changing properly -

my android layout not changing layout folder on orientation change below layouts , permissions giving activity. default when open portrait or landscape working if change default portrait landscape or default landscape portrait not changing. there should not change layout structures , drawable using. //my activity permission <activity android:name="com.pro.sample.distributor1" android:label="@string/app_name" android:configchanges="keyboard|keyboardhidden|orientation|screensize|screenlayout" android:windowsoftinputmode="adjustresize" > </activity> //this sw-600dp-port <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/distributor_main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="1