Posts

Showing posts from August, 2014

javascript - AJAX call sending JSON data -

i working on chat system refreshes automatically using ajax. first using jquery $.post function, since wanted return json data php script, want use $.ajax function. script worked using $.post function, can not return json. relevant code: javascript: $.ajax({ url: "pages/loadmessage.php", type: "post", data: {"c": geturlparameter("c"), "t": messagetime}, datatype: "json", success: function(pdata){ console.log(pdata); }, error: function(xhr, status, error) { alert(error + status); } }); php code: <?php require_once("../init.php"); header('content-type: application/json'); if (input::exists() && input::get("c") && input::get("t")) { $chat = new chat($user->data()->id, input::get("c")); $messages = $chat->getnewmessages(input::get("t"), $user->data()->id); if ($messages) ...

ios - Using enum With Integers in Swift -

i'd know how can limit set of values can pass function argument (or class property). or, in other words, logic want implement, actually, make function or class accept particular values. i've come idea use enum it. caveat here can't use pure integers 'case' so: enum measure { case 1, 2, 3 } is there way implement want? enum measure:int{ case 1 = 1 case 2 = 2 case 3 = 3 } //accept argument func mymethod(measure:measure){ switch measure { case .one:... case .two:... case .three } } //call method raw data mymethod(measure(rawvalue:1)!) //or call method mymethod(measure.one)

r - "zoom"/"scale" with coord_polar() -

Image
i've got polar plot uses geom_smooth(). smoothed loess line though small , rings around center of plot. i'd "zoom in" can see better. using scale_y_continuous(limits = c(-.05,.7)) make geom_smooth ring bigger, alter because recompute datapoints limited limits = c(-.05,.7) argument. for cartesian plot use coord_cartesian(ylim = c(-.05,.7)) clip chart not underlying data. can see no way coord_polar() any ideas? thought there might way grid.clip() in grid package not having luck. any ideas? what plot looks now, note "higher" red line: what i'd draw: what when use scale_y_continuous() note "higher" blue line, it's still not big.

Building ionic, cordova app I get an Error: Cannot find module 'sax' -

i following instrucitons on how start building cordova apps android using ionic. when "ionic platform add android" on command line error error: cannot find module 'sax' cannot find solutions that. have idea comes from? thanks! i did originaly install on powershell using npm install. i didn't find solutions uninstalled ionic , cordova , reinstalled them both. fixed issue.

c# - Currency Format Returns Invalid Characters in Azure -

i have double amount 5190.40 , when convert "swiss franc" gives 5'190.40 . however, when deploy changes azure, not convert correctly. converted currency 5Â 190.40 , incorrect. culture name german (switzerland) . i using following code convert currency internal static string formatcurrency(this double amount, string currencycode) { var culture = (from c in cultureinfo.getcultures(culturetypes.specificcultures) let r = new regioninfo(c.lcid) r != null && r.isocurrencysymbol.toupper() == currencycode.toupper() select c).firstordefault(); if (culture == null) return amount.tostring("0.00"); culture.numberformat.currencysymbol = string.empty; return string.format(culture, "{0:c}", amount).trim(); } i executing code in following manner: double amount = 5190.40; amount.formatcurrency("chf"); ...

sql - How to set an object as an out parameter? -

i have written procedure in pl/sql , want return emp type object. possible that? if yes, how can it? here code: create or replace procedure get_emp_rs (p_deptno in emp.deptno%type, p_recordset out emp_det) emp_details emp_det; begin open p_recordset select ename, empno emp deptno = p_deptno order ename; fetch p_recordset emp_details; --exit when p_recordset%notfound; --end loop; --for indx in p_recordset --loop emp_details.ename:= 'test'; --end loop; end get_emp_rs; / set serveroutput on size 1000000 declare l_cursor emp_det; --l_cur emp_det; --l_ename emp.ename%type; --l_empno emp.empno%type; l_deptno emp.deptno%type; begin l_cur:=get_emp_rs ('30', l_cursor); dbms_output.put_line('low'); /*loop fetch l_cursor l_ename, l_empno, l_deptno; exit when l_curso...

iphone - Unable to copy symbols from this device Using iOS 9.2.1 Xcode is 7.2 -

could not resize “/private/var/folders/_5/jhpy2pns35n0kljwt0l08q_40000gn/t/temporaryitems/(a document being saved xcode 3)/dyld_shared_cache_armv7s” (no space left on device) has figured out how solve issue? trying set iphone 6s xcode, , started happening. tried reinstalling xcode, did nothing. i had same problem, had lots of free space on iphone claiming no space left on device. i hadn't thought memory on mac affect once deleted few files app downloaded device correctly. i recommend: make sure device , mac have enough memory clean xcode reset xcode the combination of of these fixed issue me. credit @vinícius albino in comments getting me answer

How to add settings and make then be built into an existing exe file in Delphi -

lets have program, modifying registry in windows. user can chose keys changed. after click "generate" create new exe file job depending on user choices. how can achieve "exe generating" clicking generate? first need have 2 exes. 1 main app, , second app changes registry. have append data copy of secondary app using main app , append data specifies keys change. 1 way use resources. use main app append required data resources target exe (the compiled to-be-generated exe). target exe file should check , load data resource own executable file , retrieve required data. you might find these links useful: how attach resource file existing executable file? and how retrieve resource in target exe: http://delphi.about.com/od/objectpascalide/a/embed_resources_2.htm

javascript - Cannot pass array to angular directive -

cannot pass array input mask plugin in angular. maybe can me this. angular.module('myproject.directives'). directive('inputmask', function() { return { restrict: 'a', scope: { inputmask: '@' }, link: function(scope, el, attrs) { $(el).inputmask(attrs.inputmask); } }; }); <input type="text" input-mask="{'mask': '9{4} 9{4} 9{4} 9{4}[9]', 'autounmask': 'true'}" /> the attribute value return string , not object needed pass plugin you can switch quotes around string valid json , parse json object <input type="text" input-mask='{"mask": "9{4} 9{4} 9{4} 9{4}[9]", "autounmask": "true"}' /> js .directive('inputmask', function() { return { restrict: 'a', scope: { inputmask: '@' }, ...

Azure automation powershell, not work int input parameter -

use azure automation, , have code this workflow report { param ( [parameter(mandatory=$true)] [string] $name, [parameter(mandatory=$true)] [int] $mycount ) inlinescript { write-verbose "name $name" write-verbose "count $mycount" } } in test pane (on https://portal.azure.com ) set next value parameters: "test" , 2 in console see next result: name test count $name working $mycount not showed according documentation i'm doing right https://technet.microsoft.com/en-us/library/hh847743.aspx how can use int input parameter? according post https://technet.microsoft.com/en-us/library/jj574197.aspx in inlinescript don't have access main variables main variable need use $using write-verbose "count $using:mycount"

javascript - jquery animate/scrollTop to multiple anchors inside divs -

i'm having problem implementing relatively complicated auto-scroll functionality on page. displays issue in code... http://codepen.io/d3wannabe/pen/xxxdqq i have multiple divs on page (blue,red,green in example) not want able scroll (which top 3 buttons in example achieve perfectly), want able scroll within (which bottom 3 buttons represent best attempt at). the thing can't figure out, why scroll within function works on first div ("scrollto3rdblueitem" button), less accurately other divs ("scrollto3rdreditem" , "scrollto3rdgreenitem" buttons). in full web application (which has more data scroll through), see lower down page parent div positioned, less accurately i'm able scroll within it. i'm struggling identify of pattern though can't try tweaking offset values. ideas might doing wrong here hugely appreciated!! ...since wasn't allowed post without quoting code - here's jquery function can see in codepen! fun...

How do I extract a single element from a JSON http response and pass it to C# as an integer? -

i'm writing wcf service , trying extract value sms following json string forms http response. rest of response superfluous requirements. {"balance":{"sms":100,"mms":2},"status":"success"} the code i've got @ moment ever returns '0' integer balance. public class balanceobject { public int sms { get; set;} public int mms {get; set;} public string status {get; set;} } public int balancerequest() { using (var wb = new webclient()) { byte[] response = wb.uploadvalues("http://api.txtlocal.com/balance/?apikey=", new namevaluecollection() { {"apikey" , api}, }); string result = system.text.encoding.utf8.getstring(response); javascriptserializer js = new javascriptserializer(); balanceobject request = (balanceobject)js.deserialize(result, typeof(bal...

javascript - $save().then on Angular $resource doesn't wait for the service response -

i have controller , function called obtain value rest wcf web service: foobar.controller('fooctrl', function fooctrl($scope, $http, $resource) { $scope.someonclickevent = function () { getsomething('a','b','c'); } } ); function getsomething($scope, $resource, a, b, c) { var servicehandle = $resource('some/addr'); var servicehandle = new servicehandle(); servicehandle.a = a; servicehandle.b = b; servicehandle.c = c; servicehandle.$save().then(function (result) { console.log('so response should ready'); $scope.result = result.valuefromservice; }); } as far know $save() returns promise , function inside .then should called right after response returned server. in case it's called imediately. if service returns true i'm going show popup, need value returned before conditional instruction executed. version of ang...

jsf - Primefaces duplicate header when i add a css rule -

Image
i use primefaces in order build datatable. problem when try align header whith columns using css rule (float: left) header row duplicated. question why happens , how can solved. below have code , snapshoot of duplicated table header. <h:form id="jobsform" styleclass="jobsform"> <p:datatable id="jobsdatatable" var="jobs" scrollable="true" value="#{jobsbean.getjoblist()}" selectionmode="single" widgetvar="jobs" rowkey="#{jobs.id}" styleclass="jobstable"> <p:column id="jobid" styleclass="jobcolumn" sortby="#{jobs.id}"> <f:facet id="idfacet" name="header"> <h:outputtext styleclass="jobtext" id="idlabel" value="#{msg.job_id}"/> </f:facet> <h...

reflection - How do I invoke a Java method when given the method name as a string? -

if have 2 variables: object obj; string methodname = "getname"; without knowing class of obj , how can call method identified methodname on it? the method being called has no parameters, , string return value. it's a getter java bean . coding hip, like: java.lang.reflect.method method; try { method = obj.getclass().getmethod(methodname, param1.class, param2.class, ..); } catch (securityexception e) { ... } catch (nosuchmethodexception e) { ... } the parameters identify specific method need (if there several overloaded available, if method has no arguments, give methodname ). then invoke method calling try { method.invoke(obj, arg1, arg2,...); } catch (illegalargumentexception e) { ... } catch (illegalaccessexception e) { ... } catch (invocationtargetexception e) { ... } again, leave out arguments in .invoke , if don't have any. yeah. read java reflection

google app engine - Objectify: How can I disable session cache? -

i love objectify's "just use ofy()" convenience objectify instance i'm running use case use advice. my use case datastore such in 1 part of process writing entities in long running process. hundreds of thousands of entities. scattered across time / entity-groups (so datastore contention isn't issue me). during long running process not have need read datastore entity more once. i know can disable "second level" cache using objectify.cache(false) create instance not use memecache. that's great. my concern on session cache. did little peeking objectify code , seems in writeengine.java when "save()" entity encounter: // stuff in session session.addvalue(key, obj); so objectify holding onto items in memory? i'd turn off saving entities in sort of cache of possible. unfortunately, right way call ofy().clear() periodically. see have added issue github tracker, good.

sql server - Combine different columns from 2 different queries into one resultset -

there many similar questions not wanted i'm reserved asking question forgive me if duplicate couldn't find precisely wanted. i have query: select top 1 t1.col1, t1.col2, <need_to_append_here> t1 left outer join t2 on t1.id = t2.id t1.id = 'x' order t2.col2 desc where see need_to_append_here , need different sql appended result 4 columns in result set: select t3.col3, t3.col4 t3 t3.id = 'z' i should see 1 row col1, col2, col3, col4 update able work single column 2nd query doing like select * (select top 1 t1.col1, t2.col2, (select t3.col3..) col3 .... but i'm unable include 2 columns in 2nd select you can join (or left join) since you're doing top 1 select top 1 t1.col1, t1.col2, t3.col3, t3.col4 t1 left outer join t2 on t1.id = t2.id left outer join t3 on t3.id = 'z' t1.id = 'x' order t2.col2 desc

html - CSS FlexBox Not Centering Horizontally Within IE On vBulletin Forum -

i have attempted align 4 images/links using flexbox simple banner row. works fine within chrome , ff, within ie 11, flexbox seems fail images stack vertically rather horizontally. you can view row of images here: http://bit.ly/1kz20hf they near top reads, "popular rpf pulse posts:" notice how in ie, banners stop being aligned horizontally. on local drive , on non vbulletin forum site there no issues within ie when test out banner code. wondering if dropping code within vbulletin framework causing issues ie 11. insights appreciated! thank you. css banner row uses below: .sgflexbox { padding: 0; margin: 0; display: -webkit-box; display: -ms-flexbox; display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-justify-content: center; justify-content: center; } .sgflexitemfooter { width: 205px; height: auto; margin: 0 12px 15px 12...

Get list of all loaded types in FxCop -

in custom fxcop rule how find implementation of given interfacenode? if there easy way, can @ least list of loaded types find out myself? answering own question. couldn't find public helper gives me loaded assemblies , types, there internal property microsoft.fxcop.sdk.internalutilities.loadedassemblies in fxcopsdk.dll can used list loaded types. there pretty intuitive find implementations of interface.

c# - Issue with method to calculate and display -

so, i'm having issue programming assignment (i'm not going lie, homework). teacher assigned following: input user total of purchase , amount submitted, call single method main routine calculates , displays results (where results change user gets in hundred dollar bills, fifty dollar bills, etc. have workable code problem, know i'm not fulfilling requirements. have "gut feeling" there's better way write code isn't bulky. i'm looking suggestions on how improve code have. in advance help. using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace change { class change { static void main(string[] args) { //initialize variables double costofpurchase = 0; double amountsubmitted = 0; double hundreddollarbills = 0; double fiftydollarbills = 0; double twentydollarbills = 0; dou...

python - How to use cxFreeze make an exe file including pygame module -

i make game using python 2.7.11, use cxfreeze creat exe file make sure others can play on other computers. disturbs me. cann't let pygame modules link testspeed.exe. python edition 32bit, , pygame module 32bit too. ide pycharm. things python in c:\ , testspeed.py in e:\ please me! this setup.py code: import sys cx_freeze import setup, executable # dependencies automatically detected, might need fine tuning. build_exe_options = {"packages": ["os"], "excludes": ["tkinter","pygame"]} # gui applications require different base on windows (the default # console application). base = none if sys.platform == "win32": base = "win32gui" setup( name = "testspeed", version = "0.1", description = "test speed!--lcy", options = {"build_exe": build_exe_options}, executables = [executable("testspeed.py", base=base)]) i type code i...

Is there a in built method from python csv module to enumerate all possible value for a specific column? -

i have csv file has many columns. requirement find possible value present specific column. is there built in function in python helps me these values. you can pandas . example file many_cols.csv : col1,col2,col3 1,10,100 1,20,100 2,10,100 3,30,100 find unique values per column: >>> import pandas pd >>> df = pd.read_csv('many_cols.csv') >>> df.col1.drop_duplicates().tolist() [1, 2, 3] >>> df['col2'].drop_duplicates().tolist() [10, 20, 30] >>> df['col3'].drop_duplicates().tolist() [100] for columns: import pandas pd df = pd.read_csv('many_cols.csv') col in df.columns: print(col, df[col].drop_duplicates().tolist()) output: col1 [1, 2, 3] col2 [10, 20, 30] col3 [100]

php - Fb Ads api How to get Active only FB Campaigns? -

i trying campaigns list facebook ads api using below code $account = new adaccount('act_' . $account_id); $campaignsets = $account->getcampaigns(array( campaignfields::id, campaignfields::name, campaignfields::start_time, campaignfields::stop_time, campaignfields::spend_cap, 'effective_status' )); but need active campaigns list how can filter list camapign status = active only thanks, ronak shah if check method declaration adaccount->getcampaigns , see accepts 2 parameters $fields , $params . $fields fields want retrieve, , $params filter. example in case (tested v2.5):- $account = new adaccount('act_' . $account_id); $fields = array( campaignfields::id, campaignfields::name, campaignfields::start_time, campaignfields::stop_time, campaignfields::spend_cap, 'effective_status' ); $params = array( ...

javascript - Create a transparent mask overlay in CSS -

Image
so i'm making game character moves in dark cave torch. want torch light area around character players can see character. able image, image must @ least 2000 x 2000px cover enough area around character. because image 2000 x 2000 fps dropped 50 30. anyway in css? notice visible area under black area not image divs backgrounds. btw i'm making html/javascript game if wonder. you can use box-shadow property generates shadow around css object. have 'negative' shadow, can use 'inset' property applied whole screen : box-shadow: inset 3px -5px 81px 97px rgba(0,0,0,0.89); the first , second px properties allow move negative shadow around center. have blur radius, spread radius, , rgb color (with opacity) you can play these settings see results, example in this tool. (don't forget inset toggle @ end).

javascript - Load content on page load dependant on hash url parameters -

jquery/javascript novice trying figure out how load content on page dependent on multiple window.location.hash parameters. i wondering if create if statement following: if (window.location.hash){ $('li[data-style"' + style + '"]', '#options > ul').trigger('click'); } else { $('li:first', '#options > ul').trigger('click'); } the else statement works can't if statement work. full code below <script> (function($) { var urlprops = {}; $('#options > ul').on('click', 'li', function() { var $this = $(this).addclass('selected'), imgid = $this.parent('ul').data('img'), img = $(imgid), cat = $this.data('cat'), style = $this.data('style'), desc = $this.text(); $this.siblings().removeclass('selected') img.attr('src', '/' +...

github - fatal: Unable to create in git -

i have 2 machines work on. have github account. today message: username 'https://github.com': jgoldstick password 'https://jgoldstick@github.com': counting objects: 29, done. delta compression using 2 threads. compressing objects: 100% (14/14), done. writing objects: 100% (16/16), 2.61 kib | 0 bytes/s, done. total 16 (delta 12), reused 0 (delta 0) https://github.com/jgoldstick/baseball.git 7be5c2d..d324acb master -> master fatal: unable create '/home/jcg/code/python/venvs/baseball/.git/refs/remotes/origin/master.lock': permission denied unexpected end of command stream (baseball)jcg@jcg:~/code/python/venvs/baseball$ however on github looks push worked. caused error message? here's error message: fatal: unable create '/home/jcg/code/python/venvs/baseball/.git/refs/remotes/origin/master.lock': permission denied that looks directory on local machine ( not github). current user (jcg) doesn't have permission file. it...

Factorize javascript/jquery code for hiding modal when click outside -

i have code work don't know how factorize it. seems able they're same code first desktyop touch devices: //desktop $(document).mouseup(function (e) { var container = $(".messenger"); if (!container.is(e.target) // if target of click isn't container... && container.has(e.target).length === 0) // ... nor descendant of container { container.empty(); container.off( 'click', clickdocument ); } }); // touch devices ipad , iphone can use following code $(document).on('touchstart', function (e) { var container = $(".messenger"); if (!container.is(e.target) // if target of click isn't container... && container.has(e.target).length === 0) // ... nor descendant of container { container.empty(); container.off( 'click', clickdocument ); } }); quite easy: // desktop (mouseup) // or touch devices ipad , ...

html5 - Hide default css button -

this question has answer here: styling input type=“file” button 37 answers i using: <div class="upload-area"> <input type="file" name="attachemnt" class="buttonclass" /> </div> i trying hide default css button, , make nice one, cannot figure out how. can help? there no standard way this. can hacks. method you .fileinput { cursor: pointer; height: 25px; overflow: hidden; position: relative; width: 100px; } .fileinput em { background: linear-gradient(to bottom, #d65a75 0%, #cd4874 100%) repeat scroll 0 0 transparent; color: #ffffff; cursor: pointer; display: inline-block; font-family: 'arial'; font-size: 15px; font-style: normal; margin-top: 5px; padding: 4px 7px; text-decoration: none; text-shadow: 1px 1px 0 #b8283d;...

hive - Hue: oozie parameters -

Image
i want pass 2 parameters hiveql script in oozie, script: alter table default.otarie_appsession add if not exists partition ( insert_date=${dt},hr=${hr} ); my oozie workflow : when send job ask parameter values, put: and error: 2016-02-05 18:41:55,460 warn org.apache.oozie.action.hadoop.hiveactionexecutor: server[dvs1vm65] user[root] group[-] token[] app[my_workflow] job[0000290-160122145737153-oozie-oozi-w] action[0000290-160122145737153-oozie-oozi-w@hive-a586] launcher error, reason: main class [org.apache.oozie.action.hadoop.hivemain], exit code [40000] this xml of workflow: <workflow-app name="my_workflow" xmlns="uri:oozie:workflow:0.5"> <start to="hive-a586"/> <kill name="kill"> <message>l&#39;action échoué, message d&#39;erreur[${wf:errormessage(wf:lasterrornode())}]</message> </kill> <action name="hive-a586"> <hive xmlns=...

enter - How do I call a Javascript Function using JQuery? -

i i'd javascript function called jquery script: document.location.href = 'http://cse.google.com/cse?cx=009002930969338329916:kta6o_isob0&q=' + escape(document.getelementbyid('search-box').value) i'm using caret coding program, use chromebook. live event handling removed in jquery 1.9, using 1.11. , try using on instead. chrome works fine. here fiddle https://jsfiddle.net/atg5m6ym/359/ also check keyup returning 13 need. $(document).ready(function() { $('#search-box').on("keyup", function(event) { $('#submit').click(); }); }); if input in label on keyup you'll see hello world. if(event.keycode == '13') enter or return key

c++ - Passing non-thread-safe objects through thread-safe containers -

i have thread-safe object queue designed model pipeline of work moving between chain of threads. in cases, want pass non-thread-safe objects (e.g., std::vector s, or other stl containers) part of these work items. now, in case have shared object between threads, there obvious problem of load/store ordering in ensuring object consistency. since thread-safe queue ensures 1 thread has ownership of object there no chance multiple threads trying modify or read object @ same time.. possible problem see ensuring memory consistency in issued loads/stores on object previous owner threads. the queue ensures thread safety creating lock_guard<...> on queue operations. wouldn't memory consistency of object being moved between threads guaranteed since memory fencing , synchronization taken care lock_guard ? part of me wants ensure passing thread-safe objects between threads, feel case there should no problem. true? the queue ensures thread safety creating lock_guard...

ios - cellForRowAtIndex is taking time to load cell from xib -

i have created custom uitableview class xib. in -cellforrowatindex following code written. the issue takes 2-3 sec push screen contains tableview . (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *simpletableidentifier = @"mycell"; customcell *cell = (customcell *)[tableview dequeuereusablecellwithidentifier:simpletableidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"customcell" owner:self options:nil]; cell = [nib objectatindex:0]; } cell.selectionstyle = uitableviewcellselectionstylenone; if(!indexpath.row) { uiview *separatorview = [[uiview alloc]initwithframe:cgrectmake(20,14, screenwidth-40, 1)]; separatorview.backgroundcolor = [uicolor colorwithwhite:0.4 alpha:0.6]; [cell addsubview:separatorview]; ...

PyQ5t: load Qt Designer into Python script (loadUiType): how to check error cause? -

i design gui in qt designer, load ui-file in puthon3 script loaduitype method: class main(qmainwindow, uic.loaduitype("adc_main_form.ui")[0]): def __init__(self): super(main, self).__init__() self.setupui(self) all works fine. make little revolution in form design , includes lot of renaming. take ui-file of qt designer (xml file) , edit in text editor. maybe make typo mistakes. message during start of python script, on line self.setupui(self): file "string", line 671, in setupui typeerror: argument 1 has unexpected type 'qradiobutton' so, goes wrong in process of importing xml file. error type tells me not enough find error. i double check qradiobutton widgets. no idea. i open ui designer - opens without error messages. i convert ui py (pyiuc5) - no errors. the .ui file here . what can way find error in such closed process setupui? in .ui file widgets have same name main window's slots. subclass main wind...

php - Page code stops executing after UNION sql query -

i'm still beginner in writing php code. couple of hours i'm trying write script takes results 2 database tables , displays results (in while loop)+ pagination. problem can not fix if there no result - script stops page executing , looks cut in half. this query: $query = "select phid photographers phcity=$row_cities[cityid] union select pservowner phservices pservowner = $row_prephotographer[phid] , pservservice=$row_service[serviceid] limit $redove, $broinastranica"; $query_params = array(); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(pdoexception $ex) { die(fusllpageerror("error","system error 103.")); } $row_photographers = $stmt->fetch(); if(!empty($row_photographers['phid'])) { { ... } while($row_photographers = $stmt->fetch()); else { echo ...

javascript - Get the last item from node list without using .length -

the following command document.queryselectorall('#divconfirm table')[1].queryselectorall('tr') gives node list 3 tablerow (tr) elements in it. if know list size, can access last element via .item(2) . is there way last element directly without resorting .length first? there's @ least 1 way var els = document.queryselectorall('#divconfirm table')[1].queryselectorall('tr'); var last = [].slice.call(els).pop(); but, following statement but if not know length prior running script makes no sense, have collection of elements, know length var els = document.queryselectorall('#divconfirm table')[1].queryselectorall('tr'); var last = els[els.length - 1]; another option document.queryselector('#divconfirm table:nth-child(2) tr:last-child');

php - Log all MySQL transactions on a per user basis -

i have php application uses single database multiple users. user log on, id stored in session, , use application retrieve or update data in database. for security/archival purposes, log every sql transaction on per user basis. note "user" not mysql user uses 1 user. how do this? i operating centos 5.8, php 5.3.18, , mysql 5.5. thanks $sql = "update table set col = ?" $db->prepare($sql); //some params etc... $filename = '/dir/logs/log-' . $_session['username'] . ''; $handle = fopen($filename, "wr"); $db->execute(); fwrite($handle, $sql); it's simple example, how use query either execution , writing in file, named user. well, used way maybe content of $sql before execution, think got idea. p.s.: thx edit :)

forms - PHP if statement not working as expected with filter_var -

i have form posts variables through php processing script. before processing script begins sanitize posted variables: $contact_name = filter_var($_post['contactname'], filter_sanitize_string); $company = filter_var($_post['company'], filter_sanitize_string); $telephone = filter_var($_post['telephone'],filter_sanitize_number_int); so far. good. but sanitizing , validating email real pain. $email = $_post['email']; $sanitised_email = filter_var($email, filter_sanitize_email); $email_is_valid = filter_var($email, filter_validate_email); if $sanitised_email isn't same $email , want go form page: if ($sanitised_email != $email) { header('location: http://'.$_server['http_host'].'/form.php'); } if $email_is_valid false , want go form page: if ($email_is_valid == false) { header('location: http://'.$_server['http_host'].'/form.php'); } neither of these 2 if statements work when enter...

xcode - Should I have used a CoreData predicate to populate my UITableview? -

i had old app rebuilt using coredata , swift 2. first go @ coredata, i'm sure i'm not doing efficient way possible. example, have 2 entities in coredata, person entity , statement entity. person entity has relationship of "to many" statement entity, statement entity has relationship of "to one" person entity. person object able have multiple statement objects. working , able add them coredata successfully. next have uiviewcontroller uitableview inside of it. have tableview's selection dropdown set multiple sections. have 2 sections assigned table view. when grab coredata entities place them array able use array , fill tableview. var persons: [person]! persons = try coredatastack.context.executefetchrequest(fetchrequest) as! [person] after (and think things simplier) break array 2 different arrays each section in table view has it's own data source. think use coredata nspredicate, after looking @ tutorial , reading couple of chapters of ...

c++ - Detecting instance method constexpr with SFINAE -

let me first start off noting similar question here: detecting constexpr sfinae . difference in question, detection method works detect static method of class. i trying detect if can constexpr copy constructed. i'm quite close, here's i've got: template <class t> constexpr int return_int(t t) { return 0; } template <class t> t& unmove(t&& t) { return t; } template <class ... t> using void_t = void; template <class t, class = void> struct is_constexpr_copy_constructible : std::false_type {}; template <class t> struct is_constexpr_copy_constructible<t, void_t< std::integral_constant<int, return_int(unmove(t{})) > >> : std::true_type {}; the logical progression of ideas in solution follows: only constant expression int...

asp.net mvc - Passing form values from one controller view to another form on a different controllers view in asp MVC -

okay i'm new mvc , trying make me webpage can transfer small form box zip code , button, quote page fill in zip code part on quote page. my problem have 2 controllers homecontroller has index view small form box. need pass zip code quotecontroller has it's own view populated new zip code. the home controller input, indexview @using (html.beginform("quote", "quote")) <p>move zip:</p> <input type="text" name="zip"/><br /> <input type="submit" value="next" name="next"> the quote form receive zip, on quote controller, on quote view @html.label("move zip ")<br /> @html.textboxfor(m => m.movefromzip, "", new { maxlength = 5, @class = "short-textbox" }) what's easiest way of doing this in index view of homecontroller, can keep form action "quote/quote" @using (html.beginform("quote",...

android - How to set TabLayout transparent keeping my icons and text white -

this first question here i´ve researched lot before. i´m new android development , trying design custom login/signing activity based on new viewpager , tablayouts. thing i´m trying set transparency background 2 tabs appbarlayout , can´t find works me. i´ve tried lots of posted solutions , no 1 seems fit case. last 1 posted here: how set tablayout background transparent but nothing, better can this: transparent background try here layout code gets this: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <imageview android:layout_width="match_parent" android:layout_height="200dp" android:id="@+id/imageview2...

c++ - Find out how this variadic templated function works -

in this answer have seen c++11 code, don't understand (but to). there, variadic template function defined, (maybe?) takes arguments passed , inserts them std::ostringstream . this function (see complete working example @ linked answer): template<typename t, typename... ts> std::string createstring(t const& t, ts const&... ts) { using expand = char[]; std::ostringstream oss; oss << std::boolalpha << t; (void)expand{'\0', (oss << ts, '\0')...}; return oss.str(); } when had guess, i'd say, character array created , initialized \0 -bytes, , insertion of function's arguments stream happens side effect of initialization (part of comma expression). in end, array contains many nulls items inserted stream. it's casted void in order avoid compiler warning (unused variable). similar this: char arr[] = {'\0', (oss << t1, '\0'), (oss << t2, '\0'), ..., (oss <...

javascript - findOne() doesn't work - is something wrong with my syntax? -

db creation: var mongojs = require('mongojs'); var db = mongojs('rodrigo-contatos', ['rodrigo-contatos']); i'm trying search in database code, using findone mongojs, code: app.get('/detalhescontato/:id', function(req, res){ var id = req.params.id; console.log(id); db.contatos.findone({_id: mongojs.objectid(id)}, function(err, doc) { console.log(err); res.json(doc); }); console.log(id) id correct findone not working no matter ;(. "567a16ba28dee028f4a8ad78 <-- console log id typeerror: cannot read property 'findone' of undefined @ /users/michel/documents/angularprojects/rodrigobranaslistatelefonica/server.js:48:12" with mongojs , need explicitly identify collections want access properties of db when call mongojs create db object. because you're trying access contatos collection, name needs provided mongojs call in second (array of strings) parameter: var db = mongojs('rodrigo-co...

java - Android HttpURLConnection POST not working -

i have problem parameters passed url post. when in php try retrieve them says $_post empty: <?php require_once 'credentials.php'; $connection = mysqli_connect(mysql_host, mysql_user, mysql_pass, mysql_database); $query = 'insert ratings (disco, rating) values (' .mysqli_real_escape_string($connection, $_post["disco"]). ', ' . mysqli_real_escape_string($connection, $_post["rating"]) . ')'; $result = mysqli_query($connection, $query); echo json_encode($result); mysqli_close($connection); ?> and android code looks this: @override protected string doinbackground(string... params) { string response = ""; try { url url = new url(params[0]); httpurlconnection urlconnection = (httpurlconnection)url.openconnection(); urlconnection.setconnecttimeout(10000); urlconnection.setreadtimeout(10000); ...

php - $.ajax POST not working but GET works fine -

been on while now. codes below works when " type: 'post' " changed " type: 'get' ". why not working post? $.ajax({ type: 'post', url: 'http://www.example.com/ajax/test.php', data: { name: "overcomer", email : "info@overcomer.we"}, cache: false, datatype: "html", beforesend: function() { console.log('firing ajax'); }, success: function (response) { console.log('success'); }, error: function (xhr, ajaxoptions, thrownerror) { console.log("error:" + xhr.responsetext+" - "+thrownerror); } }); whe change post on jquery, must change post in php. so, on php code change: $_get['name'] $_post['name'] , $_get['email'] $_post['email'] (related) $_get $_post if not working, post php code here.

c++ - Function removes too much -

i'm doing phone registry , in need able add, remove , show phones on stock. i've made possible add in phones whenever add let's 3 phones , remove second 1 both third , second phone deleted , don't understand why. this cellphonehandler.h file: #ifndef cellphonehandler_h #define cellphonehandler_h #include "cellphone.h" class cellphonehandler { private: cellphone **phone; int nrofphones; int priceofphone; int stockcapacity; int nrofphonesinarr; public: cellphonehandler(); ~cellphonehandler(); void addphone(string brand, int nrof, int price); bool removephonefromstock(string name, int nrof); int getnrofphones() const; int getnrofphonesinarr() const; int getprice() const; void getphonesasstring(string arr[], int nrof, int priceofphone) const; }; #endif // !cellphonehandler_h this cellphonehandler.cpp file. #include "cellphonehandler.h" cellphonehandler::cellphonehandler() { this->...

html5 - Progress bars with text on the leff - bootstrap -

my question is: how can progress bars loking thats below. i'm using bootstrap , have 2 columns 4/8. help. enter image description here you need customize theme default bootstrap, may can section. http://getbootstrap.com/customize/ after download custom theme , redefined

android - How can I get image name? -

i have button , imageview, when click button, there seems 1 of random image in imageview. it's names appear in textview... imageview img=(imageview)findviewbyid(r.id.logolar); random rand = new random(); int rndint = rand.nextint(5) + 1; string drawablename = "image"+ rndint; int resid = getresources().getidentifier(drawablename, "drawable", getpackagename()); img.setimageresource(resid); textview logoismi = (textview)findviewbyid(r.id.logoismi); logoismi.settext(lastimagename); clickeddata.add(logoismi.gettext().tostring()); lastimagename = drawablename; but code, images names must be; image1 , image2 , image3 ... don't wanna it. images have different names. can different images names code; final class drawableclass = r.drawable.class; final field[] fields = drawableclass.getfields(); final random rand = new random(); int rndint = rand.nextint(fields.length); tr...

glibc posix_memalign allocation overhead -

i trying understand memory overhead associated posix_memalign - in other words, if posix_memalign relies on boundary tagging , how big such tagging is. so wrote following (very simple) program (linux x86_64 platform, "gcc -m64"): #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) { int i; void* prev; void* memp; int align = atoi(argv[1]); int alloc = atoi(argv[2]); (i = 0; < 5; ++i) { if (posix_memalign(&memp, align, alloc)) { fprintf(stderr, "allocation failed\n"); return 1; } if (i == 0) printf("allocated %d bytes @ 0x%08x\n", alloc, memp); else printf("allocated %d bytes @ 0x%08x (offset: %d)\n", alloc, memp, (int)(memp-prev)); prev = memp; } return 0; } however, result baffle me... $ /tmp/test 8 1 allocated 1 bytes @ 0x0133a010 alloc...