Posts

Showing posts from March, 2012

android - Using AlarmManager to activate and deactivate silence mode -

in program, getting 2 dates user. first date activating silence mode , second date deactivating it. handling issue, have tried use 2 different alarmmanager , 2 different broadcastreceiver couldn't achieve it. can activate silence mode @ first date couldn't deactivate it. part of code: public class addevent extends appcompatactivity { private static pendingintent silenceactivatorpendingintent; private static pendingintent silencedeactivatorpendingintent; private static alarmmanager manager1; private static alarmmanager manager2; @override protected void oncreate(bundle savedinstancestate) { intent silenceactivatorintent = new intent(this, silencemodeactivator.class); intent silencedeactivatorintent = new intent(this, silencemodedeactivator.class); silenceactivatorpendingintent = pendingintent.getbroadcast(this, 0, silenceactivatorintent, 0); silencedeactivatorpendingintent = pendingintent.getbroadcast(this, 0, silenc

android - How to calculate IV on AuthenticateISO on DESFire EV1 -

i'm having troubles creating new iv after authenticating. i'm not sure if understanding of concept right, mifare documentation. data on card enciphered. these steps i'm taking: authenticateiso 0 iv (0x1a 3k3des key) response card (encrypted randa'): 08 48 cd a3 43 c5 00 fe 1d 78 d1 e5 a9 24 26 5a 91 00 first 8 bytes should cmac , updated iv(?): 08 48 cd a3 43 c5 00 fe create 3k3des session key: 74 ef 23 87 10 e4 3b e6 c8 4c 41 74 03 08 a9 7f f3 fa 59 15 e4 c5 06 call getvalue: 90 6c 00 00 01 [fileid] 00 response card: a2 3c cb 70 4d d5 22 91 00 decrypt first 8 bytes response session key , updated iv decrypted result: 7f 7d 80 f5 [crc32] after last step, first 4 bytes should value , last 4 crc32. sure i'm not doing right iv, because result isn't correct. should 0f a0 00 00 [crc32] . could have pointers i'm doing wrong? i've been trying solve @ least 2 weeks , have come nowhere. you put android tag in question. suggest use tap

python - Google search results limits -

i tried search in google search engine word "sunday". the total number of results 1.390.000.000 . can see first 420 results, until 42 page of results. is there way take results of google search? you can use google module control number of results query. install using pip : pip install google usage: from google import search n = 10 # number of results query = 'sunday' results = google.search(query, stop=n) # returns generator result in results: print(result) before using method, keep in mind pause parameter: pause (float) - lapse wait between http requests. lapse long make search slow, lapse short may cause google block ip. mileage may vary! docs

css - Removing table border which is inside a cell -

i have table inside table, want remove border cells of child table(around , b). below source code this. <style> .withborders tr td{ border: 1px solid black !important ; } .withborders table.withoutborders tr td { border:0px } </style> <table class="withborders"> <tr> <td> <table class="withoutborders"> <tbody> <tr> <td>a</td> <td>b</td> </tr> </tbody> </table> </td> <td>c</td> </tr> <tr> <td>d</td> <td>e</td> </tr> </table> the problem isn't working, have tried many changes child table's css selector unable override parent table css property. could please advice on this? note: can no

math - Rotate a matrix(2D Array) by 45 degrees in c++ -

i'm trying rotate matrix(mxn)by 45 degrees. example: |a|b|c|d|e| |f|g|h|i|j| |k|l|m|n|o| would rotated this: | | |a| | | | | | |f| |b| | | | |k| |g| |c| | | | |l| |h| |d| | | | |m| |i| |e| | | | |n| |j| | | | | | |o| | | any appreciated! edit: on problem. i have been thinking , formula ended with: f(i,j) = (i+j,m-1-i+j) but problem run if rotation 2 times wouldn't 90 degree rotation. if wanted rotate point (x,y) 45° use formula x' = cos(45°) * x - sin(45°) * y y' = sin(45°) * x + cos(45°) * y now know cos(45°) = sin(45°) = 1 / sqrt(2). if (x,y) integer coordinated (x',y') not integers due sqrt(2) factor. if want rotate elements in matrix points lie in matrix want rotate integer coordinates integer coordinates (taking central point h origin). in sense, asking impossible. there 2 ways around this. 1) drop requirement integer coordinates. not possible if want fit results in array. if array represents pixels in image do. once rotat

ios - Adding an action to a custom button -

i have custom button animation , inside view. i'm having problems adding action button. here code. logout button , don't know how add action on log user out. class exampleviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() self.view.backgroundcolor = uicolor.white self.addcircleview() // additional setup after loading view, typically nib. } func addcircleview() { var circleview1 = vmbuttoncirclefun(frame: cgrect(x: cgfloat(0), y: cgfloat(0), width: cgfloat(60), height: cgfloat(60))) circleview1.addcirclelayer(withtype: vmmakelocation.top.rawvalue) circleview1.strokecolor = uicolor(red: 243/255, green: 106/255, blue: 106/255, alpha: 1.0) circleview1.center = cgpoint(x: cgfloat(self.view.bounds.width / 2 - 100), y: cgfloat(self.view.bounds.height / 2)) circleview1.seticonbutton(uiimage(named: "layer 14.png")!, withtype: vmmakelocation.top.rawvalue, with: uicolor(red: 127/255, green: 140/255, b

c# - How does the strategy pattern differ from polymorphism? -

in computer programming, strategy pattern (also known policy pattern) behavioural software design pattern enables algorithm's behavior selected @ runtime. the strategy pattern... defines family of algorithms. encapsulates each algorithm. makes algorithms interchangeable within family. (source: wikipedia ) in case, want able inject different hashing algorithms service. c# has several hashing algorithms derive hashalgorithm , such as: md5 sha256managed ripemd160managed given hierarchy, looks strategy pattern, had never heard of strategy pattern, might classic example of polymorphism. whilst designing code solve particular problem, designed interface based on strategy pattern inject different hashing algorithms: public interface ihashstrategy { hash computehash(byte[] data); } usage public sealed class hashcreator { public hash gethash(ihashstrategy strategy, byte[] data) { return strategy.computehash(data); } } going previous

javascript - Toggling CSS Class Has No Effect on Element -

Image
i trying create basic javascript drop down menu. toggling class called "show," displays drop down content. not work - element stays hidden after class applied. i imagine have error in here somewhere, can't seem find it. help! function drop() { document.getelementbyid('content').classlist.toggle('show'); } .container { display: inline-block; position: relative; } .dropdown_btn { color: white; background-color: black; cursor: pointer; padding: 20px; } .dropdown_btn:hover, .dropdown_btn:focus { background-color: grey; } #content { display: none; position: absolute; background: grey; color: white; width: 160px; } .container { text-decoration: none; display: block; padding: 10px; color: white; } .container a:hover { background-color: #f1f1f1 } .show { display: block; } <div class="container"> <button

php - Unable to connect to Amazon RDS from EC2 wordpress site -

i'm migrating website cpanel hosting amazon ec2. i'm using amazon rds host wordpress database. i followed following steps: created folder wordpress files old server. created database in rds , uploaded old site's db dump. edited wp-config.php file change parameters connect rds instance. while worked out fine, except i'm getting following error " error establishing database connection " while open site in browser. tried changing security group on rds , allow , added user on mysql required permission database. the problem connection rds not getting established. i'm able connect rds ec2 instance wordpress not able to. my wp-config.php looks like: /** name of database wordpress */ define('db_name', 'wordpress'); /** mysql database username */ define('db_user', 'db_username'); /** mysql database password */ define('db_password', 'db_password'); /** mysql hostname */ define('db_host',

intellij idea - Creating a live template in Android Studio -

i'm trying create live template in android studio convert "a string".smt to someclass.somemethod("a string") by going preferences > editor > live templates i've created new live template. choose applicable in java: expression i've put smt abbreviation , following template text: someclass.somemethod($string$) this works when type smt individually , creates someclass.somemethod() but want put string directly method parameter. template doesn't come when type .smt following string. ideas? postfix completion templates cannot created through ui. include custom logic , can implemented plugins.

hadoop - elastic search table in hive -

i have hive table below basicinfo: name string, address string, state string, dob date created es index : below create external table esbasic (name string, address string, state string, dob date) stored 'org.elasticsearch.hadoop.hive.esstoragehandler' tblproperties('es.resource' = 'test32/test32','es.nodes' = 'x.x.x.x:9200','es.input.json' = 'false'); insert overwrite table esbasic select * basicinfo select * esbasic it returns proper results. but in kibana , when visualize table, address field makes problem when has more 1 word. like, riverview avenue in address field becomes 2 separate words. need mark address field not analyzed. how can while creating @ time of hive external table creation? or there other way modify this?

r - Text layer work in ggplot but removed with ggplotly -

Image
i have barplot text layer working fine ggplot library want add interactivity ggplotly fails show text layer updated packages problem persist df = read.table(text = " id year type amount 1 1991 hiit 22 2 1991 inter 144 3 1991 viit 98 4 1992 hiit 20 5 1992 inter 136 6 1992 viit 108 7 1993 hiit 20 8 1993 inter 120 9 1993 viit 124 10 1994 hiit 26 11 1994 inter 118 12 1994 viit 120 13 1995 hiit 23 14 1995 inter 101 15 1995 viit 140 16 1996 hiit 27 17 1996 inter 103 18 1996 viit 162 19 1997 hiit 24 20 1997 inter 96 21 1997 viit 172 22 199

How do I run AVL (a binary) from a python script using the subprocess module? -

i'm trying script series of runs in avl (athena vortex lattice) , vortex lattice code designing wings , other lifting surfaces. i have binary stored in ~/bin/. typically run avl within terminal, , enter commands. typical commands be: load ~/path/avlexamplefile.avl oper a 5 x fs return quit which, loads .avl input file, enter operations menu, sets angle of attack 5 degrees, executes computation, prints out forces output file, exits operations menu, , quits program. i'm trying run avl python script using subprocess module using following code: import subprocess sp avl = sp.popen(['~/bin/avl3.35'], stdin=sp.pipe,stdout=none, stderr=none, universal_newlines=true) avl.communicate('load ~/file/avlexamplefile.avl') this works. avl loads, first command executed, following error, , won't take further commands. avl c> forrtl: severe (24): end-of-file during read, unit -4, file

Does Google App Script PropertiesService support serialized data or arrays? -

i'm trying pass serialized data, or array, through propertiesservice , in order build dynamic table in docs. i'm thinking of like: var properties = propertiesservice.getdocumentproperties(); var orderlist = properties.getproperty("orders"); // iterate through orderlist add rows table columns description, amount , price. is possible, or should fall work indexes , string-manipulation key names like: var rowcount = properties.getproperty("row_count") // for-loop till rowcount var itemdesc = property.getproperty("item_" + + "_description") var itemprice = property.getproperty("item_" + + "_price") both methods work. there quotas may limit either approach. if serialize array , save orders property have make sure stays under 9kb limit per value. if make property each line item need stay under 500k read/writes per day. number going changing in near flexible quota system. https://developers.goog

how to add jquery tabcontrol in jquery dialog that open from other jquery dialog have a tab control -

i have jquery dialog form contains jquery tabcontrol. $(document).ready(function () { var dialog = $("#createform").parentsuntil(".ui-dialog"); dialog[0]["validatefilter"] = { ignore: "" }; dialog[0]["forminvalidcallback"] = function () { $("#persontab").tabs("select", $("form .input-validation-error").closest(".ui-tabs-panel").get(0).id); }; $(dialog).parent().find(".ui-dialog-content").addclass("dialog-content-nopadding"); dialog.find("#persontab").tabs({ "show": function (event, ui) { if (!$(dialog)[0].dragged) dialog.dialog('option', 'position', 'center'); var otable = $('div.datatables_scrollbody>table.display', ui.panel).datatable(); if (otable.length >

javascript - Trying to reuse a redux-form with functional component -

Image
i'm trying build reusable component create simple forms, having validation , handling submit actions. able use self, when try make functional component inject props got stuck in error. this class uses component build forms import react 'react'; import customreduxform './customreduxform'; class loginform extends react.component { getfields() { return [ { name : 'username', type : 'text', label : 'user', mandatory : true }, { name : 'password', type : 'password', label : 'password', mandatory : true } ]; } handleformsubmit(values) { console.log(values) } render() { return ( <div> <div>test</div> <customreduxform formname="loginform" fields={this.getfields()} onsubmit={this.handle

Unable to execute java program in jenkins? -

i trying execute simple java class through jenkins , have followed below post no results,please how execute complete java program in jenkins. how compile , run simple java file in jenkins on windows always getting error building in workspace c:\program files (x86)\jenkins\workspace\run java class [run java class] $ cmd /c call c:\windows\temp\hudson7739288570136427109.bat c:\program files (x86)\jenkins\workspace\run java class>javac "e:\java_tutorials\javapractices\src\com\practice\javssupercars.java" javac: file not found: e:\java_tutorials\javapractices\src\com\practice\javssupercars.java usage: javac <options> <source files> use -help list of possible options c:\program files (x86)\jenkins\workspace\run java class>java supercars error: not find or load main class supercars c:\program files (x86)\jenkins\workspace\run java class>exit 1 build step 'execute windows batch command' marked build failure finished: failure the

php - PhpStorm Path not found inspection -

require_once app . ds . 'controllers' . ds . $this->controller . '.php'; i'm including controller. has default value set , has find something. in real world works, inspection still shinning in ide , solve somehow. inspection says this path '/media/matej/space/www/rs/app/controllers/$this->controller' not found how can explain it, aware of happening? there comment solve issue? you using dynamic code here .. cannot evaluated in ide using static analysis alone (as using $this->controller can during run time). two options here: suppress warning line -- place /** @noinspection phpincludeinspection */ on line before that. this option makes sense if have little of such suppressions in code, otherwise half of file suppression comments :) just turn off such inspection -- adding such suppression comments time (often) looks ugly , not desired way in general. for that: settings | editor | inspections | php | general --> unres

List of application which use ODBC driver -

i need find out applications use odbc driver such ms excel, ms access. reason behind it, since access has naming conventions column , table name ( https://support.office.com/en-us/article/guidelines-for-naming-fields-controls-and-objects-3c5d8ebd-08b5-472a-ae57-c3632910068b ). need find out other application has naming conventions column , table name.

python - I need to understand how __setstate__ can change the value of assigned variable -

this part of code show how code constructed. after calling , initiating network call function setstate update saved parameters iterate , save them in self.params update done inside object layer , variables w , b. i don't understand how updating self.params update original variables. def __getstate__(self): weights = [p.get_value() p in self.params] return weights def __setstate__(self, weights): = iter(weights) p in self.params: p.set_value(i.next()) def __init__(self, .......): self.layer8 = lenetconvpoollayer( rng, input=self.layer7.output, image_shape=(.....), filter_shape=(....), subsample=(..) ) self.params = self.layer8.params + self.layer7.params + self.layer6.params class lenetconvpoollayer(object): def __init__(self, .......): self.w = theano.shared(w_values, borrow=true )

linux - docker cannot start container after reboot use '--restart-always' -

i want container auto-start after computer reboot, use '--restart=always' flag, don't run expected. when reboot system, container didn't startup. i'v tried change storage driver aufs overlay2, use '-s overlay2', didn't help. $ uname -a linux debianv 4.9.0-1-amd64 #1 smp debian 4.9.2-2 (2017-01-12) x86_64 gnu/linux $ docker version client: version: 1.13.0 api version: 1.25 go version: go1.7.3 git commit: 49bf474 built: tue jan 17 09:44:08 2017 os/arch: linux/amd64 server: version: 1.13.0 api version: 1.25 (minimum version 1.12) go version: go1.7.3 git commit: 49bf474 built: tue jan 17 09:44:08 2017 os/arch: linux/amd64 experimental: false $ docker info containers: 2 running: 0 paused: 0 stopped: 2 images: 2 server version: 1.13.0 storage driver: overlay2

MATLAB - least square curve fit for multiple independent variables -

Image
i have following function: i'd coefficients least squares method matlab function lsqcurvefit . the problem is, don't know, if it's possible use function when function t has multiple independent variables , not one. so, according link should have multiple xdata vectors - this: lsqcurvefit(f, [1 1 1], nprocs, ndoms, ndof, measuredvals) do know how it? my attempt i've tried define objective function this f = @(c, x) c(1)*x(2).^(c(2)*x(1).^c(3)) + (c(4) + c(5)*x(1))/x(3); and use lsqcurvefit this lsqcurvefit(f, [1 1 1], [ndoms ndof nprocs], measuredvals), but there's problem, measuredvals vector of size 56x1, "xdata" matrix of size 56x3, i'm getting error: index exceeds matrix dimensions. error in factorizatonkglobregr>@(c,x)c(1)*x(2).^(c(2)*x(1).^c(3))+(c(4)+c(5)*x(1))/x(3) error in lsqcurvefit (line 202) initvals.f = feval(funfcn_x_xdata{3},xcurrent,xdata,varargin{:}); caused by: failure in initia

javascript - JQuery DataTable: Set colspan of column title dynamically -

unlike in example provided documentation, want make column title span dynamically. i have generated sample data var data = []; (var = 0; < 4; ++i) { (var j = 0; j < 4; ++j) { var datarow = []; datarow.push ("10" + (i + 1)); datarow.push ("a"); (var k = 0; k < 8; ++k) { datarow.push ("b"); datarow.push ("test"); } data.push (datarow); } } tried generate header via columndefs var columndefs = [ { title: "title", targets: [0, 1] } ]; (i = 0; < 8; ++i) { columndefs.push ({ title: "data" + i, targets: [(i + 1) * 2, (i + 1) * 2 + 1] }); } and generated table $("#table").datatable({ columndefs: columndefs, data: data, rowsgroup: [ 0 ], responsive: true, paging: false, searching: false, fixedheader: true, fixedcolumns: {

google apps script - Improove function of multiple replacement by RegEx in range of cells -

i use code multiple regex replace in range of cells, work slow. know better use "push array" instead of range.getvalue, dont understand how works , grateful help. function patternizer(){ var ss = spreadsheetapp.getactivespreadsheet().getactivesheet(); var firstrow = 1 var lastrow = 1000 var column = 11 regexrep(/( |)\d+-\d+/,'',firstrow,lastrow,column); regexrep(/\d{4}-\d{4}/,'',firstrow,lastrow,column); regexrep(/.*?(\d\d.*)/,'$1',firstrow,lastrow,column); regexrep(/(.*\d\d).*/,'$1',firstrow,lastrow,column); regexrep(/[a-za-z]{3,}/,'',firstrow,lastrow,column); } function regexrep(rxp,rxr,firstrow,lastrow,column){ //(regex pattern, replace pattern, firstrow, lastrow, column) var ss = spreadsheetapp.getactivespreadsheet().getactivesheet(); var r1 = new regexp(rxp); (i=firstrow; i<=lastrow; i++){ try{ var tr = ss.getrange(i, column

c - Mutex lock and a number of threads -

i have api (written in c ) permits number of incoming (concurrent) connections. each connection handled independet pthread created whenever client connects api. each of these connections can (but not have to) change properties of server such requests should not processed @ same time. my code follows structure: pthread_mutex_t lock; void request_handler(char * request) { pthread_mutex_lock(&lock); process_request(request); pthread_mutex_unlock(&lock); } assume 1 request being processed takes long time (e.g. ten seconds). in time, 5 other requests come in, 5 additional pthreads reach @ pthread_mutex_lock function. do wait there , continue intended (one after served)? the reason why i'm asking this i'd expect haven't found example more 1 concurrent thread in official documentation. is there guarantee requests processed in same order in have been received or any single 1 of 5 waiting threads allowed start after long request finished?

php - .htaccess - allowing access to a directory from one URL -

my current .htaccess file looks this: rewriteengine on rewritecond %{http_referer} !^https?://mysite.com/page/ [nc] rewriterule ^ - [l,f] and allows access index.php file in 'restricted' area people accessing iframe on /page/. how can allow access files in directory 403 error @ moment.

Returning to previous window not working in Python Tkinter -

i new python , trying had designing gui application.i have 3 classes in directory of python project, each 1 projects different window of different size therefore using window.destroy() everytime before call class, in 1 window, have button while trying access menu() function empty window loads up. below codes of 3 classes login, menu , customerdetails respectively. path being followed: login-->menu--> new customer--> button-->(ideal result=menu, result=blank window ). from tkinter import * tkinter import ttk frontend.menu import menu class login: def log(self): if self.username.get() == "123" , self.password.get() == "123": self.window.destroy() menu() def login(self): # title frame title=frame(self.window, border=2) title.place(relx=0.5, rely=0.2, anchor=center) # addng login form frame frame=frame(self.window,background="#ccd5cc", highlightthickness=2 ) frame.place(relx=0.5, rel