Posts

Showing posts from February, 2014

java - Extending a class in the method signature -

can explain does? generics question since i'm learning in java tagged java. public static <t extends comparable<? super t>> void quicksort(t[] list) {...} what don't understand part: <t extends comparable<? super t>> i have tried looking @ this doesn't seem explain in clear way. my guess is: genetic type t extends comparable interface requires generic type superclass of generic type. don't understand this. example: public class x implements comparable<x> { } the class x implements comparable satisfies extends comparable , generic parameter of comparable x because x super x ( java generics super keyword ) another example: public class y {} public class x extends y implements comparable<y> { } another example: public class x implements comparable<object> { } but won't work: public class {} public class x implements comparable<a> { } as class x comparable objects not in i

Using the Counter function on a list in python -

we have return frequency of length of words in .txt file. e.g "my name emily" converted list: ["my", "name", "is", "emily"] , converted list of lengths of each word: [2, 4, 2, 5] , use function counter outputs dictionary looks like: counter({2: 2, 4: 1, 5: 1}) but need include count of zero: counter({1: 0, 2: 2, 3: 0, 4: 1, 5: 1}) any ideas? should rid of counter function together? counter counts frequency of items, means keeps count of items present. but, if item looking not there in counter object, return 0 default. for example, print counter()[1] # 0 if need items 0 count in it, can create normal dictionary out of counter, this c = counter({2: 2, 4: 1, 5: 1}) print {num:c[num] num in xrange(1, max(c) + 1)} # {1: 0, 2: 2, 3: 0, 4: 1, 5: 1}

qt - Using a Loader for a string of QML -

in qt 5.3 i've been using loader qml element loading screens, loading view qml file in background. i'm trying load string of qml dynamically. qt.createqmlobject enables me so, can't seem loader element play along. seems loader takes url ( qurl ) or component ( qqmlcomponent ), qt.createqmlobject creates object ( qobject ). i'm new qml, understanding components reusable elements, similar classes, , objects instances of classes. can't seem wrap head around why loader wouldn't work objects. how can show loading screen while (asynchronously) parsing , initializing string of qml? example qml code: item { rectangle {id: content} loader {id: loader} component.oncompleted: { var obj = qt.createqmlobject('import qtquick 2.3; rectangle {}', content); loader.source = obj; // throws error. } } it's not possible using current api. loader's documentation says, loads objects via url points qml fil

Brew install git putting files in .rvm -

after running brew install git , got output: the os x keychain credential helper has been installed to: ~/.rvm/bin/git-credential-osxkeychain 'contrib' directory has been installed to: ~/.rvm/share/git-core/contrib bash completion has been installed to: ~/.rvm/etc/bash_completion.d zsh completion has been installed to: ~/.rvm/share/zsh/site-functions ==> summary 🍺 ~/.homebrew/cellar/git/2.0.0: 1324 files, 31m, built in 46 seconds is expected? why should brew or git putting under rvm (ruby version manager)? as @mblanc pointed out, $ brew --prefix ~/.rvm

regex - Regular Expression for Pakistan's mobile number -

i want regular expression mobile number start '+92' or '0' , user type onlye ten digits more. did basic google search “regex pakistan mobile”? here solution first result: ^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$

Confused by Return in Array Recursion (java) -

given array of ints, possible divide ints 2 groups, sums of 2 groups same. every int must in 1 group or other. write recursive helper method takes whatever arguments like, , make initial call recursive helper splitarray(). (no loops needed.) this problem coding bat trying figure out. got stuck found solution confused purpose of 1 line , confused final return statement doing. help! public boolean splitarray(int[] nums) { return splitarrayhelper(nums, 0, new int[nums.length], 0, 0, new int[nums.length], 0, 0); } private boolean splitarrayhelper(int[] nums, int n, int[] split1, int s1, int t1, int[] split2, int s2, int t2) { if (n == nums.length) return t1 == t2; //returns true or false split2[s2] = split1[s1] = nums[n]; // purpose of line? return splitarrayhelper(nums, n + 1, split1, s1 + 1, t1 + nums[n], split2, s2, t2) || splitarrayhelper(nums, n + 1, split1, s1, t1, split2, s2 + 1, t2 + nums[n]); } //i don't know return statement doing. how or statement decide

sql - python - create table and insert data from csv -

i have numerous different .csv files structured - "company", "column2", "column3" "abc corp", "john doe", "212,345" "dbe ltd", "victor smith", "234,345" i understand how write these csv files table, want write these new table may not know columns need dynamically scan .csv file column names first row create table portion.

Bootstrap - fill a row with fixed size divs -

please see code here i have div.row , number of red divs inside row, these red divs fixed size. want align red divs that: it fills many red divs possible in row either divs centered in row, or div margin calculated fill whole row width. there can unused space on right hand side. how do that? first of all, bootstrap row can contain 12 columns, or columns of various widths or offsets adding 12. so, can have 6 col-xs-2 in 1 row, or 12 col-xs-1 , or 3 col-xs-4 , etc. there many ways customize , expand on this, such nested columns. take @ bootstrap grid system . if want content centered on page, surround div class container . if want divs automatically adjust widths, need remove width: 100px; css. here's fiddle .

php - retrieving and echoing multiple values from mysql column -

Image
i have created these 3 columns in mysql table can have list of each users transactions. ticket_date, ticket_num, ticket_result i created function echo value in columns , worked successfully. function.php: $sql = "select * members user_id = '{$_session['user_id']}'"; $query = $this->db_connection->query($sql); while ($row = $query->fetch_object()) { global $me, $me2, $date; $me = $row->ticket_num; $me2 = $row->ticket_result; $date = $row->ticket_date; } transactions.php <table class="table"> <thead> <th>date</th> <th>ticket id</th> <th>result</th> </thead> <tr> <td><?php echo $date; ?> </td> <td><?php echo $me; ?> </td> <td><?php echo $me2; ?> </td> </tr> </table> my problem if user has mor

php - Reload current page and upload a persistent variable in Phalcon -

all view in current project extend general index view looks this: <!doctype html> <html> <head> <title>title</title> </head> {{ stylesheet_link("css/base.css") }} {{ stylesheet_link("css/layout.css") }} {{ stylesheet_link("css/skeleton.css") }} {{ stylesheet_link("css/main.css") }} {{ stylesheet }} <body> <div class="container"> <div class="one columns"> <!-- here nav-bar --> </div> <div class="sixteen columns"> <hr /> </div> <div class="one column offset-by-thirteen"><a href="#">{{ english }}</a></div> <div class="one column"><a href="#">{{ french }}</a></div> <div class="

How to alphabetically sort 2D array based on an element, without using the built-in sort function? (python) -

i've been stuck on while, 1 please me? suppose have array: [[231,cow,234334,2231319,323242],[3,alien,2,2312,3212],[9,box,234,2319,3242]] can me create sort function sorts array alphabetically based on 2nd element of each individual array in larger array, looks like: [[3,alien,2,2312,3212],[9,box,234,2319,3242],[231,cow,234334,2231319,323242]] here simple bubble sort 1 of easiest sorts understand (since looks homework.) key, think, instructor trying think 2d aspect, here means need @ second element of second column in compare. have modified compare this. tested , need put quotes around elements strings. def bubblesort( ): in range( len( ) ): k in range( len( ) - 1, i, -1 ): if ( a[k][1] < a[k - 1][1] ): swap( a, k, k - 1 ) def swap( a, x, y ): tmp = a[x] a[x] = a[y] a[y] = tmp a=[[231,'cow',234334,2231319,323242],[3,'alien',2,2312,3212],[9,'box',234,2319,3242]] print bub

Python argparse: Mutually exclusive required group with a required option -

i trying have required mutually exclusive group 1 required parameter. below code have put #!/usr/bin/python import argparse import sys # check option provided part of arguments def parseargv(): parser = argparse.argumentparser() group = parser.add_mutually_exclusive_group() group.add_argument("-v", "--verbose", choices=[1,2,3,4], = "increase verbosity") group.add_argument("-q", "--quiet", action="store_true", = "run quietly") name = parser.add_mutually_exclusive_group(required=true) name.add_argument("-n", "--name", = "name of virtual machine") name.add_argument("-t", "--template", = "name of template use \ creating vm. if path not provided looked \ under template directory.") parser.add_argument("-s", "--save", = "save machine template. if \ path

Using PHP value in javascript - working in alert() but not getelementbyid -

i using this: $newpostid_fromcookie = $_cookie['scrolltobottom']+5000; echo " <script> window.onload = function () { //document.getelementbyid('$newpostid_fromcookie').scrollintoview(); alert('$newpostid_fromcookie'); } </script> "; this correctly shows value cookie in alert, getting 'is null' error when trying use value in getelementbyid. how can use value in this? your $newpostid_fromcookie seems integer. in xhtml, not valid , maybe browser not it. should use string (with prefix example): document.getelementbyid('cookie_$newpostid_fromcookie').scrollintoview(); of course, change html in consequence.

Evaluation of APL direct functions -

here snippet testing recently. takes 2 diameters ( ⍺,⍵ ) , computes circumference of circle: 10{(○1×⍺){⍺ ⍵}○1×⍵}10 ⍝ note brackets around ⍺ 31.4159 31.4159 10{○1×⍺{⍺ ⍵}○1×⍵}10 31.4159 98.696 i understand how evaluation of expression works - why first 1 evaluating correctly , second 1 isn't? i using dyalog apl. you have nested functions. in both cases, inner function returns right , left argument. in first case, left argument inner function expression (○ 1×⍺), in second case left argument inner function ⍺, or unaltered left argument of outer function -- entire result of inner function multiplied ○ , 1. note argument circle function right 1 x totally redundant. in apl, expressions evaluated right left. can function applies right unless modified parens. therefore in first expression ○ takes 1 multiplied right ⍺ due parentheses. in second expression ○ takes 1 multiplied right result of inner function. furthermore, note due scalar extension, can compute 2 n

r - Does the varIdent function, used in LME work fine? -

i glad if me solve problem. have data repeated measurements design, tested reaction of birds ( time.dep ) before , after infection ( exper ). have fl (fuel loads, % of lean body mass), fat score , group (experimental vs control) explanatory variables. decided use lme , because distribution of residuals doesn’t deviate normality. there problem homogeneity of residuals. variances of groups “before” , “after” , between fat levels differ (fligner-killeen test, p=0.038 , p=0.01 respectively). ring group fat time.dep fl exper 1 xz13125 e 4 0.36 16.295 before 2 xz13125 e 3 0.32 12.547 after 3 xz13126 e 3 0.28 7.721 before 4 xz13127 c 3 0.32 9.157 before 5 xz13127 c 3 0.40 -1.902 after 6 xz13129 c 4 0.40 10.382 before after have selected random part of model, random-intercept ( ~1|ring ), have applied weight parameter both “fat” , “exper” ( varcomb(varident(form=~1|fat), varident(form=~1|exper) ). plot of stand

mysql - Error executing UPDATE -

i'm having little trouble performing update query node mysql2 module. i'm preparing query using '?' placeholder , passing in values so; socket.on('connection', function(client){ [...] client.on('userjoin', function(username, userid){ run_db_insert("update users_table set clientid = ? user = ?", [client.id, userid], function(){ console.log(client.id + ' <=> ' + userid); }); [...] }); unfortunately, raising error; you have error in sql syntax; check manual corresponds mysql server version right syntax use near ''12345678' userid = ?' @ line 1 the data isn't reflected in database. reason, code doesn't appear picking second question mark placeholder , it's not passing correct value (i.e. it's trying find userid of ? ). if change code this; run_db_insert("update users_table set clientid = ? user = '" + userid + "'", [clie

javascript - AnulgarJS - Object parameters in service not changing -

i'm having troubles services in angular. basically have service use constant class user specific parameters, store these in variables read values cookie. this service: shoutapp.service('userconfig', function (userservice, config) { this.user_id = $.cookie('shoutuserobj')._id; this.user_username = $.cookie('shoutuserobj').username; this.user_password = $.cookie('shoutuserobj').password; this.user_joindate = $.cookie('shoutuserobj').joindate; this.user_twitter = $.cookie('shoutuserobj').twitter; this.user_facebook = $.cookie('shoutuserobj').facebook; this.user_google = $.cookie('shoutuserobj').google; this.refreshuserobj = function (callback) { console.log("starting refresh"); //this function retrieves new user data userservice.requestuserobj($.cookie('shoutuserobj')._id, function (code, userobj) { if (code === config.code_ajax_success) { //here delete old cook

c# - See my packet details via Wireshark as byte instead of hex -

i want build dhcp packet , in build process params user example agent circuit id (string) - attribute number 82. after build packet send packet , see result via wireshark problem when see packet see agent circuit id value hex , want see value byte example: string agentcircuitid = "33445566778899"; i want field 2 bytes 33 44 55 66 77 88 99 in result try string "1234" , result 31 32 33 34 http://s27.postimg.org/bdhe9j4hv/123.png any idea how ?

c# - extract text content from web page using asp.net web form -

Image
i'm trying load page may asp.net web form , extract text , display extracted text in areatext like this: and code is: <%@ page language="c#" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default" %> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> #form1 { height: 500px; width: 1199px; } .auto-style1 {} #textarea1 { height: 288px; width: 1157px; } </style> </head> <body> <form id="form1" runat="server"> <asp:button id="button1" runat="server" text="clike me" onclick="button1_click" onclientclick="aspnetform.target ='_blank';"

android - cannot resolve symbol FileProvider -

i trying test fileprovider tutorial . it asks include in manifest : <provider android:name="android.support.v4.content.fileprovider" android:authorities="com.mydomain.fileprovider" android:exported="false" android:granturipermissions="true"> </provider> in manifest, error: cannot resolve symbol fileprovider i followed these instructions , add v4 support library android studio. add following build.gradle file, gradle sync fails : compile "com.android.support:support-v4:18.0.+" what must resolve problem ? go file > invalidate caches / restart , invalidate , restart.

wpf - How to update observable collection on property change and also store it on every change? -

i have dynamic listbox contains textbox display list items , can edit listbox item. application setting file contains string collection want bind listbox. want update setting files on every change of listbox item, created class implements inotifyproprtychanged. have converted string collection settings file observable collection of custom type has string property. bind textbox property of custom class , update source property on property change. want update observable collection well. , updates app setting file well. please me on this. appreciated. code: public class windowviewmodel : inotifypropertychanged { private observablecollection<urlmodel> customcollection; public observablecollection<urlmodel> customcollection { { return customcollection; } set { customcollection = value; notifypropertychanged("customcollection"); } } public event propertychangedeventhandler propertychan

64bit - Program in x64 assembly modifying array passed from a C++ procedure in Linux does not work, though analogous solution worked for x86 -

i wrote program in x64 assembly replace string's lower-case letters stars. assembly procedure called c++ program , receives array of chars. similar logic applied x86 worked (the difference being registers used etc.), string remains unaltered when built x64. use debian linux , nasm . section .text global func func: push rbp mov rbp, rsp ; zadanie jako takie mov rax, qword [rbp+8] loop: cmp byte [rax], 97 jl increment cmp byte [rax], 122 jg increment mov byte [rax], 42 increment: add rax, 1 cmp byte [rax], 0 jne loop exit: mov rax, 0 ;return 0 mov rsp, rbp pop rbp ret it called following c++ program: #include <stdio.h> #define length 1024 extern "c" int func(char *a); int main(void) { int result; char text[length]; printf( "write string\n" ); fgets( text, length -1, stdin ); printf("string: %s\n", tex

java - HibernateUtil is working on GlassFish but not with Tomcat -

when run java web app using hibernate in netbeans glassfish works great, when run same java web app tomcat server start receive message: "java.lang.noclassdeffounderror: not initialize class mypackage.hibernateutil" any reason why? it appears following libraries needed tomcat, not glassfish: slfj4-api slfj4-simple persistance jpa2.0

java - codility challenge, test case OK , Evaluation report Wrong Answer -

the aluminium 2014 gives me wrong answer [3 , 9 , -6 , 7 ,-3 , 9 , -6 , -10] got 25 expected 28 but when repeated challenge same code , make case test gives me correct answer your test case [3, 9, -6, 7, -3, 9, -6, -10] : no runtime errors (returned value: 28) what wrong ??? the challenge :- a non-empty zero-indexed array consisting of n integers given. pair of integers (p, q), such 0 ≤ p ≤ q < n, called slice of array a. sum of slice (p, q) total of a[p] + a[p+1] + ... + a[q]. maximum sum maximum sum of slice of a. example, consider array such that: a[0] = 3 a[1] = 2 a[2] = -6 a[3] = 3 a[4] = 1 example (0, 1) slice of has sum a[0] + a[1] = 5. maximum sum of a. can perform single swap operation in array a. operation takes 2 indices , j, such 0 ≤ ≤ j < n, , exchanges values of a[i] , a[j]. goal find maximum sum can achieve after performing single swap. example, after swapping elements 2 , 4, following array a: a[0] = 3

ios - Supporting multiple orientations on a single view controller -

i trying pretty simple thing: support horizontal orientation in app, except 1 stack of view controllers. simplicity, lets have 2 uiviewcontrollers. lets call them masklandscapevc , maskallvc. each separately embedded in own instance of custom uinavigationcontroller. here code navigation controller. #import "mptloginnav.h" @interface mptloginnav () @end @implementation mptloginnav - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } #pragma mark #pragma interface orientaiton methods - (nsuinteger)supportedinterfaceorientations { if (self.ismaskallstack) return uiinterfaceori

java - How to get element's value from XML using SAX parser in startElement? -

is possible content of element xml file in startelement function override function of sax handler? below specification. 1) xml file <employees> <employee id="111"> <firstname>rakesh</firstname> <lastname>mishra</lastname> <location>bangalore</location> </employee> <employee id="112"> <firstname>john</firstname> <lastname>davis</lastname> <location>chennai</location> </employee> <employee id="113"> <firstname>rajesh</firstname> <lastname>sharma</lastname> <location>pune</location> </employee> </employees> 2) startelement function @override public void startelement(string uri, string localname, string qname, attributes attributes) throws saxexception { .......code in here.......... } 3) expected result element

sql server - Which to Prefer IN vs Join vs Equals in SQL? -

Image
i want manufacturer tbl_manufacturer. wrote 3 different queries manufacturers of item tbl_sales_orderitems table. want know 1 prefer. let me know query should used on other , why? query 1: using subquery select manufacturer tbl_manufacturers manufacturerid in(select trc.manufacturerid tbl_sales_repaircategory trc trc.repaircategoryid in (select repaircategoryid tbl_vendorparts vendorpartid in (select refid tbl_sales_orderitems typeid = 2 , salesorderid = 182))) query 2: using sub-query distinct select distinct manufacturer tbl_manufacturers m, tbl

java - List of timestamps overrides the previous timestamp -

i using arraylist store list of timestamps of past 5 weeks. i.e., if today 2014-06-09, want store 2014-06-02 2014-05-26 2014-05-19 2014-05-12 2014-05-05 here code. public class test { public static void main(string ap[]) throws interruptedexception{ list<timestamp> ts = new arraylist<timestamp>(); timestamp t = new timestamp(new java.util.date().gettime()); timestamp temp = null; for(int i=0;i<5;i++){ t.settime(t.gettime()-(7*24 * (long)60* (long)60) * (long)1000); temp = t; system.out.println(t); ts.add(temp); temp = null; } } } but problem getting list of overrided values i.e., list contains elements last timestampi i.e 2014-05-05) can reply question? the reason you're not getting "new" timestamps because keep overriding same 1 , adding list - end same object entered 5 times list , last value display in "all" items. don't need temp - create new timestamp object

ios - UISearchControllerDelegate - Search bar not visible in table header -

my uitableviewcontroller conforming new uisearchcontrollerdelegate , uisearchresultsupdating . here setup code search bar: override func viewdidload() { var searchcontroller = uisearchcontroller(searchresultscontroller: self) searchcontroller.searchresultsupdater = self self.tableview.tableheaderview = searchcontroller.searchbar self.definespresentationcontext = true } however, when running in simulator there no search bar in table header, though specified in code. tried code in viewwillappear , again no search bar shown. i informed apple engineer must give search bar frame. if print frame of search bar, notice it's height zero. bug in apple's code. searchcontroller.searchbar = cgrectmake(0.0, 0.0, 320.0, 44.0) edit: the documentation specifies must pass in view controller want display results. display in same view controller in, pass in nil. var searchcontroller = uisearchcontroller(searchresultscontroller: nil)

angularjs - angularui bootstrap dropup not working -

i need use dropup menu. code worked ui-bootstrap-tpls-0.10.0.js: <div class="btn-group dropup"> <button type="button" class="btn btn-default" ng-click="print('pdf')">{{text}}</button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> <span class="sr-only">toggle dropdown</span> </button> <ul class="dropdown-menu" role="menu"> <li><a ng-click="print('pdf')">pdf</a></li> <li><a ng-click="print('excel')">excel</a></li> </ul> </div> after upgrading ui-bootstrap-tpls-0.11.0.js, dropup popup doesn't show anymore. appreciated. dropdown still works expected. add dropdown attribute outer d

c# - How do you make an MVC Webgrid show multiple lines in a cell? -

i have function in code generates string a\nb\nc , when pulled webgrid, use function on razor side change \n <br /> , , know works because in webpage source shows string on 3 separate lines. @functions { public static string replacelinebreaks(string s) { return s.replace(environment.newline, "@html.raw(<br />)"); } } <div id="grid_mywebgrid"> @grid.gethtml( tablestyle : "table", alternatingrowstyle : "alternate", headerstyle : "header", columns: grid.columns( grid.column("letters", format: item => @html.raw(replacelinebreaks(html.encode(item.letters)))), ) ) </div> but when load page, cell column shows: abc instead of: a b c is there in webgrid lets tell that column used multi-line cell? i found called @helper can use design razor inline templates. using @helper , wrote foreach s

database - MySQL Workbench 1146 error with table alias -

i have code of mysql in workbench 1. select `ΟΝΟΜΑΣΙΑ_ΠΡΟΪΟΝΤΟΣ`, `ΠΩΛΗΣΗ` 2. from(select `ΟΝΟΜΑΣΙΑ_ΠΡΟΪΟΝΤΟΣ`, sum(`ΠΟΣΟΤΗΤΑ`) `ΠΩΛΗΣΕΙΣ` 3. `hospital`.`προιοντα`, `hospital`.`χρεωσεις_περιστατικων` 4. `hospital`.`προιοντα`.`ΚΩΔΙΚΟΣ_ΠΡΟΪΟΝΤΟΣ` = `hospital`.`χρεωσεις_περιστατικων`.`ΚΩΔΙΚΟΣ_ΠΡΟΪΟΝΤΟΣ` , year(`ΗΜ_ΝΙΑ_ΧΡΕΩΣΗΣ`) = 2013 5. group `ΟΝΟΜΑΣΙΑ_ΠΡΟΪΟΝΤΟΣ`) `Π` 6. `ΠΩΛΗΣΗ` = (select max(`ΠΩΛΗΣΕΙΣ`) `Π`.`ΠΩΛΗΣΕΙΣ`); the problem exists in line 6. mysql workbench doesn't recognize table alias "Π", throws me error: error code: 1146. table 'π.πωλησεισ' doesn't exist. what can do? that's because Π derived table , not permanent table , can't use in where clause normal table. rather include max() calculation in outer query. change query below select `ΟΝΟΜΑΣΙΑ_ΠΡΟΪΟΝΤΟΣ`, `ΠΩΛΗΣΗ` ( select `ΟΝΟΜΑΣΙΑ_ΠΡΟΪΟΝΤΟΣ`, `ΠΩΛΗΣΗ`, sum(`ΠΟΣΟΤΗΤΑ`) `ΠΩΛΗΣΕΙΣ` `hospital`.`προιοντα`, `hospital`.`χρεωσεις_περιστατ

ios - AVAssetExportSession working in background -

Image
i tried manage avassetexportsession working when app in background. have ios 6 device , testing there. m making audio mix , trying export audio. when app in foreground m making ok, if m going background m getting avassetexportsessionstatusfailed , have create beginning. so, ever possible make audio mixing work in background? i m trying make [exportsession exportasynchronouslywithcompletionhandler: ] in nsoperationqueue or getting global queue - results same - stops when app going in background , sending failed afterwards. does have example avassetexportsession working in background? i have found solution works audio, have not tried video if update "background modes" setting in capabilities of project include audio. allow export. this intended playing music in background. ---- edit --- this works video

css - There is any way to add classes to bootstrap_django form_fields? -

https://github.com/dyve/django-bootstrap3 much. by way i'll need add classes customize ui , add behaviors class based. i'll template side. i use that: {% bootstrap_form form_field fixthis %} but can't understand if: - project it's young, haven't feature - feature usable, i'm not able - general skill problem of mine on django: wrong approach problem here docs: http://django-bootstrap3.readthedocs.org/en/latest/templatetags.html#bootstrap-field edit: trick, still using django_bootstrap. way in form.py file. approach right or should keep trying move logic in template? class authorform(forms.modelform): class meta: model = author fields = ['code','name','birthdate',] widgets = { 'birthdate': forms.textinput(attrs={'class': 'datepicker'}), } use classes in form, following: 'email': textinput(attrs={ 'class': 'form-control&#

c++ - Pointers and enum in C -

i'm trying rewrite c++ code c , got problems comparising enum pointers. please take look. enum: enum state{title,play,lost} my function looks that: void changestate(int *state, int newstate) { state = newstate; if (state == title) { /* */ } else if (state == play) { /* something2 */ } else if (state == lost) { /* something3 */ } } and when try calling function by: changestate(&state, title) etc. doesn't work correctly. when put in code: if (state == title) { /* instructions */ } what mistake? advance time. you need dereference pointer (use *state ) read value points to this means code should change to void changestate(int *state, int newstate) { *state = newstate; if (*state == title) { /* */ } else if (*state == play) { /* something2 */ } else if (*state == lost) { /* something3 */ } }

visual c++ - Using fopen_s in C -

i have problem programming in c, fopen in visual studio. read fopen_s function , added following line project, still doesn't work. _crt_secure_no_warnings so tried using fopen_s in way: file *fp; errno_t err; if ((err = fopen_s(&fp, "c:/file.txt", "rt")) != 0) printf("file not opened\n"); else fprintf(fp, "date: %s, time: %s, score: %i \n", __date__, __time__, score); fclose(fp); it's still crashing. what's wrong? you use fclose invalid fp value, if opening failed. add {} around else branch, @ least. many developers think idea use braces everywhere, 1 statement inside them. it's easy make mistake if don't, experienced developers. put them around then branch too.

bash - Find all substrings counts in a string -

i running command returns large string. returned string looks "foofoofoofoo verification completed: 6 reported messages. foo foo foo verification completed: 0 reported messages.foofoofoofoofoofoofoo verification completed: 2 reported messages. foo foo foo" i looking parse output , total sum of values returned after "verification completed:", in case 8. note: foo output & verification completed # reported messages can occur numerous times in string output. i looking @ using awk/grep this. suggestions? not huge unix/bash guy. using gnu awk: awk '$1~/^[0-9]+$/{s+=$1} end{print s}' rs='verification completed:' file 8 edit: on provided input: awk '$1~/^[0-9]+$/{s+=$1} end{print s}' rs='verification completed: ' file 54

database - VFP Grid + SQL server 2008 - grid not showing correctly -

i having problem, have grid called "gridbasica" , this: thisform.gridbase.recordsource = "sgviemp" sgviemp cursor made executing select sqlserver command sqlexec. when want modify registry, go form , the update there. so, when come form grid, grid isnt grid anymore, big white rectangle. reading around said: delete recordsource , asingt again. thisform.gridbase.recordsource = "" *--i sqlexe here thisform.gridbase.recordsource = "sgviemp" i , works, but, when click button modify again cursos updated modify form doesnt load fields did first time. could me out that? thanks in advance. --------------- edit ------------------ i have been doing recommended: lnselect = select(0) n = sqlexec(thisform.conexion,"select emp_ccodigo codigo, emp_cnombre 'nombre o razon social', emp_cnumrif 'r.i.f' sgviempr","sgviemp1") set echo on suspend select sgviemp zap in sgviemp *-- browse *--zaps correct

wordpress - Security header is not valid - WP E-commerce -

i using wp e-commerce (version 3.8.14.1) , wordpress (wordpress 3.9.1) following site: https://www.westernblotservice.com/ payments set though paypal payments standard 2.0 , paypal pro 2.0. standard works flawlessly, there problem paypal pro. after item added cart , credit card information inserted, following error "security header not valid". i triple checked information (api username, password, signature), made sure there aren't characters, deleted , issued new api username, password, signature, nothing seems help. sandbox mode isn't checked in wp e-commerce. pretty sure using live api information paypal account (from profile/selling tools). called paypal , verified set correctly. told me it's error on plug-in's side. i created test product $0.01, can added cart here: https://www.westernblotservice.com/test-2/ clicking order should take shopping cart page erorr occurs. any appreciated! this error indicates in cases api credentials

c# - Does it make any practical difference to instantiate an object inside the constructor? -

this question has answer here: what difference between instantiation in constructor or in field definition? 5 answers initialize class fields in constructor or @ declaration? 13 answers is there practical difference between 2 ways of instantiating object? public class myclass { private mytype myobject = new mytype(); } and public class myclass { private mytype myobject; public myclass() { myobject = new mytype(); } } thanks helping. no there isn't practical difference, between 2 ways provided. exaclty same.

javascript - How to change the css attribute of #header using jQuery and an array of images? -

i trying edit script changes images of div shown below, change background-image property of #header. as can see in fiddle here, http://jsfiddle.net/hskpq/460/ trying show images $('#header').css('background-image',..................).fadeto('slow',1); how can this? guess have change other parts too.. var img = 0; var imgs = [ 'http://www.istockphoto.com/file_thumbview_approve/9958532/2/istockphoto_9958532-sun-and-clouds.jpg', 'http://www.istockphoto.com/file_thumbview_approve/4629609/2/istockphoto_4629609-green-field.jpg', 'http://www.istockphoto.com/file_thumbview_approve/9712604/2/istockphoto_9712604-spring-sunset.jpg' ]; // preload images $.each(imgs,function(i,e){var i=new image();i.src=e;}); // populate image first entry $('img').attr('src',imgs[0]); var opacity = 0.1; // change minimum opacity function changebg() { $('img').fadeto('slow',opacity,function(){ $('

jquery - knockout is not working under document.ready -

i working on knockout , having issues. below .js code , ko.applybindings(viewmodel); way down under document.ready , not working @ all. works when add ko.applybindings(viewmodel); in side method $('#dttable tbody').on('click', 'tr', function (). please suggest issue if place code inside data table row click, once click on 2nd time other row or same row error comes "we can not define binding multiple times". please tell me issue in code , 2nd should put apply bindings /// <reference path="knockout-3.1.0.debug.js" /> $(document).ready(function () { var viewmodel = new function () { this.firstname = ko.observable(); this.lastname = ko.observable(); }; $('#dtable').datatable({ "scrolly": 300, "scrollcollapse": true, "jqueryui": true }); var selectedrow; $('#dtable tbody').on('cli

jquery - Easy responsive tabs custom tab activate -

i'm using easy responsive tab link .. here 1st tab active on page load.. want change active tab else other 1st tab.. have following code: html : <div id="demotab"> <ul class="resp-tabs-list"> <li> .... </li> <li> .... </li> <li> .... </li> </ul> <div class="resp-tabs-container"> <div> ....... </div> <div> ....... </div> <div> ....... </div> </div> </div> here demo page. want change order of activated 2nd tab. posiible? you can dynamically this <ul class="resp-tabs-list"> <li><a href="#tab1">responsive tab-1</a></li> <li><a href="#tab2">responsive tab-2</a></li>

objective c - Finding keys/Values from nested NSDictionary -

i have file located @ /users/admin/desktop/wi-fi.txt, contains follows... wi-fi: software versions: corewlan: 4.3.2 (432.47) corewlankit: 3.3.2 (332.36) menu extra: 9.3.2 (932.35) system information: 9.0 (900.8) io80211 family: 6.3 (630.35) diagnostics: 3.0 (300.40) airport utility: 6.3.2 (632.3) interfaces: en1: card type: airport extreme (0x14e4, 0x10e) firmware version: broadcom bcm43xx 1.0 (5.106.98.100.22) mac address: a8:86:dd:a9:6d:13 locale: apac country code: in supported phy modes: 802.11 a/b/g/n supported channels: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165 wake on wireless: supported airdrop: supported status: connected current network information: ddl2: phy mode: 802.11n bssid: c8:d7:19:62:1e:46 channel: 6 country code: in network type: inf

c - Why does fork() and printf() output more than I predict? -

this little program: #include <unistd.h> #include <stdio.h> int main() { printf("1"); fork(); printf("2"); fork(); return 0; } the output of code 12121212 , ask: why print more 122 ? because printf buffered , text printed when program exits. try flush stdout after each print.

android - Can i use search view for API level 8 -

i trying use search view in application showed error i.e view require api level 11(current minimum 8). there method through can use search view keeping min api level 8 only? if there provide small code snippet. as can see in documentation , searchview added in api level 11. if want use below that, use support library: https://developer.android.com/reference/android/support/v7/widget/searchview.html see this post .

ruby on rails - id nil when select model without no relation -

i have model no relation. class gridconfig < activerecord::base end my question why result of query appended id:nil columns? gridconfig.select(:fontsize) result is #<gridconfig id: nil, fontsize: "12px"> is there options this? thank you. i want find records , pick columns. , send client. user_key = params[:user_key] grid_id = params[:grid_id] @config = gridconfig.where(['user_key = ? , grid_id = ?', user_key, grid_id]) .select(:model_id, :fontsize, :displaycount, :columnmodel) # checked @config variables @ point , found nil:id... @config = @config.index_by(&:model_id) # , want makes indexed model_id [{"model":{...}},{"model2" : {...}}, {}] respond_to |format| format.json { render json: @config } end you can use pluck method select columns array, index first column. @config = gridconfig.where(user_key: params[:user_key], grid_id: params[:grid_id]) .pluck(:model_id, :fontsize, :display

javascript - Insert text before submitting HTML button -

i have button calls ajax once submit need add input have enter text , if text same text found in db button should execute ajax. how can done? this ajax code: <script> jquery(function(){ jquery(".canjear").click(function(e){ if(this.tagname==="a"){ e.preventdefault(); } jquery.ajax({ url: "index.php?option=com_cuphoneo&task=miscuponess.canjearcupon", type: "post", data: {id:jquery(this).data("id")}, success: window.location.href = "index.php?option=com_cuphoneo&view=miscuponess&layout=default" }); }); }); </script> this php/html button: <div class="panel-boton-canjear"> <?php foreach($campos_extra $value){ if($value->id == 17){ if(!empty($value->value)){ ?>

ios - Will Metal work on non A7 devices? (for example iPhone 5 or iPad Mini (not retina)) -

will metal work on non a7 devices? (for example iphone 5 or ipad mini (not retina)). if not, way create application metal supported devices only? it a7 or greater. wwdc videos "designed a7" , kept emphasizing throughout presentations.

ruby on rails - Prepros - C:bignum to big to convert into `long' -

i launch prepros application compile scss in css. error appear : rangeerror on line ["87"] of c: bignum big convert `long' run --trace see full backtrace c:\users\me\desktop\fff-bootstrap\scss\style.scss how resolve ? thank's i presume using spritesheet? if believe issue "chunkypng" when cannot compile correctly. i had issue , resolved resaving pngs in photoshop. guess there must have been error in image somewhere.

iis - IIS7 https to http redirect not working on www subdomain -

i trying force use of http on pages of our site exception of checkout page. have used rewrite rule below doesn't work www sub-domain in url. if use https://domain.com redirects http://www.domain.com if try https www nothing happens. please note there canonical domain name redirect in place issue still happens without rule. <rule name="no-https" enabled="true" stopprocessing="true"> <match url=".*" negate="false" /> <action type="redirect" url="http://{http_host}{request_uri}" /> <conditions> <add input="{https}" pattern="on" /> <add input="{url}" pattern="checkout" negate="true" /> </conditions> </rule> this has been driving me nuts morning, i'm hoping more experience of iis rewrites can give me help. spent few hours on similar issue. in case i'm redirecting traffic http

c# - Visual Studio Lightswitch 2013 HTML... how to calcualte and display? -

its rather simple area really, ive got lightswitch application hooked sql server, , want add 3 values table using computed field... know c# code side here work im add, ive got value in table, how display on screen view? it doesnt show in table list dragged , dropped onto screen, started javascript few days ago inexperienced @ moment, if possible, point me in right direction or give example of javascript please, grateful... thanks. literally spent days trying things , got no where..

java - mysql jdbc connector batch update exception update count not as expected -

i using batch insert java application mysql database bulk data loading. compiling result of failed executions, handling batchupdateexception in following way: catch (batchupdateexception e) { int[] codes = e.getupdatecounts(); (int = 0; i<codes.length; i++) { if (statement.execute_failed == codes[i]) { lr.recordloadcount--; //`records` list containing objects //added in batch lr.addfailreason(records.get(i).xmlstring()); } } lr.addexception(e.getmessage()); } i running case executions fail (table not exist). ideally having fail reason added every record. however, find first record, being added. when debugged code, found codes[0] coming '-1', whereas other coming '-3' (which statement.execute_failed). as per javadocs: public int[] getupdate

configuration - Configuring two logback appenders independently -

i might asking trivial, i've tried doesn't seem work. "main" appender, want log "info"s everywhere, except in third-party package (let's call boring ), produces many of them (so @ warnings only). additionally, want log "debug"s in interesting package. works fine following logback.groovy : root(info, ["main"]) logger("interesting", debug, ["main"]) logger("boring", warn, ["main"]) now want configure different appender logging 1 level more like root(debug, ["detail"]) logger("interesting", trace, ["detail"]) logger("boring", info, ["detail"]) this works, when put both together, doesn't. can imagine caused fact each logger either on or off given level. i'm aware behavior want, loggers in "boring" package must on info level (because of detail appender) , messages main appender filtered, can't see how configure th