Posts

Showing posts from June, 2012

swift - How to initial correctly between two class -

Image
i want make sure in class home invoke class hud, , these 2 part code test okay when run in xcode, crash , show issue: "fatal error: use of unimplemented initializer 'init(size:)' class 'leftbehind.hud'" i hope told me how fixed it, thanks. import uikit import spritekit class hud: skscene { let positionx:cgfloat let positiony:cgfloat let sceneself: skscene let year = sklabelnode() let month = sklabelnode() let day = sklabelnode() let hour = sklabelnode() let minute = sklabelnode() init(positionx:cgfloat,positiony:cgfloat,scene:skscene) { self.positionx = positionx self.positiony = positiony self.sceneself = scene super.init() } required init?(coder adecoder: nscoder) { fatalerror("init(coder:) has not been implemented") } func hudshow() { year.fontnam

algorithm - how to remove duplicate numbers from unsorted array -

i given following question in technical interview: how remove duplicates unsorted array? one option thinking of: create hash map frequency of each number in array go through array , o(1) lookup in hash map. if frequency > 0, remove number array. is there more efficient way? another option sort array o(nlog n) using quick sort or merge sort then iterate through array , remove duplicates why option 1 better option 2? i cannot use functions work array_unique. instead of removing object array if hash map says there duplicate, why don't build new array each item in hash map, , add array if there isn't duplicate? idea save step of having 2 arrays equal overhead @ start. php sucks @ garbage collection if start massive array, though unset value, might still hanging around in memory.

javascript - jQuery .post or .get pass dynamic parameters -

the common way send request server is $.get('link/to/send', { param1: "value1", param2: "value2" }, function(result) { // ... etc }); now if want send dynamic parameter names, can jquery support that? (i.e. need write generic code can specify parameter names @ runtime) this not jquery dependent, it's vanilla javascript. you should this: var objtosend = {}; objtosend["param1"] = "value1"; objtosend["param2"] = "value2"; $.get('link/to/send', objtosend, function(result) { // ... etc });

javascript - How to simulate drag and drop feature using protractor for e2e? -

hi html code drag used is: <div class="btn-event" dnd-type="'newevent'" dnd-draggable="event" dnd-effect-allowed="copy" dnd-copied=""> <div class="icon"> <i class='demo'></i> </div> <span class="label" title="object name"> {{o.name}} </span> </div> the code drop is: <div class="row slot-body" dnd-list="sequenceslot.events" dnd-allowed-types="['newevent']" dnd-drop="drop(event, index, item, external, type, dropped item)" dnd-dragover="drop.validate(event, index, type)"> are supposed search dragabble ? or css ? use draganddrop() action method, example: browser.actions().draganddrop( element(by.css("div[dnd-draggable]")), element(by.css("div[dnd-dragover]")) ).perform();

java - Stream closed when using htpp client -

when using httpclient response error on line out.write(entityutils.tostring(resentity)); // line 70 in java code why happens? closeablehttpclient httpclient = httpclients.custom().setuseragent("mozilla/5.0 (windows nt 6.3; rv:36.0) gecko/20100101 firefox/36.0").build(); httpresponse response = httpclient.execute(new httpget(searchlink.tostring())); httpentity resentity = response.getentity(); system.out.println(entityutils.tostring(resentity)); printwriter out = new printwriter(new file("searchresult.xml")); out.write(entityutils.tostring(resentity)); out.flush(); out.close(); httpclient.close(); the error is 2015/08/07 13:03:12,887 error [stderr] (thread-101) java.io.ioexception: stream closed 2015/08/07 13:03:12,887 error [stderr] (thread-101) @ java.util.zip.gzipinputstream.ensureopen(gzipinputstream.java:61) 2015/08/07 13:03:12,887 error [stderr] (thread-101) @ java.util.zip.gzipinputstream.read(gzip

hibernate - Spring Data JPA repository query builder, many to many relationship -

i want construct find query in repository interface select elements mapped many many relationship. user.java: @entity @table(name = "user") public class user { @id @column(name = "id", columndefinition = "binary(16)") private uuid id; @column(name = "username") private string username; @column(name = "email") private string email; @column(name = "passwordhash") private string passwordhash; @manytomany(mappedby = "userstracking") private set<show> shows; ... show.java: @entity @table(name = "shows") public class show { @id @column(name = "id", columndefinition = "binary(16)") private uuid id; @column(name = "imdb_id", length = 9, nullable = false) private string imdbid; @column(name = "title", length = 100, nullable = false) private string title; @column(name = "

android - Scrolldown Listview from top -

i having 1 imageview , below imageview , having 1 listview . want scroll down listview top , zoom imageview when listview scrolls down. can ? basically, want zoom imageview on top of listview when pulls listview top. try this, listview , scrollview pull zoom : https://github.com/frank-zhu/pullzoomview

python - Re-running SQLAlchemy queries when connections get stale -

i have sqlalchemy connecting postgres via pgpool. pgpool configured recycle connections 60s old. i have 2 problems: 1) sometimes, huge query takes more 60s (i know it's bad... we're working on improving this) , subsequent queries fail because rely on same old connection no longer valid. 2) similarly, when start pyramid app using ipython, connections stale here when stop think moment. when attempting perform query session stale connection, exception saying: operationalerror: (psycopg2.operationalerror) connection terminated due client idle limit reached error: connection terminated due client idle limit reached sqlalchemy's pessimistic disconnect handling docs recommend testing connection when out of pool. however, connection becoming stale after being checked out, wouldn't much. i think right solution refresh session's connection upon getting type of error: session = mysession() # using scoped_session here query = session.query(...) try: ro

php - Why doesn't the rowcount and results show at the same time, when i am using setFetchMode(PDO::FETCH_ASSOC) -

well, trying query data , show results , see row_count. below code using: <?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "db_xx"; try { $conn = new pdo("mysql:host=$servername;dbname=$dbname", $username, $password); $sql = 'select * tbl_registration_requests flag_acceptance="0"'; $q = $conn->query($sql); $q->setfetchmode(pdo::fetch_assoc); $rows = $q->fetchall(); $num_rows = count($rows); } catch (pdoexception $pe) { die("could not connect database $dbname :" . $pe->getmessage()); } ?> and showing in table:: <table id="table_reg_confirm" border="1" cellpadding="5px" "> <thead bgcolor="#999999"> <tr> <th>id</th> <th>first name</th>

how to import .dbf file in python in windows environment? -

can tell me how import .dbf file in python . beginner. i have .dbf file me @ local location. need operations on record, using python. there python module called dbf should allow read data. module supports dbase, foxpro , visual foxpro files. dbf 0.96.003 ( https://pypi.python.org/pypi/dbf ?) pure python package reading/writing dbase, foxpro, , visual foxpro .dbf files (including memos) package documentation supports dbase iii, foxpro, , visual foxpro tables. text returned unicode, , codepage settings in tables honored. memos , null fields supported. documentation needs work, author responsive e-mails. not supported: index files (but can create tempory non-file indexes), auto-incrementing fields, , varchar fields. installation: pip install dbf

regex - Regex_Extract Using PIG -

i using pig string in set of records , output name of file(which appended end of each record using udf) , count of matching string. file name looks follows 2015-03-04.23_55_05.abhi_ram.info.json. below pig script: register udf; input_data= load 'input_dir' using classname(); record_match = filter input_data $0 matches '$search_string'; group_record = group record_match all; record_count = foreach record_match generate regex_extract($0,'((\\d{4}-\\d{2}-\\d{2})\\.(\\d.*)\.(\\w.*)\\.(\\w.*)\\.(json))',1), count(record_match); dump record_count; i want output 2015-03-04.23_55_05.abhi_ram.info.json, count($search_string). am missing in regex? i did'nt why want apply regex first field source. first field has filename pattern ?. because, $0 -> denotes first record in row. then,if want source filename in output record.the easy way read = load 'inp.data' using pigstorage(',','-tagsource'); which appe

node.js - Designing a thinner controller in SailsJS -

i new mvc programming.currently have user model 1 attribute timespent . using d3.js plot time spent per user in 1 of views. current way implementing incorporating logic of searching database , getting data in correct format in usercontroller . from have read on sails docs, recommend "thin" controllers whenever possible. else can incorporate search/formatting code in more reusable manner? controllers should thin because controllers :) it's common error when start using mvc framework put logic in controller, definetly should't there. if working data stored in database , related model, suggest logic should in model. many people think, model shouldn't thin possible :) and of course if not fit there, yann suggested, use services. part of yout application logic should there!

php - How to set to create users permissions in codeigniter -

i new codeigniter. project have 3 users. superadmin,admin , users. there base controllers : superadmin_controller, admin_controller, user controller which extends my_controller . the superadmin create admin, we can set how users admin creates. want whatever number of user admin asks can create users. till have managed create different credentials these users. want set permission of creating users number of users asked for(no of users fetched database). want understand is there way can restrict admin create specific number of user? please suggest tutorial. you can have 2 fields in database admin i.e. "users_limit","users_created" can store how many no. of users can created through admin "users_limit" , increase value of "users_created" value 1 whenever admin adds user. check condition whenever admin creates users if ((users_created+1)<users_limit){ /* allow creating user*/ } else { /* not allowed */ }

html - my whole div is clickable. can I make hover effects on links when the pointer is in the div area? -

http://www.grandeformato.com/new/ under slider have section called product-section clickable divs. css of "hover" of div is: .product-section ul li:hover { box-shadow: 0px 0px 6px 0px #ccc; } .product-section ul li h4:hover { color: #ff601a; -o-transition:.5s; -ms-transition:.5s; -moz-transition:.5s; -webkit-transition:.5s; } and can see link becomes orange (ff601a) when pointer on it. possible becoming orange when pointer on whole div? sure thing! you can use :hover sector on parent change child's properties. .product-section ul li:hover h4 { color: #ff601a; -o-transition:.5s; -ms-transition:.5s; -moz-transition:.5s; -webkit-transition:.5s; }

javascript - Why positioning element next to mouse cursor is so "laggy"? -

Image
https://jsfiddle.net/m0zwwav4/ html: <div id="container"></div> <div id="tooltip">tooltip!</div> css: #container { width: 500px; height: 500px; border: solid 1px red; } #tooltip { position: absolute; } js: var container = document.getelementbyid('container') var tooltip = document.getelementbyid('tooltip') container.onmousemove = function(event) { tooltip.style.left = (event.pagex + 20) + 'px' tooltip.style.top = event.pagey + 'px' } when move cursor inside red box, tooltip seems little bit laggy (there little delay) - testing in chrome on max os. there trick make faster make moving fast mouse cursor? you can without javascript. change container's cursor url, image containing tooltip text: you can using data uri: #container { cursor: url(data:image/png;base64,ivborw0kggoaaaansuheugaaaeoaaaazcaiaaaazqc9/aaaaaxnsr0iars4c6qaaaarnqu1baacxjwv8yquaaaajcehzc

ssrs 2012 - Reporting Services won't start -

i have sql 2012 rs entreprise edition machine won't start rs in native mode. following message when trying start services through reporting services configuration manager: system.invalidoperationexception: impossible de démarrer le service reportserver$new_instance sur l'ordinateur 'lenovo-g580p'. ---> system.componentmodel.win32exception: accès refusé --- fin de la trace de la pile d'exception interne --- à system.serviceprocess.servicecontroller.start(string[] args) à system.serviceprocess.servicecontroller.start() à reportservicesconfigui.panels.windowsserviceidentitypanel.startwindowsserviceprechangewindowsserviceidentity(servicecontroller rsservice) and following message when trying start services through sql server configuration manager: the request failed or service did not respond in timely fashion. i have added servicespipetimeout registry setting of 60000, rebooted machine, , same error messages showed! any plz! thank you,

SQL server Update using JOIN -

i used command in sql server update table using maximum data in other table innerjoin update dbo.table2 set table2.lastgrantdate = max(table1.plannedprojstartdate) table1 inner join table2 on table2.serial = table1.fundingestablish but doesn't work it workes when use without max() any way solve ?? you need use subquery. here 1 way: update t2 set t2.lastgrantdate = t1.maxppsd table2 t2 inner join (select fundingestablish, max(plannedprojstartdate) maxppsd table1 group fundingestablish ) t1 on t2.serial = t1.fundingestablish;

java - i want to slide image when i am touch to swipe in android using json url -

hi new android developer want swipe images in activity using json url how implemented can me please in advance you can implement using view pager pageradapetr. try understand below link. http://android-er.blogspot.in/2014/04/example-of-viewpager-with-custom.html

javascript - plot two ranges y-axis in a morris.js line chart -

i have 2 series different range , trying plot in 2 ranges different scale on 2 y-axis of line chart morris.js. possible? i can see 1 serie-1 because serie_2 plotted in value 0 because numbers smaller serie_1. new morris.line({ element: dest, data:data, xkey: 'date', ykeys: ['serie_1','serie_2'], labels: labels, ... }) tom lank pointed morris issue; got 1 there ( multiple scales same chart ), , there superimposed graphs @ superimposed graphs example . i'm not sure whether can superimpose graphs , change opacity using morris object model itself, sure doable plain css. that said, i'd rather present both graphics side side; superimposing them leads magnitude confusion. i hope helps!

css - manipulating wordpress "the_content" -

i'm working on wp site. article page, use <?php the_content(); ?> pull in content of post page i'm on. need manipulate first letter of first paragraph. fortunately me, first paragraph seems have unique class of excerpt . i'm able make big , change font, etc, issue arises when comes color. there 6 separate sections on site. each has it's own color. need letter appropriate color. however, @ point declares first paragraph of class excerpt it's out of hands can't dynamically add in color or add unique class name, etc. thoughts? edit upon request little of code: <div class="postexcerpt"> <span class="author">bob smith</span> <br/><br/> (this call the_content() , generates following <p> tags. oddly enough, when inspect element, see first 1 has class of `excerpt`, when view source, doesn't) <p>blah blah blahblah blah blahblah blah blahblah blah blahblah blah blah</p> <p&

ios - stuck at 3rd level of hierarchal tableview data -

i developing app using storyboard , using 2 uitableview , 1 label uiviewcontroller . app take data .plist file. able retrieve data .plsit show in first table , according selected row data shown on second table when click view detail second table 1 array strings can view , can't view others. here sample understating. > aa > aaa , b > bb > bbb. i have 3 topics in first table i.e. lumber puncture, urinary catheterization , veni puncture. when click on each cell displays me data in second uitableview according cell. lets suppose showing me following data: introduction indication equipments etc now when click introduction of lumber puncture data shows me detail of lumber puncture .plist array data. if click on urinary catheterization introduction on second data cell, shows me first lumber puncture detail. how can solve problem? kindly me detail answers new develop ios apps. thanks here code first table , passing data second table. @implementatio

amazon web services - Solr drops/deletes all old documents while reindexing -

Image
version: solr 4.1 problem statement: solr delete/drops old documents when click on full-import od data import handler. after full import complete, every thing works fine. help me understand jvm values attached image, trying connect issue. as per understanding solr not delete/drop old documents till new documents imported fully. in case drops old documents while new documents partially imported. details: we using solr cloud single shard , 2 replica. s1-r1--------s1-r2 using amazon load balancer balance hit on each of them. both of solr attached 3 zookepers. memory allocation: java_opts="$java_opts -xms8192m -xmx12288m -xx:permsize=3072m -xx:maxpermsize=8192m -xss4m" the solr admin panel showing: physical memory 98.2% swap space 0.0% file descriptor count 0.2% jvm-memory 34.3% solr delete/drops old documents when click on full-import of data import handler. after full import complete, every thing works fine. -- ask clean = true, cle

Where is "close diff window" in Intellij keymap and/or menu -

Image
there bug in latest intellij "escape" no longer closes popup "diff" windows such compare clipboard compare git show history i workaround closing window via option-f4 or control-w. keymap entry closing these windows? have searched on close , there no entry. the last fallback go snail way - mouse on click on red "close window" button: mouse movements slower keyboard shortcut. updated information note: normal "close window" keys (i on mac) not work. here ij bug entry https://youtrack.jetbrains.com/issue/idea-142932 another update here key bindings: notice there no close editor tab instead close all i'm using os x yosemite , pressing cmd + f4 has desired effect of closing window. cmd + f4 bound window / editor tabs / close.

python - How to search TextField for regular expression in Django? -

i submitting form in django , wrote clean function, attempts go through textfield , looks see if of words in field match words formatted --> #tweet, #people, , on, can not seem working(the form saves fine btw), knowledge of regular expression around zero, , yes know have used model form here experimenting because new django. forms.py class tweetform(forms.form): tweets = forms.charfield(widget=forms.textarea(), initial='write tweets here') class meta: fields=('tweets',) def clean(self): data = self.cleaned_data regular = re.compile('\b#\w\w+') clean_tweets = data['tweets'] lines in clean_tweets: words = regular.findall(lines) hashtags in words: print hashtags #want print them in terminal def __init__(self, userprofile, *args, **kwargs): super(tweetform, self).__init__(*args, **kwargs) self.userprofile = userprofile

python - XPath with Scrapy node begins with \n -

i'm using scrapy on html like: <td nowrap="" valign="top" align="right"> <br> text here. <br> other text here <br> </td> td[1]/text()[1] gives me: (empty line) text here. i've tried normalize-space, i.e. normalize-space(td[1]/text()[1]), works when test in firefox extension, not in scrapy. think scrapy getting tripped \n , skips on (or takes first line of node, nothing). i've tried "preceding" , "following" code, think might considered 1 element, dom says nodevalue = "\ntext here" thoughts?, extract every text, desired 1 index. instance: response.xpath("//table[@id='myid']/tr[1]/td[1]//text()")[1] demo scrapy shell: $ scrapy shell http://www.trobar.org/troubadours/coms_de_peiteu/guilhen_de_peiteu_01.php in [1]: table = response.xpath("//table")[2] in [2]: td = "".join(table.xpath(".//td[1]//text()

ajax - Get and pass Json file with PHP -

i have json file in server: file.json : {"max":"512", "min":"1", ... i ajax call: $.ajax({ url: 'load_json.php', type: "post", data: { id: id }, datatype: 'json', success: function(resp) { console.log(resp.json.max); } }); where load_json.php is: $json = file_get_contents("file.json"); $response = array('json' => $json); echo json_encode($response); but in console undefined . why? a possible solution is: $response = array('json' => json_decode($json)); is effective solution? in php reading file.json string , string putting array, javascript cant parse proper json object. use json_decode function in php code: $json = file_get_contents("file.json"); $response = array('json' => json_decode($json)); //here echo json_encode($response); or: $json = file

android - How can I resize the font in a scene2D select box? -

i'm creating android app using scene2d in libgdx. app have compatible many screen resolutions, problem at. font used in selectbox uses set amount of pixels, on 1080p phone screen small read, , on low resolution phone big. there seems no way scale text. here setup select box public void create(stage stageall, bitmapfont font, float width, float height){ screenwidth = width; screenheight = height; stage = stageall; tableskin = new skin(gdx.files.internal("resources/uiskin.json")); sb = new selectbox(tableskin); sb.setitems("5 km", "10 km", "20 km"); stage.addactor(sb); sb.setsize(screenwidth/2, screenheight/20); } thanks in advance james

export - Send text to non-active window via autohotkey -

for project need program exports text or spreadsheet data other programs word, excel, notepad, etc.. user set cursor in application wants export to, clicks in program on "export", start autohotkey .exe. figured out how window of other application, not how send data. here current code: winget, id, list window_id := id3 ;id2 = current program, id3 = program behind (we want send data here) controlsendraw, , myexportdatahere, ahk_id %window_id% ;<-------- doesnt work ;~ ///////////// works, ugly because of popup: ;~ window_id := id3 ;~ winactivate, ahk_id %window_id% ;~ sendraw myexportdatahere ;~ window_id := id2 ;~ winactivate, ahk_id %window_id% use first parameter of controlsendraw specify control this: http://lexikos.github.io/v2/docs/commands/controlsend.htm#function_syntax

javascript - Trouble trimming trailing comma from dynamically filled string -

i trying trim last character paragraph dynamically filling checkbox values. trouble must trim trailing character of whole paragraph. not want trim value before added list of values. here codepen: http://codepen.io/cavanflynn/pen/pqlwkj html: <dl class="dropdown"> <dt> <a href="#"> <span class="hida">▼</span> </a> </dt> <dd> <div class="mutliselect"> <ul class="ul"> <li> <input type="checkbox" value="ponumber" />number</li> <li> <input type="checkbox" value="authnumber" />auth number</li> <li> <input type="checkbox" value="statusid" />status</li> <li> <input type="checkbox" value="manufacturerid"

Rails / Devise: Namespaced RegistrationsController fetching non-namespaced views -

i have rails 4 / devise 3 app. have base set of routes , view files pretty standard. have namespaced portals set of views , routes hit when user access site through subdomain. how tell me namespaced portals::registrationscontroller devise views app/views/portals/devise rather app/views/devise ? here controller: class portals::registrationscontroller < registrationscontroller layout 'portals/layouts/application' append_view_path 'portals' def create @portal = portal.friendly.find(request.subdomain) super end def edit @portal = portal.friendly.find(request.subdomain) super end def update end end i tried using append_view_path 'portals' seemed have no effect. other non-devise controllers grab right view files default.

asp.net - Load object from RavenDB -

i'm trying refactoring on project. want replace code between lines , 2 commented lines above can use on page need quote object //quote.loadactive(); //quoteid = quote.id; //-------------------------------------------------------- list<quote> dbquotes = session.query<quote>() .customize(x => x.waitfornonstaleresultsasoflastwrite()) .tolist(); foreach (quote q in dbquotes) { if (q.isactive) { quoteid = q.id; quote = session.load<quote>(q.id); } } //-------------------------------------------------------- here's loadactive() function inside quote class public quote loadactive() { list<quote> dbquotes = session.query<quote>() .customize(x => x.waitfornonstaleresultsasoflastwrite()) .tolist(); foreach (quote q in dbquotes)

javascript - First class functions- how are even they possible? -

i'm struggling this. i'm reading book , example code works can't head around how. first class functions seem twist , turn, turn inside out , feed in , out of each other magic. goes this: var data = {}; data["value1"] = fancymethod.value1 ; data["value2"] = fancymethod.value2 ; data["value3"] = fancymethod.value3 ; getgoing( complexfunction , data); function getgoing( complexfunction , data){ function setupcomplexfunction(param1, param2){ var param3 = param1.somevalue ; complexfunction(param1, param2, param3, data); } importantfunction(getgoing); } the thing importantfunction() 1 sets processes used retrieve parameters functions feed it. so params obtained after importantfunction() called. how possible other code inside getgoing() runs ok when when unable obtain params until importantfunction() called? above simplification of code show concepts i'm struggling with. actu

php - redirect bots and crawlers via .htaccess -

hi , problem want redirect bots , crawlers site5 , real visitors site4 can see in schema http://i.stack.imgur.com/y3ofd.jpg what did created .htaccess file , put in site1.com/folder/ : rewriteengine on rewritecond %{http_user_agent} googlebot [or] rewritecond %{http_user_agent} msnbot [or] rewritecond %{http_user_agent} slurp rewritecond %{http_user_agent} facebookexternalhit/1.1 rewriterule ^(.*)$ http://site2.com/xyz/$1 [l,r=301] and did same in site2.com redirect site4.com did miss something? regards first, make sure apache setup functions correctly. after try like rewriteengine on rewritecond %{http_host} site3.com$ [nc] rewritecond %{http_user_agent} googlebot [or] rewritecond %{http_user_agent} msnbot rewriterule ^(.*)$ http://site4.com/$1 [l,r=301] to test can use simple curl simulate google bot request: curl -a "googlebot/2.1 (+http://www.googlebot.com/bot.html)" http://site3.com or headers only curl -x

android - ViewPager with multiple PageTransformer (PageTransformers at Runtime) -

i have custom requirement viewpager. want pager should have horizontal pagetransformer depthpagetransformer default. on screen have button on press of want current page slide on top bottom , next page replacing verticalpagetransformer , page changes page transformer should changed depthpagetransformer default one. so want apply pagetransformers on runtime. appreciated. here code: //sets intial page transformer viewpager.setpagetransformer(false,new depthpagetransformer()); now when tap button in onclick have: //sets vertical page transformer viewpager.setpagetransformer(false,new verticalpagetransformer()); viewpager.setcurrentitem(viewpager.getcurrentitem() + 1); then in onpageselected() set intial one @override public void onpageselected(int position) { viewpager.setpagetransformer(false,new depthpagetransformer()); } it sounds easy , correct page transformations not smooth @ all. behave weird. pages shrink @ time. page change fast 1 cannot see transformatio

Jquery.ajax POST call running wrong method supplied -

i trying run action method jquery.ajax call seeing controller name post method "edit" being run instead of action supplying in url attribute "deleteitem" client $.ajax({ type: 'post', url: '/edit/deleteitem?id=1', contenttype: 'application/json', success: function () { alert('deleted ok'); }, error: function (xhr, ajaxoptions, thrownerror) { alert(thrownerror); }, }); server code // expect running [httppost] public actionresult deleteitem(string id) { return json(""); } // , not [httppost] [authorize] [validateinput(false)] public actionresult edit(viewmodel) { try .... route config routes.maproute( "edit", // route name "edit/{id}", // url parameters new { controller = "edit", action = "edit", id = ur

jquery - Script being triggered too soon -

i trying replace sliders default "1, 2, 3" navigation words using jquery. i have working code: //changes slider numbers text navigation $(".rslides_tabs .rslides1_s1 a").text("automotive"); $(".rslides_tabs .rslides1_s2 a").text("residential"); $(".rslides_tabs .rslides1_s3 a").text("sign & millwork"); //wraps slider nav in containing div css purposes $("ul.rslides_tabs").wrap("<div class='rslides_wrap'></div>"); my problem is, half time when load page works , half time doesn't. feel it's getting called or something. have tried wrapping in both window.onload, , document.ready (and both of combined), still randomly doesn't work on page load. i've tried code above < head > tag, , right before < /body > tag, doesn't make difference. any suggestions on can make work 100% of time? http://tcgi.com.lindsayviscount.com/ i not

css - jQuery .show() is not working in Firefox -

the code below suppose have menu hidden until #menubutton clicked on, clicking on not revealing menu. used work has stopped , have no idea why. works in chrome not in firefox. <a id='menubutton' href="#"> <img src="/wp-content/themes/helpline/images/mobilemenu.png"> <div id='menubuttontext'> menu </div> </a> <ul id='menucontainer'> <li><a href='/'>home</a></li> <li><a href='/services/'>services</a></li> <li><a href='/about-us/'>about us</a></li> <li><a href='/procedures/'>procedures</a></li> <li><a href='/call-back/'>request call back</a></li> <li><a href='/contact/'>contact us</a></li> </ul> <script type="text/javascript"> var inout="0&qu

html - How to center the list icon for an image inside a li element -

li{ height: 20px; line-height: 20px; vertical-align: middle; } <ul style="list-style-type: circle"> <li><img src="http://latex.codecogs.com/gif.latex?a=b&plus;\left&space;(&space;c&plus;d&space;\right&space;)^2" height="20" width="150"></li> </ul> as not of browser support mathml use images equations. adjust height of images don't have problem when use images in text. have problem using images list element, bullet icon shown aligned bottom of image. i tried specify height of li element same height of image , assign same value line-height property. after use vertical-align: middle property doesn't work. what can done vertically center bullet icon? you need vertical-align img : ul { list-style-type: circle; } li { height: 20px; line-height: 20px; position:relative; } li img { height:20px; width:150px; border: 1px sol

c# - WCF. Set user credentials -

sorry, english bad. i have wcf services project , asp.net mvc project i'm using ninject wcf client extension inject services in example bind<iservice>().toservicechannel(); now i'm need add authentication , authorization wcf services. have implemented usernamepasswordvalidator , iauthorizationpolicy . in examples used service reference , user credentials added here: serviceclient host = new serviceclient(); host.clientcredentials.username.username = "user"; host.clientcredentials.username.password = "pass"; but didn't create service reference. have interfaces. , use here: public class homecontroller : controller { private readonly iservice _service; public homecontroller(iservice service) { _service = service; } } how can add user credentials? you need create channelfactory set user credentials: example : var result = new channelfactory<iservice>("*", new endpointaddress

How to get the total number of objects created in javascript for a class? -

lets have following code snippet: function airplane(id) { this.id = id; } var air1 = new airplane(234); var air2 = new airplane(235); var air3 = new airplane(236); is there way total number of airplane objects created airplane.getcreatedlength() ? you keep track of in property attached constructor: function airplane(id) { this.id = id; airplane.instances += 1; } airplane.instances = 0; var air1 = new airplane(234); var air2 = new airplane(235); var air3 = new airplane(236); console.log(airplane.instances) // 3

oauth 2.0 - Trying to use `oauth2-server-php` but token request simply prints contents of `token.php` -

i've been trying figure out how implement oauth2 server can handle authorization api. have read through documentation bshaffer's oauth2-server-php , tried following step step guide but when run curl -u testclient:testpass http://localhost/oauth2/token.php \ -d grant_type=client_credentials' it spits out contents of file token.php rather return access token. i modified path http://localhost/oauth2/token.php actual path token.php have installed. has else experienced or know causing it? looks short_open_tag issue. token.php file start short tag? if so, change long 1 ( <?php ) or enable short tags in php.ini .

twitter - twurl followers/ids.json ALWAYS returns my own followers -

here twurl command: twurl "cursor=-1&screen_name=forexcom&count=5000" /1.1/followers/ids.json this twitter account has 70k followers. when above command own 1600+ followers in list. the command formulated according twitter api guidelines here: https://dev.twitter.com/rest/reference/get/followers/ids i have tried , without cursor, using either screen_name or user_id or both. have passed count=1000 . nothing works. 1600+ of own followers. it's though not passing arguments @ all. can see errors in command? the format used post requests, -d switch added, of course. get requests should have parameters appended in query string: twurl "/1.1/followers/ids.json?cursor=-1&screen_name=forexcom&count=5000" the above query works.

c++ - Box2D can't run testbed -

i ran cmake , make on box2d success when try run testbed text below displayed in terminal nothing else happens. freeglut (./testbed): and after prompt. looks opengl/freeglut not working because helloworld working. the system ubuntu 12.04 the solution super simple, needed sleep solve it. reinstalled graphics driver , works.

python - HTML tables won't align properly in Outlook -

i trying attach html code outlook email via python. question surrounding html , outlook. trying use code below , make 2 tables aligned vertically. when have html code works fine, when mail outlook tables 1 on top of each other. thoughts on why happening. <html> <head> <title>tester</title> </head> <body> <table> <table style="border:1px solid black;border-collapse:collapse;float:left;margin:10px"> <th style="border:1px solid black;padding:3px" bgcolor="#dddddd" align="left">first</th> <th style="border:1px solid black;padding:3px" bgcolor="#dddddd" align="left">last</th> <tr bgcolor="#ffffff" style ="height:23px;"> <td style="border:1px solid black;padding:3px" align="left"><code> </code></td> <td style="border

c++ - CERN ROOT: Is is possible to plot pairs of x-y data points? -

i use cern root draw 2d graph of pairs of x-y datapoints possibly y-errorbars . know how draw histograms. is possible cern root? if how? also realize there may better libraries doing this. have been using gnuplot, unfortunately can't seem integrate c++ code, since can't find c/c++ gnuplot interface covers features , allows me send data in bidirectional manner - ie: both , gnuplot. if have better alternative suggestion welcome. there gnuplot iostream send data c++ gnuplot. within root, can use (as suggested others) tgraph , tgrapherrors , tgraphasymerrors . edit: the gnuplot iostream example homepage looks this. means once have data points either 1 vector of tuples or several vectors of floats, can send them gnuplot. #include <vector> #include <cmath> #include <boost/tuple/tuple.hpp> #include "gnuplot-iostream.h" int main() { gnuplot gp; // create script can manually fed gnuplot later: // gnuplot gp(">

jquery - $.getScript from dropbox password protected javascript file -

i want execute file dropbox. i have business dropbox account , can protect file using password. wonder if can send file's password in query parameters can execute command. for example: $.getscript('https://dl.dropbox.com/s/mlps4b84mt6f6ug/example.js'); the password file 'test'. how can access it?

ruby - Fiber.yield using || -

i following code: sg = fiber.new s = 0 loop square = s * s s += 1 s = fiber.yield(square) || s end end puts sg.resume puts sg.resume puts sg.resume puts sg.resume 40 puts sg.resume puts sg.resume 0 puts sg.resume puts sg.resume when run, outputs: 0 1 4 1600 1681 0 1 4 how line 6 s = fiber.yield(square) || s work? think understand component parts not line whole doing. (is there alternative way of writing might better me understand?). (edit: code modified example page 295 'beginning ruby, novice professional 2nd ed' peter cooper.) according docs yield any arguments passed next resume value fiber.yield expression evaluates to. the line s = fiber.yield(square) || s assigns argument passed resume s . if value nil (or argument missing), s re-assiged s (i.e. doesn't change). example: sg.resume #=> s = nil || s #=> s = s sg.resume 40 #=> s = 40 || s

django - Admin redirects to /login although REMOTE_USER is provided -

i configured authentication using remote_user in django project, replacing default modelbackend. however, when call admin page still redirects login page. tested with: curl -i -h 'remote_user: ruser1' http://localhost:8765/admin/myapp/mytable/ location: http://localhost:8765/admin/login/?next=/admin/myapp/mytable/ [edit: wrong - tested remote_user=ruser1 ./manage.py runserver] the remote user has been added auth_user table. my related config snippets are: middleware_classes = ( ... 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.auth.middleware.remoteusermiddleware', 'django.contrib.auth.middleware.sessionauthenticationmiddleware', ... ) authentication_backends = ( 'django.contrib.auth.backends.remoteuserbackend', ) you can't set remote_user http header, otherwise users able spoof header , log in user wanted. in production, remote_user environment variable set serv

python - How do I cron an ipython jupyter notebook's cells? -

i have ipython jupyter notebook i've developed , run django 1.8 with: manage.py shell_plus --notebook within notebook have written data analytics , reporting modules produce csv , html output via petl , pandas. i'd automate notebook in such way can cron notebook cells execute , serve static html output, don't see way run cells within notebook without human driving process, i.e. cron. nbconvert has --execute flag run notebook before converting format. so instance, run notebook , convert static html: ipython nbconvert --execute --to html mynotebook.ipynb if want run , save results ipynb file, can use --to notebook .

plugins - Python - How to check if requests installed correctly -

so i'm using import requests in 1 of python scripts keep getting large error looks .get() method i'm using out of requests isn't there, or wasn't installed correctly, when try pip menu isnt doing correctly. followed directions https://pip.pypa.io/en/stable/installing.html here, python get-pip.py won't work? feel missing simple.. advice? know have python installed correctly because whereis python comes correctly location. cambria@vayne:~$ pip traceback (most recent call last): file "/usr/bin/pip", line 9, in <module> load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() file "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 521, in load_entry_point return get_distribution(dist).load_entry_point(group, name) file "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2632, in load_entry_point return ep.load() file "/usr/lib/python2.7/dist-

sql server - Dateadd returning the wrong days in the month -

i have stored procedure runs pull data sales in given month. not return 31 days on months have 31 days. need understanding breakdown of following string (dateadd(dd,-(datepart(dd,getdate())),convert(char(8),getdate(),112)))+'23:59:59') i understand convert(char(8),getdate(),112) taking system date , converting yyyymmdd , datepart(dd,getdate()) takes system date , takes day part, cannot decipher entire string. there issue expression have given. bracket after 23:59:59 not have opening brace. however expression intends is: (datepart(dd,getdate())) getting the current date's day part convert(char(8),getdate(),112)) getting current date in yyymmdd (dateadd(dd,-(datepart(dd,getdate())),convert(char(8),getdate(),112))) subtracting day part today's date (see negative sign). thus trying first day of current month. in case result of above expression crosses last day of previous month, adds 23 hours 59 minutes. the logic intended last day of previ

java - My APK is over 50m, can i just move that APK into the expansion file and write a wrapper? -

my apk getting ready deploy 174m, on amount putting on google play (50m cap + 2 2g expansion files). could move apk expansion file , write wrapper "the apk" i thinking great way around google play limitations without needed excise non-critical components expansion. has else thought of going route?

functional programming - Standard ML: Basic Conversion to Uppercase Character -

i'm trying write function converts lower case character uppercase (if uppercase, leave unchanged). here's i've written: fun toupper(mychar) = exception invalidcharacter; if ord(mychar) >= ord(#"a") andalso ord(mychar) <= ord(#"z") mychar else if ord(mychar) >= ord(#"a") andalso ord(mychar) <= ord("z") chr(ord(mychar) - (ord(#"a") - ord(#"a"))); else raise invalidcharacter; i'm getting compilation error: ullman.sml:66.12 error: syntax error: inserting equalop uncaught exception compile [compile: "syntax error"] raised at: ../compiler/parse/main/smlfile.sml:15.24-15.46 ../compiler/toplevel/interact/evalloop.sml:44.55 ../compiler/toplevel/interact/evalloop.sml:292.17-292.20 am not allowed define exceptions within function i've done? thanks help, bclayman no, need define exception in let expressi

javascript - AngularJs filtering data based on option selection and tag creation based on selection -

here code : jsfiddle initialy should display data. i'm able add new tags , based on tag selection data filtering data should added below existing filtered data if new tag selected , data should removed if tag deleted. finally everything resolved. //filter .filter('findobj', function () { return function (dataobj, multiplevlaue) { if (!multiplevlaue) return dataobj; return dataobj.filter(function (news) { var tofilter = []; angular.foreach(multiplevlaue,function(v,i){ tofilter.push(v); }); return news.categorylist.some(function (category) { return tofilter.indexof(category.displayname)>-1; }); }); }; }) here u can refer : code

html5 - CSS Border-Radius Modulation -

Image
i have searched online extensively, cannot find discussion. is there way modulate border radius of object using css animation? looking kind of (either 1 of circles, not both): does have general idea if possible? i'm not looking exact replication, simple implementation of border-radius effect. ideas. this close can get: http://codepen.io/anon/pen/bnbnpg?editors=010 @-webkit-keyframes mymove { 25% {border-radius: 120px 100px 120px 110px;} 50% {border-radius: 100px 120px 110px 120px;} 75% {border-radius: 120px 110px 120px 100px;} 100% {border-radius: 110px 120px 100px 120px;} } i try doing code pen add instead. added border spins 1000 degrees lol div { width: 100px; height: 100px; border-radius: 100%; border-color: red; border-style: solid; position :relative; -webkit-animation: mymove 5s infinite; animation: mymove 5s infinite; } @-webkit-keyframes mymove { 25% { -webkit-transform: rotate(10000deg); } 25% {bo

r - How to color different groups in qqplot? -

Image
i'm plotting q-q plots using qqplot function. it's convenient use, except want color data points based on ids. example: library(qualitytools) n=(rnorm(n=500, m=1, sd=1) ) id=c(rep(1,250),rep(2,250)) mydata=data.frame(x=n,y=id) qqplot(mydata$x, "normal",confbounds = false) so plot looks like: i need color dots based on "id" values, example blue ones id=1, , red ones id=2. appreciate help. not used qqplot before, want use it, there way achieve want. looks function invisibly passes data used in plot. means can this: # use qqplot - generates graph, ignore plotdata <- qqplot(mydata$x, "normal",confbounds = false, col = sample(colors(), nrow(mydata))) # given have data generated, can create own plot instead ... with(plotdata, { plot(x, y, col = ifelse(id == 1, "red", "blue")) abline(int, slope) }) hope helps.

ios - How do I create one class to use in a different project? -

i have many projects in ios. of them use same classes (app1, app2 , app3 use same classes class1.m , class2.m ). there way collect these apps in 1 app (multi task) or use these classes 1 time apps? actually can compile classes static library , add future projects dependency. this tutorial it.

javascript - HTML5 Canvas — Line too thick -

Image
these past 2 days i've been playing around html5 canvas element. i'm attempting draw maze, i'm @ stand-still. line drew isn't consistent linewidth property. it's ~2px thicker. i'm familiar half pixel problem canvas element, , need start @ 0.5 , don't know need put 0.5 in code. if i'm not mistaken, if want make vertical line consistent, x argument needs .5 , horizontal line, y value needs .5? var canvas = document.getelementbyid("c"), c = canvas.getcontext("2d"), w = canvas.width, h = canvas.height, hallwaywidth = w * 0.10; /*18px*/ c.beginpath(); c.linewidth = 4; c.moveto(0, 0); c.lineto(w / 3, 0); c.moveto(0, 0); c.lineto(0, h); c.moveto(w, 0); c.lineto(w, h); c.moveto(w / 3 + hallwaywidth, 0); c.lineto(w, 0); c.moveto(0, h); c.lineto(w / 2, h); c.moveto(w / 2 + hallwaywidth, h); c.lineto(w, h); /*code thick line*/ c.moveto(hallwaywidth, 0); c.lineto(hallwaywidth, w / 3); c.stroke(); here'

Excel+VBA How can I set the bg colour of a cell using its own contents? -

i'm trying sheet entering rgb value cell set background colour value. know can use range("a1:be57").interior.color = rgb(127, 255, 127) to set background whole range 1 colour, each individual cell in range pull own contents. ideally having range("a1:be57").interior.color = rgb(.value) where .value replaced actual contents of cell (i.e. 127, 255, 127) each instance in range. though i'm aware unlikely simple. is possible? ok. here vba function takes string , attempts turn vba color-compatible string. below extremely simple usage example. should able take function , add code base. there no input validation ensure rgb string in correct format have tried original value of "127, 255, 127" , works "'127,255,127" value in a1. clear now. ' converts rgb string value hex string can use set color properties ' splits string rgb values, reverses them vba, , returns hex string public function convertvaluetocolour(r