Posts

Showing posts from April, 2010

javascript - ...scrollTop($(this)...) -

i have few div s .class class scroll position defined child of parent, need assign scrolltop() $(this) , $(".class").scrolltop($(this).parent().find('.child').scrolltop()); but code doesn't work... $(".class").scrolltop( function(){ $(this).parent().find('.child').scrolltop() } ); doesn't work either. clue? this assuming reading question right. have mulitple "class" elements have own "child" elements. need use each set every element separately. $(".class").each( function(){ var elem = $(this); var childsscrollposition = elem.parent().find('.child').scrolltop(); elem.scrolltop(childsscrollposition); } );

python - setting attribute in current_thread as state holder -

i have wsgi application can potentially run in different python web server environments(cherrypy, uwsgi or gunicorn), not greenlet-based. application handles different paths rest apis , user interfaces. during http call of app there need know, context of call, since implementation logic methods share code of api calls , ui calls , bunch of logic separated in many modules should react differently depending on context. simple , straightforward way pass parameter implementation code, e.g. apicall(caller=client_service_id) or usercall(caller=user_id), it's pain propagate parameter possible modules. solution set context in thread object this? def set_context(ctx): threading.current_thread().ctx = ctx def get_context(): return threading.current_thread().ctx so call set_context somewhere in beginning of http call handler can construct context ovject depending on environment data, , use get_context() in part of code must react depending on context. best practices achive th

How do you send POST parameters to a function in PHP using Fat-Free-Framework? -

the documentation on website bit lacking ( http://fatfreeframework.com/routing-engine ). want use shorthand expression of post: $f3->route('post /login','auth::login'); how send params auth->login() function above? this alternative way of writing it, bit longer: $f3->route('post /login', function($f3) { $params = $f3->get('post'); $auth = new auth; $auth->login($params['username'], $params['password']); } ); if mean auth::login should automatically receive post data argument, can't. all f3 route handlers receive following arguments: the framework instance the route tokens (if any) see here example. anyway, if auth->login function you're referring one included in framework , couldn't work in manner since login() function is not route handler . returns true or false . route handler has little bit more that: example, reroute user on success or

html - Resizing a background image, as it's too big for the browser -

so i'm designing web page incomplete atm, it's missing 2 buttons simple. instead of messing around divs , css styling decided make background in photoshop. created image in resolution of 1920x1080, when apply image background doesn't fit browser window bottom right corner missing. there code can add fix issue or best option recreating image @ smaller resolution , if so, resolution should build for? here link page in case didn't explain enough: http://www.itss.brockport.edu/~rsiss1/cis442/bulletinboard/bulletinboard here code: <?xml version = "1.0" encoding = "utf-8" ?> <!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>bulletinboard</title> <style> body {background: url(bulletinboardbg.jpg); background-position: center no-repeat;} </style> </head&g

asp.net - variable is not declared it may be inaccessible due to its protection level -

Image
my vb skills not best, , problem has had me stumped few days. in list of controls shown in visual studio not defined in code behind, can "mouseover" them , tooltip text pops right up. similar questions: this 1 had no solution - 'var_name'is not declared. may inaccessible due protection level.' in debug mode this 1 said solution in web.config, don't understand where/how - bc30451: 'mailvalidation' not declared. may inaccessible due protection level this 1 misspelled word - vb.net error: inaccessible due protection level update - here problem might clue problems are: in tools.vb module, have class access ldap. the namespace tools class given in login.aspx.vb code, yet login code not recognize tools class. pay close attention first part of error: "variable not declared" ignore second part: "it may inaccessible due protection level". it's red herring. some questions... (the answers might

graphics - graph a function restricted in R -

Image
i'd want plot function: f(x,y)=x^2-2*y, constraint: x+y=1 in graph functions overlap , not seen restricted function f(x,y). appreciate better if x+y-1=0 transparent. mi code in r: x <- seq(-5, 5, length= 10) y <- x fun1<-function(x,y){x^2-2*y} m <- outer(x, y, fun1) m[is.na(m)] <- 1 persp(x, y, m, theta = 30, phi = 30, expand = 0.5, col = "royalblue", ltheta = 120, shade = 0.75, ticktype = "detailed") par(new=true) fun1<-function(x,y){x+y-1} m <- outer(x, y, fun2) m[is.na(m)] <- 1 persp(x, y, m, theta = 30, phi = 30, expand = 0.5, col = "red", ltheta = 120, shade = 0.75, ticktype = "detailed") some overplotting might help. first plot suggested in comments above. de-select segments constraint violated assigning na, i.e. no plotting , overplot heavier color. ( found unless froze z-limits "shifted" @ last step. may need suppress z-axis labels, since still overlaying each

Chrome webNavigation.onComplete not working? -

i'm trying write chrome extension executes code when user on youtube page video. far can tell, code correct, isn't working. eventpage.js: chrome.webnavigation.oncompleted.addlistener(function(){ console.log("test") },{url: [{pathcontains: "watch", hostsuffix: "youtube.com"}]}); and manifest file { "manifest_version": 2, "name": "youtubeextension", "description": "a chrome extension youtube", "version": "0.1", "permissions": ["https://www.youtube.com/", "webnavigation"], "background": { "scripts": ["eventpage.js"], "persistant": false } } it seems oncompleted doesn't work on youtube. chrome.webnavigation.oncompleted triggered when document has finished loading. when navigate different page on youtube, new page not "loaded" in traditional way, page d

python - Cannot resolve keyword 'items' into field. Choices are: id, name -

i using photologue create photo gallery site django. installed django-tagging virtualenv, not knowing no longer supported photologue. now, after having performed migrations, whenever try add photo or view photo, fielderror @ /admin/photologue/photo/upload_zip/ cannot resolve keyword 'items' field. choices are: id, name. i uninstalled , reinstalled django, photologue, sqlite file, , removed django-tagging, problem persists. tried running different project uses photologue , shares virtualenv, , prompted perform same (assumedly destructive) migration. i can't figure out have possibly changed on system if problem spans multiple projects , dependencies have been freshly installed. exception location: /home/cameron/envs/photologue/local/lib/python2.7/site-packages/django/db/models/sql/query.py in raise_field_error, line 1389 traceback: environment: request method: post request url: http://localhost:8000/admin/photologue/photo/add/ django version: 1.7.1 python ver

Pandas Python - Create dummy variables for multiple conditions -

i have pandas dataframe column indicates hour of day particular action performed. df['hour'] many rows each value 0 23. i trying create dummy variables things 'is_morning', example: if df['hour'] >= 5 , < 12 return 1, else return 0 a loop doesn't work given size of data set, , i've tried other stuff df['is_morning'] = df['hour'] >= 5 , < 12 any suggestions?? you can do: df['is_morning'] = (df['hour'] >= 5) & (df['hour'] < 12) i.e. wrap each condition in parentheses, , use & , and operation works across whole vector/column.

python - Understanding matplotlib magnitude_spectrum output -

i'm having problems understanding output generated matplotlib's magnitude_spectrum function call. i have generated sine 50khz frequency, f_s = 488000.0 # hz t = np.arange(0.0, 1.0, 1/f_s) s1 = 100*np.sin(2*np.pi*50000*t) i plot resulting magnitude spectrum, after dividing number of fft bins s1_magspec = plt.magnitude_spectrum(s1,fs=f_s) plt.plot(s1_magspec[0]/len(s1_magspec[0])) the result single spike @ 50khz, magnitude of 50, opposed expected 100. can explain why is? here link ipython notebook describing showing afforementioned code , resulting plot: http://nbviewer.ipython.org/gist/bkinman/22cc15d3ad3b9b2db09e it looks has default setting fft window used. documentation says default hanning window. if use boxcar window instead: s1_magspec = plt.magnitude_spectrum(s1, fs=f_s, window=np.ones(s1.shape)) you'll peak @ 100, straight numpy fft. by way, if edited question put in line of code creating s1_magspec rather relying on notebook vie

Mass Creation of Google Leaderboards -

i have game there 68 objectives have own time tracking, more on way. there way create leaderboards on google play en masse? doing them individually incredibly tedious , error prone. this can done using publishing api: see https://developers.google.com/games/services/publishing/quickstart details.

javascript - Math formula for positioning a box relative to where the user clicked within constraints? -

this going difficult me explain i'm looking mathematical formula defines position box pops out relative user clicked in column of rows. here's attempt @ articulating mean: https://imgur.com/a/dbja3 the red circle user clicks in column on left , box on right pops out. when user clicks row @ bottom of column box should pop out bottom edge lined bottom of column. if user clicks in middle should aligned middle. box pops out never runs past height of column on left user never has scroll. does make sense? can use css set absolute position of box need formula work out should be. i don't think there's 1 formula satisfy condition, programming can working. start obvious: top := click.y - height / 2 bottom := click.y + height / 2 then refine it: if bottom > container.height -> bottom := container.height top := max(0, bottom - height) elif top < 0 -> top := 0 bottom := min(container.height, height) fi

filesystems - How to monitor individual files with Ruby listen gem? -

i'm trying use listen gem ( https://github.com/guard/listen ) listen specific files, far have been able base functionality of listening whole directories working properly. here's example of i'm trying @ moment: require "listen" module filetracker filedir = "/home/user/dir" filenames = [ "file1", "file2" ] # should track 'file1' , 'file2' in directory listener = listen.to(filedir, only: filenames) |modified, added, removed| puts "updated: " + modified.first end listener.start sleep end i have tried specifying single filename string only: parameter, didn't work either. my end goal able track list of user-defined files in various directories changes. want track each specific file, not the entire directory. i wasn't paying attention doing here. only: takes regex, failing construct , provide. can else out may need use listen watch or ignore specific files.

java - IndexOutOfBounds error when trying to get last value -

so suppose loop through array , finding @ points array starts new year , how many days in year. problem have can't last year of array 2013. 2010 [25202, 25567) 365 days. 2011 [25567, 25932) 365 days. 2012 [25932, 26298) 366 days. exception in thread "main" java.lang.arrayindexoutofboundsexception: 26663 @ weatheranalysis.yearsarray(weatheranalysis.java:213) public static void yearsarray(string a[]) { // array find amnount of days in year int range1 = 0; int range2 = 1; string year = ""; (int = 0; <= a.length-1; i++) { string s = a[i]; string p = a[i+1]; if (s.equals(p)) { range2 ++; }else{ year = s; system.out.println(year+" ["+range1+", "+range2 +") "+ (range2-range1)+" days"); range1 = range2; range2 ++; } }

Javascript blues in PHP: getElementById & getElementsByClassName -

this should simple enough, alas it's giving me issues: i have php page gives me 3 different iterations of td contents. first shown display: table-cell , , others hidden display: none . echo '<td style="display: table-cell" class="gamelinecell" id="'.$playerline.'" colspan="3">'; & echo '<td style="display: none" class="gamelinecell" id="'.$playerline.'" colspan="3">'; i have link corresponding each td option -- clicking supposed run function loadline pass string corresponds td id. id strings akin 'ev-f1' -- 5 characters, number, hyphen. echo "<a onclick='loadline(".$playerline.")' href='javascript:void(0)'>".$playerline."</a>"; the script hides td s of class gamelinecell , , displays 1 link clicked. <script> function loadline(line) { var lines = docu

r recognizing time columns from integer and float columns -

i have multiple columns integer , float data in them. want recognize of columns have date , time data. example column values 2,3 not time data column values "1959-12-31 17:00:02 mst" has date , time values. how can in robust way? i thought using as.posixct() function. realized as.posixct(2, origin = "1960-01-01") converts 2 time , makes recognizing time values difficult :( > z=2 > as.posixct(z, origin = "1960-01-01") [1] "1959-12-31 17:00:02 mst" > z1 <- sys.time() > z1 [1] "2014-12-01 19:08:21 mst" > class(z1) [1] "posixct" "posixt" > unclass(z) [1] 2 > unclass(z1) [1] 1417486102 > z1 [1] "2014-12-01 19:08:21 mst" > as.posixct(z, origin = "1960-01-01") [1] "1959-12-31 17:00:02 mst"

android - Tracing From Activity.java to ActivityManagerServices -

i'm trying trace registerreceiver() activity class understand process flow. i'll believe call end in activitymanagerservice.registerreceiver(). from understanding, should involve request systemservice, since activitymanagerservice live in systemservice. problem, cannot trace code execution flow activity.java activitymanagerservice. from developer.android.com: java.lang.object ↳ android.content.context ↳ android.content.contextwrapper ↳ android.view.contextthemewrapper ↳ android.app.activity i've been looking class above trace implementation of registerreceiver(), can not locate code request systemservice of activitymanagerservice. hope can explain how activitymanagerservice triggered. thank you. found answer google groups. since activity , contextthemewrapper not implement registerreceiver(), reach contextwrapper: contextwrapper.registerreceiver() [mbase in contextwrapper contextimpl] con

python 3.x - Clear PyCharm Run Window -

is there way clear "run" console in pycharm? want code delete/hide print() made previously. "clear_all" button, without having press manually. i have read there way in terminal os.system("cls"), in pycharm, adds small square without clearing anything. also, don't want use print("\n" *100) since don't want able scroll , see previous prints. in pycharm: cmd + , (or pycharm preferences ); search: " clear all "; double click -> add keyboard shortcut (set ctrl + l or anything) enjoy new hot key in pycharm console!

sql - How to use ORACLE MERGE statement to INSERT values using DECODE? -

i'm trying use merge upsert. update code works (i haven't posted here) merge statement insert giving following errors: ora-00963 ---missing expression (when select mentioned in insert-values) ora-00917 ---missing comma (when select removed) when format code, calls syntax check near values & points towards clause. basically want write merge-insert statement accommodates decode statement well. please me i'm new oracle. merge table1 t1 using(select distinct a_cd, f_str, a_pm, a_type table2) t2 on(t1.c_name=t2.a_cd) when not matched insert(c_type, c_name, c_value) values (select t3.c_type, t4.a_cd c_name, decode(t3.c_type, 'a comp', t4.f_str, 'a_pm', t4.a_pm, 'a_type' t4.a_type) c_value) from(select 'a_comp' c_type dual union select 'a_pm' c_type dual union select 'a_type' c_type dual)t3, (select distinct a_cd, f_str, a_

java - How to "hover over" the button in selenium? -

this question has answer here: how perform mouseover function in selenium webdriver using java? 7 answers how add hover element? consider below code: package automationframework; import java.util.concurrent.timeunit; import org.openqa.selenium.*; import org.openqa.selenium.firefox.firefoxdriver; public class loginpage { private static webdriver driver = null; public static void main(string[] args) { // create new instance of firefox driver driver = new firefoxdriver(); //put implicit wait driver.manage().timeouts().implicitlywait(10, timeunit.seconds); //launch website driver.get("url"); // find element that's id attribute 'account'(my account) // driver.findelement(by.xpath("/html/body/table/tbody/tr[5]/td/table/tbody/tr/td[2]/form/table/tbody/tr[3]/td[

python - django bytesIO to base64 String & return as JSON -

i using python 3 & have code, trying base64 out of stream , returnn json - not working. stream = bytesio() img.save(stream,format='png') return base64.b64encode(stream.getvalue()) in view, have: hm =mymap() strhm = hm.generate(data) return httpresponse(json.dumps({"img": strhm}),content_type="application/json" ) getting error not json serializable. base64.b64encode(stream.getvalue()) seems giving bytes in python 3.x, base64.b64encode accepts bytes object , returns bytes object. >>> base64.b64encode(b'a') b'yq==' >>> base64.b64encode(b'a').decode() 'yq==' you need convert str object, using bytes.decode : return base64.b64encode(stream.getvalue()).decode()

css3 - How to target media queries for Samsung tab 8.4 inch -

how target media queries samsung tab 8.4 inch. code @media (device-width: 800px) , (device-height: 1280px) when first appearance media query getting affected. once changed orientation portrait landscape , again portrait, style not getting affected. device specification : http://www.gsmarena.com/samsung_galaxy_tab_s_8_4-6439.php thanks in advance i can't test solution on physical device, can play orientation: landscape mode @media screen , (max-device-width : 1280px) , (orientation : landscape) { /* styles landscape*/ } portrait mode @media screen , (max-device-width : 800x) , (orientation : portrait) { /* styles portrait*/ } notice, different browsers (chrome, android native browser, firefox etc.) handle media queries in different way. example if use: @media screen , (max-width : 480px) it work on desktop chrome browser , on android smartphone browser, not on safari on iphone. make work on safari have use: @media screen , (max-device-w

Email Tracking for Crm Application -

i'm working on crm application , need track email of clients. how can implement emal sync functionality ? i'll use google apps marketplace. there several ways implement this. you use gmail contextual gadget - inserts configurable gadget gmail. can design gadget access crm. https://developers.google.com/gmail/contextual_gadgets you use gmail api connect gmail crm. build synchronisation process checks "crm" label example in users inbox. when labelled email can added crm. https://developers.google.com/gmail/api/ you build chrome extension extends gmail , allows crm access. extension can manipulate gmail dom. example of gmail.js https://github.com/kartiktalwar/gmail.js?utm_source=tuicool

sql - Whats Difference in performance of ViewBag and View Data and when to use which one -

i new mvc. want know when should use viewdata, viewbag , tempdata pass objects , there difference in performance of viewdata , viewbag? view data: view data dictionary object derived view data dictionary class. view data property of controller base class. view data used pass data controller corresponding view. usage: public actionresult index() { viewdata.name = "tony boss"; return view(); } view bag view bag dynamic property takes advantage of new dynamic features in c# 4.0. wrapper around view data , used pass data controller corresponding view. view bag property of controller base class. usage: public actionresult index() { viewbag.name = "tony boss"; return view(); } temp data: temp data dictionary object derived temp data dictionary class , stored in short lives session temp data property of controller base class. temp data used pass data current request subsequent request (means redirecting 1 page another).

c - GTK Application doesn't refresh UI when using OpenCV -

i have simple gui application wrote in c raspberry pi while using gtk+2.0 handle actual ui rendering. application far pretty simple, few pushbuttons testing simple functions wrote. 1 button causes thread woken prints text console, , goes sleep, while button stops operation locking mutex, changing status variable, unlocking mutex again. simple stuff far. point of using threaded approach don't ever "lock up" ui during long function call, forcing user blocked on i/o operations completing before ui usable again. if call following function in thread's processing loop, encounter number of issues. #include <opencv2/objdetect/objdetect.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <stdio.h> #include <errno.h> using namespace std; using namespace cv; #define project_name "camera_module" // include before liblog #include <log.h> int cameraacquireimage(char* pathtoimage

mysql - Using an index when searching by two columns -

i have large table from fetch data. data received using comparison of 2 columns, , b. there should not many rows match a. i want add index better performance. question need set index on both , b or enough set index on a? you can refer link better indexing. http://www.programmerinterview.com/index.php/database-sql/what-is-an-index/

nsarray - IOS App crash: [__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array -

i have method pass 'id' here: nsstring *id = @"4bf58dd8d48988d181941735"; [self getnames:id]; this works fine, when use 'id' object passed within segue: nsstring *id = _selectedstore._id; [self getnames:id]; i error: 'nsrangeexception', reason: '*** -[__nsarrayi objectatindex:]: index 0 beyond bounds empty array' what's going on? here's it's getting error. attempt (keep in mind i'm new @ this) take array of foursquare id's, names , photourl id's. if remove code creates photourl (i've noted in code) runs without crashing. - (void)getnames { nsmutablearray *final = [[nsmutablearray alloc] init]; (searchvenue *object in self.venues) { [foursquare2 venuegetdetail:object._id callback:^(bool success, id result){ if (success) { nsdictionary *dic = result; nsarray *venue = [dic valueforkeypath:@"response.venue"]; self.venue

ruby on rails: submit a form clicking a check_box using JQuery -

i have form. added jquery onchange submit number_field tag. same want check_box_tag. want form submitted if click on 1 checkbox. tried many options don't it. hope can me. <%= form_tag("/rooms/list", method: "get", :name => "list", :remote => true) %> <%= label_tag(:size, "gewünschte raumgröße:") %> <%= number_field(:room, :size, in: 0.0..999999999, step: 1.0, :value => @size, :onchange => ("javascript: document.list.submit();")) %> <br> equipment <br> <% @categories.each |category| %> <%= check_box_tag(category, {:remote => true, :onclick => ("javascript: document.list.submit();")}) %> <%= label_tag(category, category) %> <% end %> <% end %> i got it! <%= check_box_tag(category,true, false, :onclick => "javascript: document.list.submit();") %>

wpf - How to reference a ResourceDictionary from another assembly -

i have resourcedictionary defined in app.xaml that: <application x:class="controller.app" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <application.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="resources/mydictionary.xaml" /> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources> </application> now, since im using prism, would use styles in "mydictionary.xaml" in other modules/assemblies within application. the problem can access styles in modules like: <label style="{staticresource mylblstyle}"/> but in module cant access same style. error "the resource "mylblstyle" not resolved" .

git - including multiple gitignore files in one -

here content of gitignore of yadr, popular project built on top of zsh : 1 # osx taken from: https://github.com/github/gitignore/blob/master/global/osx.gitignore 2 # ---------------------------------------------------------------------------------------------- 3 .ds_store 4 # thumbnails 5 ._* 6 # files might appear on external disk 7 .spotlight-v100 8 .trashes 9 10 # windows taken from: https://github.com/github/gitignore/blob/master/global/windows.gitignore 11 # ---------------------------------------------------------------------------------------------- 12 # windows image file caches 13 thumbs.db ... that looks awful solution. => not possible include multiple gitignore, , have them maintained separately ?

haskell - Using lens for array indexing if both array and index are in State -

i have array , array index in state monad. can read idx using use , modify using += , other similar modifiers: {-# language templatehaskell #-} import control.lens import control.lens.th import control.monad.state import data.array data m = m { _arr :: array int int, _idx :: int } $(makelenses ''m) foo x = idx += x ii <- use idx return ii now want combine arr , idx form lens arr[idx] : combo arr idx = undefined bar x = combo arr idx += x ii <- combo arr idx return ii how can this? code different data.sequence ? the answer turned out just combo arr idx f m = (arr . ix (m^.idx)) f m as index may out of bounds, ix partial lens called traversal . bar has use uses instead of use : foo x = combo arr idx += x ii <- uses $ combo arr idx return ii also ii monoid m => m int instead of int , because of partiality. if original unsafe behaviour of returning int needed can restored replacing uses u

jquery - img element is not changing on view even when firebug shows changed image after image path is changed -

i using ajax replace 'html' of 'tr' element of table custom 'html'. grabbed tr element table , replaced html partial view content. image inside tr element not changing according partial view. //my javascripts $(document).on('submit', '#frm-update-prj', function (e) { e.preventdefault(); var myform = $(document).find('#frm-update-prj')[0]; var formdata = new formdata(this); $.ajax({ url: "/dashboard/saveeditedprojecttitle", type: "post", data: formdata, mimetype: "multipart/form-data", contenttype: false, cache: false, processdata: false, success: function (resultview) { var grid = $(".tbl-horizontal").data("kendogrid"); var selectedrow = grid.dataitem($(editelement).parents('tr')); select

html - Dynamic div height based on other divs dynamic heights -

i have sidebar search field, 2 lists , text div. height of search field , text div same heights of 2 lists unknown (meaning change). i wonder if there way, css, make height of first div dynamic changes depending on height of browser window , height/number of items in seconds list. second list have anywhere between 0 , 20 items in max-height of 40% of entire page height. <style> body, html { height: 100 % ;margin: 0;padding: 0; } ul { list - style: none; margin: 0; padding: 0; } #sidebar { max - height: 100 % ; overflow: hidden; width: 300 px; } #inputcontainer { height: 50 px; max - height: 50 px; overflow: hidden; background: #eee; } #firstlist { background: #ddd } #secondlist { width: 100 % ; background: #bbb; position: absolute; bottom: 120 px; width: 300 px; } #firstlist ul { max - height

android - Get and Store text from looped checkboxes into a String -

i kinda new in android , java programming, , have question, wish me solve :) i have program, fetch , loop data database , convert checkboxes, user must check checkboxes , hit submit button,, value(s) of checked checkboxes stored string[], send activity via intent.putextra.. so far, can fetch , loop data database, have no idea how store checked value (of checkboxes) string , sent activity via intent. can guys please me , should put code? and here code : private void fetchfromdatabase() { // todo auto-generated method stub mydb.open(); int totalgroup = mydb.counthowmanygroups(username); string groupid[] = mydb.fetchgroupid(username); string groupname[] = mydb.fetchgroupname(username); string flag[] = null; (int = 0; < totalgroup; i++) { listcheckbox = new checkbox(this); listcheckbox.settext(groupname[i]); listcheckbox.settag(groupid[i]); if (listcheckbox.ischecked()) { int x=0; flag[x]=l

java - Is there a language + framework that excels in multi tenant applications -

currently i'm doing research software company makes "e-invoice applications". these applications made ibm domino, want switch platform. 1 of requirements multi tenancy, want host multiple businesses on same cloud server. my question is: there language + framework excels in multi tenant applications? i love dynamicallytyped languages ruby , python, frameworks on rails , django. because programmer has more freedom , script shorter (most of times) compared static languages java. i'm still open languages / frameworks.

android - Navigation Drawer icon not shown -

i using custom action bar. code using - getactionbar().setdisplayoptions(actionbar.display_show_custom); getactionbar().setcustomview(r.layout.custom_home_action_bar); actionbar bar = getactionbar(); bar.setbackgrounddrawable(new colordrawable(getresources().getcolor( r.color.color_dark_blue))); but when use code customise action bar, navigation drawer icon not shown. when comment these lines shown cannot customise action bar.how can achieve both? thanks in advance i got solution. used getactionbar().setdisplayoptions(actionbar.display_show_custom | actionbar.display_show_home); instead of getactionbar().setdisplayoptions(actionbar.display_show_custom);

c - Efficiently compute the modulo of the sum of two numbers -

i have 3 n -bit numbers, a , b , , c . cannot calculate (a + b) % c can calculate a % c , b % c . if modulo operation unsigned , know ahead of time a + b not wrap around n bits can instead calculate ((a % c) + (b % c)) % c . however, possible cases modulo operation signed or addition of a , b might lead wrap-around. it looks there might confusion why ((a % c) + (b % c)) % c cannot relied upon work. here unsigned example: unsigned = 0x1u; unsigned b = 0xffffffffu; unsigned c = 0x3u; ((a % c) + (b % c)) % c == 0x1u (a + b) % c == 0x0u here signed example: int = 0x1; int b = 0xe27f9803; int c = 0x3u; ((a % c) + (b % c)) % c == 0x1u (a + b) % c == -2 what want is: ((a+b)%2^n)%c let a+b = k 2^n + d where k = 0 or 1 , d < 2^n . plugging in get: ((k 2^n + d) % 2^n) % c = (d % 2^n) % c = d % c taking previous expression modulo c get (a + b) % c = (k 2^n + d) % c => d % c = % c + b % c - k 2^n % c with n = 32 , in c: unsigned mymod(u

c# - Screenshots of multiple actionbar tabs -

i using xamarin , c# suspect problem equally valid in java environment. i have actionbar activity hosts 3 tabs each of hosts fragment. uses viewpager allow user swipe between tabs. the requirement programmatically screenshot each tab , email these attachments. the problem whilst actionbar/viewpager works optimises tabs - isn't creating fragment's view until next in line shown. so, if you're on tab 0 - first tab - fragment view tab 2 null. can't screenshot. to overcome have tried set tab/fragment has null view selected. generates view because setting selected not render on screen view not have width or height value again cannot screenshot (this reason defensive check @ start of code taking screenshot). so, guess question how can force tab rendered on screen correctly filled out , can screenshot? my main code extracts follows: private void emailreport() { list <bitmap> bitmaps = new list<bitmap>(); list <string&

ios - Adding a sound effect to a jump -

i want add sound effect jump action when character jumps. sounds simple cannot it, i've tried far.. in header file character have: systemsoundid jump; - (void)playsound:(nsstring *)jump1 :(nsstring *) mp3; in implementation file have: - (void)playsound :(nsstring *)jump1 :(nsstring *) mp3{ systemsoundid audioeffect; nsstring *path = [[nsbundle mainbundle] pathforresource : jump1 oftype :mp3]; if ([[nsfilemanager defaultmanager] fileexistsatpath : path]) { nsurl *pathurl = [nsurl fileurlwithpath: path]; audioservicescreatesystemsoundid((__bridge cfurlref) pathurl, &audioeffect); audioservicesplaysystemsound(audioeffect); } else { nslog(@"error , file not found aye: %@", path); } } also inside function jump have: [self playsound:@"jump" :@"mp3"]; please excuse inexperience had go @ great feature game, if tell me doing wrong or different , better way works great thanks!

reporting services - Sharepoint 2013 add SSRS 2008 reports -

Image
i have no knowledge on sharepoint , there contractor set bunch of ssrs 2008 reports on sharepoint site. left , joined company , given task add new ssrs reports site. in visual studio (bids) can see targetserverurl set sharepoint site , targetreportfolder, targetdatasourcefolder etc have been set site/project. have modified reports , deployed successfully. have sharepoint admin account think. part similar deploy reports report server. the sharepoint site when loaded below. when create new report in vs , deploy can see under project folder of sharepoint site. project folder in case eereports. the report added report1, if open eereports folder can see , run it. seems reports folder, not every report in folder on same domain. but if go default page, newly added report not there. do? guess there must work need done add report default site. all right figured out luck. click edit on page, create new list item new report, high light item , select insert - link - sh

ruby - Add a local gem into a Vagrantfile -

is there "clean" way add local gem vagrantfile ? i'm new ruby , vagrant , i'm playing vagrant 1.6.5 , ruby on mac os x. i'm trying write new gem, want add 1 or more vagrantfile , placed in different directories. edit gem , see how works every time execute vagrant . so have edited gemfile adding following line: gem 'myvagrantgem', :path => "~/wsruby/myvagrantgem" and have added line vagrantfile : require 'myvagrantgem' but when try execute vagrant : there error loading vagrantfile. file being loaded , error message shown below. caused syntax error. path: /users/freedev/wsruby/vagrant-ubuntu-lxc/vagrantfile message: cannot load such file -- myvagrantgem i specify absolute path of ruby file. suppose that, in ruby, if want add new object or library should specify gem dependency.

angularjs - call method from directive to controller -

i want call function in controller directive. my directive .directive('multecs', ['$http', function($http){ return{ restrict: 'a', replace:false, link: function(scope, elem, attr){ scope.addtoarray(); } } }]); method in controller $scope.addtoarray = function(){ console.log('method called'); } try passing in function want call directive. .directive('multecs', ['$http', function($http){ return{ restrict: 'a', replace:false, scope : { myfunctiontocall : '=' }, link: function(scope, elem, attr){ scope.myfunctiontocall(); } } }]);

javascript - How to restrict download of js files in a website? -

i developed website using html , javascript. logic lies in javascript files. want secure javascript files being download when user directly enters url. possible restrict? a javascript file downloaded client because client has able execute code inside. best thing can obfuscate javascript code.

mysql - PHP - Import csv into database data too long -

i'm trying upload csv file save records database php. used sql method load data infile didn't work anyway. index.php has form <input name='csv' type='file' id='csv'/> . my file upload has 5 strings columns , 2 integers (last of them), has 2 rows, header , values. they fields not null in 'usuarios' database. here's problem, when trying add record (for instance: 'bea') says that .....(sooo long)......k8docprops/app.xmlpk data long column 'nombreusuario' @ row 1 yeah, readfile shows that, changed details of every column (i don't think problem) , put values varchar(200) / integer(200) , whatever doesn't let me put more length because tried specified key long; max key length 767 bytes . and here's code, made others examples: subircsv.php require ('../cabses.php'); require ('../conecta.php'); if (isset($_post['submit'])) { if (is_uploaded_file(

ios7 - Adaptative layout iOS 8 and iOS 7 -

Image
i've develop app should work on ios 7 , ios 8 devices. i'm using xcode 6 develop , i'm having issue design ui. designed ui using adaptive layout, when try run app on device in it's installed ios 8 works great on display dimension (iphone 4s, iphone 5, 5c, 5s , iphone 6, 6 plus) can see on following screenshot: when try run on device in it's installed ios 7 trouble can see on following screenshot: how can fix issue? need design storyboard system should use if detect ios 7? hope can me

javascript - simple mailto function that composing an email from html file -

i need create simple mailto function when click on html file brings default email application composed mail "ready-to-go." figured click event on mailto id sufficient, not firing. should do? fyi, not want user click on hyperlink. plan on removing it. <script type="text/javascript"> $(document).ready(function(){ $("#mymailto").click(); }); // document.ready </script> <!doctype html> <html> <head> <title>your title here</title> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta http-equiv='cache-control' content='no-cache'> <meta http-equiv='expires' content='0'> <meta http-equiv='pragma' content='no-cache'> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> </head> <body> <a href="mailto:tes

crontab run shell script that write user history into a log file -

i write following shell script: #!/bin/bash histfile=~/.bash_history set -o history file=$(date "+%y_%m_%d_%h_%m_%s").txt history > /home/sandipon/$file cat /home/user/$file sshpass -p my_password scp /home/user/$file host:/home/test/$file and scheduled cron: */2 * * * * /home/user/history.sh but provides blank file. comment fedorqui correct. also, shoud add username in crontab file (if use "/etc/crontab"). example: */2 * * * * username /bin/bash /home/user/history.sh

java - Spring form binding drop down object -

facing issue in spring form binding.say have 2 models category , product. @entity @table(name="product") public class product { @id @generatedvalue private long productid; @manytoone @joincolumn(name="categoryid") private category category; //getters , setters } @entity @table(name = "category") public class category { @id @generatedvalue private long categoryid; private string categoryname; } in controller render add product page @requestmapping(value = "/productpage", method=requestmethod.get) private modelandview getaddproductpage(){ modelandview modelandview = new modelandview("add-product","product",new product()); map<category,string> categoriesmap = new hashmap<category, string>(); list<category> categories = categoryservice.getallcategories(); if(categories != null && !categories.isempty()) {

mysql - How insert multiple rows in three different table at a time through procedure -

if want insert multiple rows in 3 different table a, b , c @ time through procedure in mysql error comes when data inserted in " c " table , data not insert in table " c " data inserted in table " " , " b ". how can rollback table , b , how put exception log data not inserted in table " c ". you have set autocommit=0 before executing query. after call store procedure,if there error found in store procedure not call con.commmit() con object of connection class. if store procedure ran smoothly call con.commit() affect in table no need rollback it.

c++ - boost::property_tree::json_parser::read_json cannot read files if path contains cyrillic characters -

is possible open files have cyrillic parts in path? able read/write cyrillic contents of files, not know how open file as json_parser::read_json only has std::string parameter , no std::wstring. can me? this limitation inherited c++ standard streams. microsoft's streams have non-standard extension accept wstring paths, ptree doesn't allow them. try using boost.filesystem's streams. open stream outside function , pass open stream read_json .

git - Why does cloning a repo break my yii2 app? -

i have yii framework app , breaks when clone it. i've read here that, in yii, main.php file had excluded, supposed ignore yii2? (sorry, i'm still new frameworks...) when clone app need check , few things. of them depend on template use: run composer install install dependencies if you're using advanced template should run ./init in advanced template running above ./init create main-local configuration file bogus db component. need manually set password here (or remove if config versioned in main.php). depending on application might need run various db migrations via ./yii migrate . such case if you're using dbmanager of rbac system, or migrations created within app in regards testing (using codeception) have following: build codeception using : codecept build -c tests/codeception.yml basic template or codecept build -c tests/codeception/<suite>/codeception.yml advanced template, <suite> is suit running (ex: common, console

algorithm - Caterpillars and Leaves. Can we do better than O(n*c)? -

Image
found question while preparing interviews. suppose caterpillars start bottom , jump next leaf. eat leaf before jumping next. given array represents jump steps made caterpillars. if array [2,4,7], means caterpillar[­0] eat leaf 2,4,6.. caterpillar[­1] eat leaf 4,8,12.. , caterpillar­[2] eat 7,14,21...0 represents ground. calculate number of uneaten leaves. let assume caterpillar jumps next destination if current leaf eaten. means, if caterpillar[7] finds leaf 28 eaten, proceed eat leaf 35. let c number of caterpillars , n number of leaves. the obvious brute force solution iterating on bool array of size n each caterpillar , mark true if eaten or false otherwise. takes o(n*c) time. can better? a caterpillar eats multiple of 'jump step' j , if alone, each caterpillar eat floor(n/j) leaves. now have got figure out leaves have counted several times. example if count leaves dividable 2 first caterpillar, don't have count leaves second caterpillar, jumps 4

jquery - Javascript MDN Function prototype bind polyfill is enumerable in array -

i'm working on project in have created jquery plugin , various other js files use bind() in various places. client requested ie8 support out of blue, included function polyfills support ie8 in ie8 in loops following methods enumerable causes data corruption. for (var d in this.originalresponse.timespans) {} in particular our issue regarding bind() , here mdn polyfill using if (!function.prototype.bind) { function.prototype.bind = function(othis) { if (typeof !== 'function') { // closest thing possible ecmascript 5 // internal iscallable function throw new typeerror('function.prototype.bind - trying bound not callable'); } var aargs = array.prototype.slice.call(arguments, 1), ftobind = this, fnop = function() {}, fbound = function() { return ftobind.apply(this instanceof fnop && othis ? : othis, aargs.concat(array.prototype.sli

awk - How to extract common words from two files where one contains a PL/SQL block while the other is a list of functions used - in UNIX? -

i have file input_sql in unix. the file looks : yifi.yifi_bdcr_process_ log @bhor.ab.ctt.com group vdr_date; raise_application_error (-20004, 'pqi_sector_daily_v1 data not available. record_cnt ' || record_cnt); from rtb.s_rtb3_gsm_usid_dy@maxima_m62085_lnk.db.att.com raise_application_error (-20004, 's_btb4_gsm_usid_dy data not available. record_cnt ' || record_cnt); ,nvl(a.useid, b.useid) useid and cm_usid <> 'unassigned'; prompt updating process table log delete cqi_imp_metric_process_log insert cqi_imp_metric_process_log trunc(sysdate), sysdate, i have file b having text like: insert log group by nvl trunc sysdate log ln sign i wish extract common words between 2 files (select, insert etc.) in unix. the output should in third file c: group by || || trunc nvl trunc sysdate trunc sysdate thanks :) ps : using solution given, log, sign, ln getting included in third file coming cqi

asp.net mvc 4 - How to pass two model list in one view in mvc 4? -

my problem list<>,i taking 2 model in 2 list in controller action method pass values in 2 lists can not pass 2 list values in view,i giving code below,please give solution this. projet name myproject, model, public class table1 { public int id {get;set;} public string student_name {get;set;} } public class table2 { public int id {get;set;} public string roll_number {get;set;} } controller page, list<table1> t=new list<table1>(); list<table2> t1=new list<table2>(); public actionresult details() { sqldataadapter da=new sqldataadapter("select * table1",con); dataset ds=new dataset(); da.fill(ds); foreach(datarow dr in ds.table[0].row) { t.add(new table1() { id=int.parse(dr[0].tostring()), student_name=dr[1].tostring() } } sqldataadapter da1=new sqldataadapter(&quo