Posts

Showing posts from July, 2011

javascript - jquery validation by date on a not required field -

i have been working on of today , feel i'm stumped. i found code validate field mm/dd/yyyy format not required. working 1 field. have multiple date fields not required if have in text field should date formatted mm/dd/yyyy. wish use datepicker client doesn't want it's validating data in text fields. here script i'm using on form: $(function() { $.validator.setdefaults({ errorclass: 'help-block', highlight: function(element) { $(element) .closest('.form-group') .addclass('has-error'); }, unhighlight: function(element) { $(element) .closest('.form-group') .removeclass('has-error'); }, errorplacement: function (error, element) { if (element.prop('type') === 'radio') { error.insertafter(element.parent()); } else { error.insertafter(element); } } }); $.validator.addmethod( "gooddate"

html - Put a backgound when hover a menu item -

i want create background-color or background-image when hover menu. this part of code. when hover on item c, background color changes behind submenu without jquery. @import "fonts.css"; body { color: #fff; margin: 0px; } .dropdownmenu{ height: 72px; background: #ec008c; } .dropdownmenu ul, .dropdownmenu li { margin: 0; padding: 0; } .dropdownmenu ul { background: gray; list-style: none; width: 100%; } .dropdownmenu li { float: left; position: relative; width:auto; } .dropdownmenu { color: #ffffff; display: block; padding: 24px 24px; font-size: 21px; text-align: center; text-decoration: none; } .menu:hover { background: #fff; color: #ec008c; } #submenu { left: 0; opacity: 0; position: absolute; top: 72px; visibility: hidden; z-index: 1; width: 235px; } li:hover ul#submenu { opacity: 1; visibility: visible; } #submenu li { float: none; width: 100%;

PHP: How to retrieve the parent array dimension having child -

i want create function pass parameter array "position", this: function f($pos){}; f($people[all][person][name]); then want retrieve parent dimension of array, want have $people[all] . way foreach cycle on person. my idea function pass position , function sort "parent" dimension position given. common case: $people[men][person][name]=>value f($people[men][person][name]) will sort men name. how that? how function f($pos){ foreach ($people[all][person] $name){ echo $name; } } f($people); this name

linux - Delete all except the most recent n files of each prefix (based on file date)? -

i'm running command in script, , it's deleting 5 of each file, it's not keeping last 5 files based on date: ls -rv | awk -f_ '++n[$1]>5' | xargs rm **underscore delimiter between prefix (hostname) , filenames. i've tried other stuff too, didn't seem trick. i'm running delete last n files in folder , works correctly: rm -f $(ls -1t -i "*.sh" | tail -n +21) this applies though. i have folder full of backups various devices have hostname prefixes. format is: hostname_config.backup-timestamp. @rici solved it. dumping -rv flags , using -t created behavior looking for. ls -t | awk -f_ '++n[$1]>5' | xargs rm

why ~9 returns -10 in Python -

this question has answer here: what '~' mean in python? [duplicate] 5 answers i trying following code , here outputs, have ideas why -10 , -11 returned? thanks. print ~9 print ~10 -10 -11 btw, using python 2.7.8. thanks in advance, lin from: python doc the unary ~ (invert) operator yields bitwise inversion of plain or long integer argument. bitwise inversion of x defined -(x+1). applies integral numbers. from: python doc two's complement binary negative integers: negative numbers written leading 1 instead of leading zero. if using 8 bits twos-complement numbers, treat patterns "00000000" "01111111" whole numbers 0 127, , reserve "1xxxxxxx" writing negative numbers. negative number, -x, written using bit pattern (x-1) of bits complemented (switched 1 0 or 0 1). -1 complement(1 - 1) = complement(0) = &qu

xcode - error uploading iOS app to the store -

Image
i'm trying upload app store here get: what i've done before:: 1- removing armv7s plist.info files 2- disabling compile active architecture only any idea please?? based on errors speculate architectures build setting includes architectures other arm64 , specify arm64 required device capability in info.plist. should either remove requirement info.plist or set architectures build setting arm64 .

c# - Visual Studio 2013: Is there a way to set properties like Autosize to true for all Forms on a particular project? -

i'm curious if there easy way set winform property autosize (for example) true every form in project without having manually change every single 1 of them. thanks! create form called baseform , let other forms inherit it. on baseform can set desired font, scaling etc. , other forms inherit these properties. first thing in every windows forms project fire up. you may consider creating basedialog, inheriting baseform. basedialog can have hidden minimize/maximize buttons etc. common modal dialogs in application.

mysql - Convert Mysqli query without using MYSQLND? -

i don't have mysqlnd driver on shared server. how write this: $stmt = $conn->prepare($query); $stmt->execute(); $result = $stmt->get_result(); $servers = mysqli_fetch_all($result,mysqli_num); without having mysqlnd driver? $servers = array(); $result = $conn->query($query); while ($row = $result->fetch_assoc()) { $servers[] = $row; } ^^^ worked!

javascript - How to automatically make content change? -

i have created block of code. works in way if click 1 of cirles, gets activated , content corresponding circle show. how can make change automatically that, example, every 5 seconds circle gets activated corresponding content shown. want make loop never ending. <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <style> #timeline{height:460px;width:3px;background-color:#e6e6e6;position:absolute;left:50%;top:55px;} a.cirle{width:15px;height:15px;background-color:#e6e6e6;border-radius:50px;position:absolute;} a.cirle:hover{background-color:red;} a.cirle.active{background-color:red;} .contentquestion1{position:absolute;top:35px;margin-left:-7px;left:50%;} .contentquestion2{position:absolute;top:225px;margin-left:-7px;left:50%;} .contentquestion3{position:absolute;top:425px;margin-left:-7px;left:50%;} #conten

osx - Python Basemap/Matplotlib Install -

i trying install basemap use matplotlib python v2.7 running on mac osx mavericks. have latest versions of modules (matplotlib,etc) running using anaconda, keep getting following error: traceback (most recent call last): file "simpletest.py", line 1, in mpl_toolkits.basemap import basemap file "/users/felishalawrence/anaconda/lib/python2.7/site-packages/mpl_toolkits/basemap/ init .py", line 37, in import _geoslib.so importerror: dlopen(/users/felishalawrence/anaconda/lib/python2.7/site-packages/_geoslib.so, 2): library not loaded: libgeos_c.1.dylib referenced from: /users/felishalawrence/anaconda/lib/python2.7/site-packages/_geoslib.so reason: no suitable image found. did find: /usr/local/bin/gcc-4.9/libgeos_c.1.dylib: stat() failed errno=20 can please give me idea of wrong? thanks!

perl - How can I pass in text rather than a file as a variable -

i want pass text in variable rather file. not sure how explain example. i have perl script usage follows printme.pl [file] want run without passing in file , passing text. echo print_me | perl printme.pl rather doing perl printme.pl textfile.txt i trying run perl script takes text file variable , outputs using echo. bash (amongst other shells) has feature called process substitution . in feature, can add shell code outputs stdout , have shell treat file. in case, write: perl printme.pl <(echo "hello world") perl receive in $argv[0] filename looks /dev/fd/63 can read line "hello world\n"

vim - Can I search all my registers to paste a value -

let's i'm restructuring text including line contains text "log". after bit more editing, want paste log line, in far-off register. there way search registers first contains term "log" , paste contents? the following should job: function! searchandpastereg() let l:pattern = input('reg search: ') if l:pattern == '' | return | endif l:i in range(1, 9) if match(eval('@'.l:i), l:pattern) != -1 execute printf('normal "%i]p', l:i) return endif endfor redraw | echo 'pattern not found' endf nnoremap <silent> ]r :call searchandpastereg()<cr> i'm not sure if talking numbered registers, or registers. if want search regs, extend range list containing desired register names, this: function! searchandpastereg() let l:pattern = input('reg search: ') if l:pattern == '' | return | endif let l:regs = range(cha

linux - awk command issue to recognize delimiter -

experts, thoughts why delimiter not working in case? '^a' real '^a' string, not ascii value 1. cat 2.txt 123^a9343784^a2207983400 45^a1270843^a66789439 67^a188285^a28075164 8^a91183^a27049564 9^a128589^a7283486 100^a84325^a7043462 cat 2.txt | awk -f'^a' '{print $1 }' 123^a9343784^a2207983400 45^a1270843^a66789439 67^a188285^a28075164 8^a91183^a27049564 9^a128589^a7283486 100^a84325^a7043462 btw, working on mac osx/linux. thanks in advance, lin edit after valid points made ed morton in comments area, have updated answer provide more insight on different behavior of awk variants regarding escaping. my understanding want use ^a delimiter. you have escape ^ character, messes awk's regex*. way this, prepending double escape sequence \\ ^ - in linux ( awk symlinked mawk or gawk , see note): $ cat 2.txt | awk -f'\\^a' '{print $1 }' # mawk, gawk now, mawk has more relaxed behavior on this, possi

android - Centering a button in a linear layout -

Image
using gravity on linearlayout centers button correctly: <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center"> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/new" android:paddingleft="40dp" android:paddingright="40dp"/> </linearlayout> but using layout_gravity=center on button centers button horizontally , not vertically, why? <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <button android:layout_width="wrap_content" android:layout_height=&quo

ruby - setting qos to 1 always sending the message -

i test sample code , set qos 1. why server sending message subscribe client subscribe client received message , search https://github.com/njh/ruby-mqtt/pull/58 should solve problem because in mqtt specs subscribe client should send puback after receiving message confirm message received. did missed something? tips? sub.rb require 'rubygems' require 'mqtt' mqtt::client.connect('192.168.9.105') |client| client.get_packet('test'=>1) |packet| puts packet.inspect end end pub.rb require 'rubygems' require 'mqtt' # publish example mqtt::client.connect('192.168.9.105') |c| c.publish('test', 'message 3', 0, 1) end because mqtt specifications qos 1 states message delivered at least once , may delivered more 1 time. (eg. puback timeout, network issues) quoting specs link: although tcp guarantees delivery of packets, there scenarios mqtt message may not received. in case of mqtt messag

c++ - Is it bad to not define a static array size in a class?--but rather to let it autosize -

ex: acceptable? compiles , seems work me; bad form? .h file class myclass { static char c[]; }; .cpp file char myclass::c[] = "abcde"; or must instead, example? .h file class myclass { static char c[10]; }; .cpp file char myclass::c[10] = "abcde"; is there benefit 1 technique on other? i'm not sure if i'm missing something. don't know don't know, ya know? update: the original code posted looked below. edited make shown above since didn't mean "private" aspect of point of discussion. in real code (running on arduino), using .h , .cpp files , static member intended accessed class. i guess i'm learning new though too, answers regarding below code seem tell me private static members same public static members ie: can both modified outside class if static. that, didn't know. wrong, see answer alok save here . more on static member variables here . line helpful me: "because static member

javascript Ace editor spaces turns into tabs? -

i'm using ace editor these settings: ace.getsession().settabsize(2); ace.getsession().setusesofttabs(true); ace.getsession().setusewrapmode(true); whenever press space automatically indents 2. want indent 2 spaces when press tab, 1 space when press space. how fix it? thanks. there may setting in code causing this, consider following 2 code examples :: var editor = ace.edit("editor"); editor.session.setoptions({ tabsize: 2, usesofttabs: true }); #editor { position: absolute; top: 0; right: 0; bottom: 0; left: 0; } <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js"></script> <div id="editor"></div> var editor = ace.edit("editor"); editor.session.setoptions({ tabsize: 8, usesofttabs: true }); #editor { position: absolute; top: 0; right: 0; bottom: 0; left: 0; } <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/

Android, elevation attribute ignored by LinearLayout -

i trying add elevation various components of app give little more material look. directly below layout giving me issues, have linearlayout casting shadow on sibling, element not show shadow , cannot figure out why. <linearlayout android:id="@+id/input_control_block" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:color="@color/white" android:elevation="8dp"> <button android:id="@+id/inputmodeselector" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="3" android:background="@color/cyan" android:clickable="true" android:drawableright="@drawable/ic_assignment_white_18dp" android:gravity="center_vertical|left" android:padding="16dp&

java - Creating a matrix out of a given vector -

i'm having trouble splitting vector 2d matrix or given side. example, given vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, rows (3), , columns (4) can turned {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}. as of right now, code prints out entire vector in array many rows are. int[][] reshape(int[] vector, int row, int col) { if (!isreshapable(vector.length, row, col)) { return null; } else { int[][] matrix = new int[row][col]; (int = 0; < row; i++) { (int j = 0; j < col; j++) { arrays.fill(matrix, vector); } } return matrix; } } you're iterating both i , j . use them (and position in vector ) like, int p = 0; int[][] matrix = new int[row][col]; (int = 0; < row; i++) { (int j = 0; j < col; j++, p++) { matrix[i][j] = vector[p]; } }

carrierwave - Rails form not retaining nested attributes upon failed submission -

i have articles form lists articles, includes form submit new article nested fields attaching photos. the form works , saves both article , photos. when validation fails render index action displays validation errors correctly. when render index action incorrect form data displayed correctly selected photos not retained user has correct data entry , reattach photos again. this problem users tend correct form data submit without noticing photos have not been attached. def index @article = article.new @articles = article.all end def create @article = article.new(discussion_params) @article.user_id = current_user.id @articles = article.all if @article.save redirect_to articles_path else render "index" end end private # never trust parameters scary internet, allow white list through. def article_params params.require(:article).permit(:content, attachments_attributes: [:id, :file, :_destroy]) end attachment.rb class attachm

python - php xdebug in netbeans - how to see values of variable? -

Image
i have enabled xdebug in php.ini file follows: [xdebug] zend_extension = "d:\xampp\php\ext\php_xdebug.dll" xdebug.profiler_append = 0 xdebug.profiler_enable = 1 xdebug.profiler_enable_trigger = 0 xdebug.profiler_output_dir = "d:\xampp\tmp" xdebug.profiler_output_name = "cachegrind.out.%t-%s" xdebug.remote_enable = 0 xdebug.remote_handler = "dbgp" xdebug.remote_host = "localhost" xdebug.trace_output_dir = "d:\xampp\tmp" and netbeans setting same manual. when try ctrl+f5 (after setting breakpoint in line 140) shows follows: how can see value of $user_id (or other variable's value) in netbean's console below?? or there way available debug php code setting breakpoint , inspect variable value in cli python import pdb;pdb.set_trace() ??? code break in particular line (when action taken submit form or reload browser) , can inspect each variable before breakpoint continue after breakpoint 1.review ph

How do you find the FQDN of the local host in GO (golang)? -

how find fqdn of local host in go (golang)? btw: net.lookupaddr() doesn't work on windows. that's not option. by default there no short way. os.hostname() doesn't provide qualified domain name default. cmd := exec.command("/bin/hostname", "-f") var out bytes.buffer cmd.stdout = &out err := cmd.run() if err != nil { log.errorf(err) } fqdn := out.string() fqdn = fqdn[:len(fqdn)-1] // removing eol

postgresql - Copying data from S3 to Redshift -

i feel should lot easier it's been on me. copy table 's3://s3-us-west-1.amazonaws.com/bucketname/filename.csv' credentials 'aws_access_key_id=my-access;aws_secret_access_key=my-secret' region 'us-west-1'; note added region section after having problem did nothing. where confused though in bucket properties there https://path/to/the/file.csv . can assume documentation have read calling path start s3://... change https s3 shown in example. however error: "error : error: s3serviceexception: bucket attempting access must addressed using specified endpoint. please send future requests endpoint.,status 301,error permanentredirect,rid" i using navicat postgresql connect redshift , im running on mac. the s3 path should 's3://bucketname/filename.csv'. try this.

c# - Can I mock object which is impossible to instantiate? -

i using com library in c# bound particular hardware , doesn't work without it. on development/testing computer don't have hardware. method using library looks this: using hwsysmanagerlib; bool processbias(hwsysmanager systemmanager, string hwpath) { int handle = systemmanager.openconfiguration(hwpath); ... // magic goes here // return result } the question is, can mock hwsysmanager test method , how? there few methods in hwsysmanager , wouldn't problem simulate functionality test. tiny example great on how mock it, if it's possible @ all. you can use adapter pattern here. create interface named ihwsysmanager public interface ihwsysmanager { int openconfiguration(string hwpath); } the real implementation class delegates work library: public class hwsysmanagerimpl : ihwsysmanager { private hwsysmanager _hwsysmanager; //initialize constructor public int openconfiguration(string hwpath) { return _hwsysmanag

java - Better way to return from recursive function when there are 2^n conditions -

suppose have n = 3 boolean variables -- a , b , c in java . these variables can have total of 8 (2^n = 2^3) combinations. these conditions used determine return statement in recursive function follows: static int recursivefunc(int x){ boolean a, b, c; = getboolval(x); b = getboolval(x + 1); c = getboolval(x + 2); if(a == true && b == true && c == true) //7 return recursivefunc(x + 1) + recursivefunc(x + 2) + recursivefunc(x + 3); else if(a == true && b == true && c == false) //6 return recursivefunc(x + 1) + recursivefunc(x + 2); else if(a == true && b == false && c == true) //5 return recursivefunc(x + 1) + recursivefunc(x + 3); else if(a == true && b == false && c == false) //4 return recursivefunc(x + 1); else if(a == false && b == true && c == true) //3 return recursivefunc(x + 2) + recursivefun

android - How to display long text to multiple line in ListView -

here xml: <listview android:id="@+id/headword_list" android:layout_width="match_parent" android:layout_height="match_parent" android:fastscrollenabled="true" android:background="#ffffff" android:cachecolorhint="#00000000" android:layout_weight="2"/> the listview showed using following code: headwordlist = (listview) rootview.findviewbyid(r.id.headword_list); adapter = new mdxadapter(getsherlockactivity()); adapter.setdict(dict, getstring(r.string.empty_entry_list), getstring(r.string.invalid_dict)); headwordlist.setadapter(adapter); rootview.requestfocus(); the problem faced when text display in list long fitted width, remaining text automatically truncated ... should can display long text 2 or more line, complete text can seen? yo

python - Output SQL as string from pandas.DataFrame.to_sql -

is there way of making pandas (or sqlalchemy) output sql executed call to_sql() instead of executing it? handy in many cases need update multiple databases same data python , pandas exists in 1 of machines. this more process question programming one. first, use of multiple databases. relational databases management systems (rdmbs) designed multiple-user systems many simultaneous users/apps/clients/machines. designed run 1 system, database serves central repository related applications. argue databases should agnostic apps , data-centric (postgre folks) , others believe databases should app-centric (mysql folks). overall, understand more involved flatfile spreadsheet or data frame. usually, rdms's come in 2 structural types: file level systems sqlite , ms access (where databases reside in file saved cpu directory); these systems though still powerful , multi-user serve smaller business applications relatively handful of users or team sizes server-level systems

html - Select all but last list-element -

i have list of tags want display horizontally. each <li> , last one, want add , after item. now, can of course: ul.tags { list-style: none; } ul.tags > li { display: inline; } ul.tags > li:after { content: ", "; } ul.tags > li:last-of-type:after { content: ""; } now thought combining last 2 rules, like: ul.tags > li:not(ul.tags > li:last-of-type):after { content: ", "; } but not work. how can select but last <li> ? all need :last-of-type within :not (like in below snippet). :not accepts simple selectors argument. below specifications simple selectors: a simple selector either type selector, universal selector, attribute selector, class selector, id selector, or pseudo-class. ul.tags > li:not(:last-of-type):after { content: ", "; } ul.tags { list-style: none; } ul.tags > li { display: inline; } <ul class='tags'> <

Executing shell script from Tcl -

i'm attempting run shell script tcl. i'm having bit of trouble though it's not working or giving me error troubleshoot. i'm pretty sure issue coming not having "run" formatted properly. appreciated. set run "sshpass -p 'password' ssh user@ip 'bash -s' <" set sh "test.sh" set cmd [list $run $sh $arg1 $arg2] if {[catch {eval [linsert $cmd 0 "exec"]} status]} { foreach line [split $status "\n"] { if {[string match *text* $line]} { //do } } } ended removing run variable , adding directly. works fine now. set sh "test.sh" set cmd [list sshpass -p 'password' ssh user@ip 'bash -s' \< $sh $arg1 $arg2] if {[catch {eval [linsert $cmd 0 "exec"]} status]} { foreach line [split $status "\n"] { if {[string match *text* $line]} { //do } } }

python - Creating table in SQLAlchemy from two different py files -

i have 2 python files, data.py , sql.py , , i'm trying achieve sqlalchemy create database table, name of database taken data.py ie: database name taken .py file. code in data.py class ddd(): which_mkt = 'us, hk' # user input mkt = input("choose value? [" + which_mkt + "]").upper() t = os.chdir(directorylistings.t_dir) # check in folder if file exist if os.path.isfile(t): # code create .db database file mkt name. code in sql.py # create database engine engine = create_engine(r"sqlite:///data\\" + z + ".db", echo=true) base = declarative_base() class gott(base): __tablename__ = 'country' id = column(integer, primary_key=true) country = column(string(255)) def __init__(self, country): self.country = country base.metadata.create_all(engine) so, in sql.py , z supposed variable name of database taken data.py i hope explanation clear. how should done?

Android App - Sync SQLite Database Across Multiple Devices -

hi i'm new android studio , looking answers i'm creating app has sqlite database, user can add/edit/delete data accordingly what want if user adds entry database on phone, if go on tablet new entry synced , displayed , vice versa is there standard / recommended way of doing this? thanks recommended way of doing sync adapters . you have knowledge on webservices , server programming able store data on servers , expose users. there third party solutions parse available can helpful .

Why does this java string comparison prints false? -

this question has answer here: how compare strings in java? 23 answers i beginning learn java,so please pardon if question seems silly, going through online examples. i found string question, should not output true ? as comparing 2 strings equal. public class helloworld{ public static void main(string []args) { string morning2 = new string("morning"); system.out.println("morning" == morning2); } } similarly program, should not print true public class helloworld{ public static void main(string []args) { string str1 = new string("paul"); string str2 = new string("paul"); system.out.println(str1 == str2); } } but program, prints true. public class helloworld{ public static void main(string []args) { string str3 = "harry";

.net - Display &#8211 text with Smileys in windows phone 8.1 C# (smileys are look like &#8211.) -

Image
i have string server contains content string html tags , smileys there. i'm able rid of html tags this, string get_title_with_nohtml = regex.replace(get_title, @"<[^>]+>| ", "").trim(); but smileys is. not able solution smileys while surfing much. here windows phone screen shot: the smileys red square area. have tried richtextblock richtextblock hasn't text property. i tried richtextblock example . var control = sender richtextblock; if (control != null) { control.blocks.clear(); string value = e.newvalue.tostring(); var paragraph = new paragraph(); paragraph.inlines.add(new run {text = value}); control.blocks.add(paragraph); } but result isn't exact. how can exact smileys? possible solution? in advance! i got solution this. string header_dashboard = windows.data.html.htmlutilities.converttotext(youstringswith_&#8221);

c# - How Marshal.FreeHGlobal can free unmanned array? -

i have reserved unmanned array using: intptr ptr = marshal.allochglobal(marshal.sizeof(array[0]) * array.length); then free using: marshal.freehglobal(ptr ); as far read, free memory correctly , no memory leak gonna happen. question: true? if is, how works? marshal state-full , store meta-data every reserved data? the allochglobal method exposes localalloc function. , freehglobal method exposes localfree function. memory management not being done managed component. done code behind these windows api functions. to answer question: yes has keep track of allocated size. can retrieve size of handle calling localsize function. honest, don't know how being done internally, don't need know that.

c++ - Speeding up processing speed for HoughCircles -

i working on hough circles function. when use function, processing speed quite slow. example, real time video feeding have lags of 1 seconds when move camera. or 10 seconds. code follows #include <sstream> #include <string> #include <iostream> #include <vector> #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <opencv\cv.h> #include <opencv\highgui.h> #include <stdlib.h> #include <stdio.h> using namespace std; using namespace cv; int main(int argc, char** argv) { //create window trackbars namedwindow("trackbar window", cv_window_autosize); //create trackbar change brightness int islidervalue1 = 50; createtrackbar("brightness", "trackbar window", &islidervalue1, 100); //create trackbar change contrast int islidervalue2 = 50; createtrackbar("contrast", "trackbar window", &islidervalu

java - Make Bottom Navigation Seperate From Fragment Layout -

i have navigation menu in fragment layout. facing issue when scroll viewpager scrolling navigation menubar too. looking ugly want move fragment activity layout menu function attached in fragment unable move it. my activity layout below <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.appbarlayout android:id="@+id/appbarmain" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/apptheme.appbaroverlay"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent"

python - Use IF statement to search json file -

i need search json file , print peole y status: [[{"name": "person1", "status": "y"}], [{"name": "person2", "status": "n"}], [{"name": "person3", "status": "y"}]] i can open file , display data ok, need search within it. complete if statement me? needs @ keyvalue? status , print 2 people y for name in openfile: **# if status == y do here? :** print ("name : " +name[i]['name']) print ("status : " +name[i]['status']) you need iterate on lists, extract dict , check key 'status': for element in openfile: ele = element[0] # grab dict if ele.get('status') == 'y': print 'name: {}'.format(ele.get('name') print 'status: {}'.format(ele.get('status') your openfile object l

javascript - Unable to remove Value from Array in Jquery -

i have following array var useridarray=["1", "3", "6", "39", "62", "139"]; i want remove array value using value i have tried following method function deletemember(id) { alert(id+"="+useridarray.indexof(id)); useridarray.splice(useridarray.indexof(id),1); } but remove last value. also noticed useridarray.indexof(id) return -1 if pass value useridarray.indexof("6") delete particular position can 1 me how remove particular value ? i think got problem id putting deletemember functions isn't string. this solve problem: var useridarray=["1", "3", "6", "39", "62", "139"]; function deletemember(id) { removeid = string(id) removeindex = useridarray.indexof(removeid) if(removeindex != -1) useridarray.splice(removeindex,1); } deletemember(3)

php - Does adding an index on the column you are selecting speed up the query? -

i have common setup, have table of tags , record pairs. querying slow adding index column of tag querying helps speed up. tag | site 123 | 456 789 | 101 my question whether beneficial add index on both these columns 1 index. never selected site, there benefit doing this? cannot guarantee each pairing unique without making changes if did performance? a typical query might this: select site , tag sitetags tag ='123' or tag = '789' if search tag need index tag column. adding column index when not used, introduce unneeded overhead when insert or update record , consume more storages. but composite index ( tag , site ) may give additional optimization mysql need read index satify query ( explain marks optimization using index ). if operation read rather write, using composite index may not bad idea. it better if tag column has high cardinality, meaning there high chance values different between each rows. but suggest consult explain

php - Create an array from two associative array -

i've 2 arrays bellow: array (size=2) 827 => int 3 868 => int 3 array (size=4) 827 => int 2 868 => int 2 829 => int 1 541 => int 1 i want combine 2 arrays , add values when keys matches. resulting array needs be: array (size=4) 827 => int 5 868 => int 5 829 => int 1 541 => int 1 tried different array manipulation function none of them worked. appreciated. you can following: using + on arrays, creating new array, have key/values of both, duplicates not overriden second one. after can loop again on second array , and add values (but if value not present in $a1). if not present in $a1, value in merged array $a2. $a1 = array(827 => 3, 868 => 3); $a2 = array(827 => 2, 868 => 2, 829 => 1, 541 => 1); $merged = $a1+$a2; foreach($a2 $key => $value){ if(!empty($a1[$key])){ $merged[$key] = $merged[$key] + $value; } }

android - Starting JobIntentService from PendingIntent (Notification button)? -

in app, have notification button fires off short network request in background using intentservice. not make sense show gui here, why use service instead of activity. see code below. // build intent used start notifactionservice intent buttonactionintent = new intent(this, notifactionservice.class); buttonactionintent.setaction(notifactionservice.action_send_confirm); buttonactionintent.putextra(notifactionservice.extra_confirm_id, confirmid); buttonactionintent.putextra(notifactionservice.extra_notif_id, notifid); // build pendingintent used trigger action pendingintent pendingintentconfirm = pendingintent.getservice(this, 0, buttonactionintent, pendingintent.flag_update_current); this works reliably new background restrictions in android 8.0 made me want move jobintentservice instead. updating service code seems straight forward don't know how launch via pendingintent, notification actions require. how accomplish this? would better move normal service , use pendingin

php - Symfony Yaml based routing doesn't work as generated -

i'm following symfony3 intro. i ran php bin/console generate:controller , followed prompts, choosing yaml routing because don't comments code. it generated following: number: path: /lucky/number defaults: { _controller: appbundle:lucky:number } and placed src/appbundle/resources/config/routing.yml this doesn't work. however, copying contents app/config/routing.yml does. it seems i'm missing additional config doesn't mention in guide because expects use annotations routes. doesn't mention in docs here under "using other formats" section. is copying generated route other file right thing do? there alternative step tells find other yaml based routes? in app/config/routing.yml can do: app: resource: '@appbundle/resources/config/routing.yml' and write inside of appbundle/resources/config/routing.yml work

ssl - CAA record suport on which server -

from 8th september 2017 mandatory have caa record ssl certificate ca/browsers forum on dns server. on linux's server upgrade bind 9.8 , support caa record , know work bind 9.6 question microsoft dns server. have win 2003 , dns server v 5.2.3 , tried add record manually c:\windows\system32\dns\domainzone.dns no sucess know microsoft part os ca/b forum did not found news microsoft point dns server version record. should move win 2012/2016 or upgrade dns server? from 8th september 2017 mandatory have caa record ssl certificate ca/browsers forum on dns server. you not required have caa record domain owner. requirement ca's check if there caa record domain , if allowed issue certificate based on record. this means, if there no caa record domain every public ca allowed issue certificate it. , not mean cannot certificate if don't have caa record.

c# - Increase Async HttpClient GetStringAsync speed. Won't make any check difference if I pass different values to check at the same time -

i'm checking on own server if username turns aviable or not. code run in while loop until condition turns true , other code executed. my problem: it doesn't matter value store inside int amount parameter. speed of checks remain same. could caused defaultconnectionlimit or similare? what want do: i want increase following value: int amount = int32.parse(bunifucustomlabel11.text); to run more checks @ same time. @ specific point speed wouldn't increase anymore. let's pass value 100 code executed in same speed when entered 200 example. functions: check current status of handle/username , return true or false: private async task checkuntiloneoftheusersisavaliable() { int amount = int32.parse(bunifucustomlabel11.text); await task.whenany(enumerable.range(0, amount).select(i => checkuntiluserisavaliable())); // if aviable run other code.. } private async task checkuntiluserisavaliable() { while (!await isuseravaliable(bunifumetrot

android - Firebase init fails when running tests in androidTest -

i have app splitten modules support instant app feature. app uses firebase . the app uses firebase in application.oncreate() callback (on startup). when try run tests in androidtest , app crashes. i put logging , discovered, app runs different process name when run normally, , test: class app : application() { override fun oncreate() { super.oncreate() firebaseapp.initializeapp(this) // com.mypackage.app when run normal app // com.mypackage.app.test when running tests log.d(tag, "running process name: " + processname(this)) // crashes process under test val token = firebaseinstanceid.getinstance().token log.d(tag, "instance token: " + token) } } i can observe firebase error message when running test suite: 09-10 13:46:00.533 17360-17360/com.mypackage.app.test i/firebaseinitprovider: firebaseapp initialization unsuccessful my google-services.json uses defines com.mypackage.a

openstack image-delete can not delete image -

our openstack kilo , manage vmware 6. we backup using following command: nova backup 762ecf86-f5eb-4c7c-a512-3cf15e23dd1a \ backup-snapshot-a-daily-$(date "+%y%m%d-%h:%m") daily 1 a new image appears when running glance image-list . to delete it, run glance image-delete without errors. we run glance image-list again , find image has disappeared. yet in vsphere client, in vmfs, directory still here. after 1 minute, run glance image-list again, image still there. so how can delete image?

css - Two column grid in react native flexbox -

this question has answer here: react native flexbox - how percentages || columns || responsive || grid etc 2 answers i'm trying build 2 column grid in react native. have 4 square, each should occupy half width of screen , there total of 2 columns in case. here code: let profilemetricsarray = [{ title: localization.session_count, value: this.state.sessioncount }, { title: localization.hours_used, value: this.state.hoursused }, { title: localization.day_streak, value: this.state.daystreak }, { title: localization.session_count, value: this.state.sessioncount }].map((item, i) => { return <view style={globalstyle.profilemetrics}> <text style={globalstyle.profietext}> {item.title}</text> <text style = {globalstyle.profilevalues}> {item.value} </text> </view> })

Scala can't infer type arguments of Java method -

i have following sophisticated type hierarchy in java: // first type interface element<type extends element<type>> { type foo(type a, type b); } // second type interface payload<type extends payload<type>> { type bar(type[] array); } // toy implementation final class somepayload implements payload<somepayload> { @override public somepayload bar(somepayload[] array) { return array[0]; } } // mix of first , second interfaces interface complicatedelement< payloadt extends payload<payloadt>, objectt extends complicatedelement<payloadt, objectt>> extends element<objectt> { payloadt getpayload(); objectt add(objectt a, objectt b); } // toy implementation final class somecomplicatedelement implements complicatedelement<somepayload, somecomplicatedelement> { final somepayload data; public somecomplicatedelement(somepayload data) { this.da

Mediawiki Infobox: How to display images -

i can not images in info boxes of mediawiki (1.29.1, semantic mediawiki installed) show up. renders filename text. my info box template: <includeonly>{| class="wikitable" ! name | [[initiative_name::{{{name|}}}]] |- ! logo | [[initiative_logo::{{{initiative_logo}}}]] ... |} </includeonly> and here´s use on page info box should displayed: {{infobox |name=my name |logo=logo_kasimir.png ... }} any appreciated.

web scraping - How to scrape web data in vba -

Image
i have followed jsotola's suggestion , recorded following macro, encountered error, how can solve it? run time error 91 , following code has been highlighted selection.listobject.tableobject.refresh sub macro1() activeworkbook.queries.add name:="1-1-1", formula:= _ "let" & chr(13) & "" & chr(10) & " source = web.page(web.contents(""http://www.hkjc.com/english/racing/horse.asp?horseno=v099""))," & chr(13) & "" & chr(10) & " data0 = source{0}[data]," & chr(13) & "" & chr(10) & " #""changed type"" = table.transformcolumntypes(data0,{{""column1"", type text}, {""column2"", type text}, {""column3"", type text}})" & chr(13) & "" & chr(10) & "in" & chr(13) & "" & chr(10) & &