Posts

Showing posts from January, 2015

How to wrire custom validation rule in controller Laravel? -

i have default validation rule in controller laravel: $validator = validator::make($request->all(), [ 'email' => 'required|email', 'phone' => 'required|numeric', 'code' => 'required|string|min:3|max:4', 'timezone' => 'required|numeric', 'country' => 'required|integer', 'agreement' => 'accepted' ]); i tried this, dont know how transfer parameters inside function: public function boot() { validator::extend('phone_unique', function($attribute, $value, $parameters) { return substr($value, 0, 3) == '+44'; }); } how can extent validation own rule? example need validate concatination of inputs: $phone = $request->code.' '.$request->phone after check if $phone exists in database i want use method: > $validator

.net - How to add a reference of "System.ServiceModel" from Azure Function? -

i calling soap service azure function, , need add reference of system.servicemodel assembly. able add other dependencies using nuget, particular assembly framework assembly, not sure how can add reference of assembly in azure function. currently getting following compilation error: error cs0012: type 'clientbase<>' defined in assembly not referenced. must add reference assembly 'system.servicemodel, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089'. copying assembly bin folder using kudu last thing want try :) any suggestions on better approach this? thanks , regards, nirman https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp you can refer system assemblies #r "assemblyname" directive #r "system.web.http" using system.net; using system.net.http; using system.threading.tasks; public static task run(httprequestmessage req, tracewriter log)

asp.net mvc - X.PagedList.MVC namespace not available following NuGet install -

i'm trying switch pagedlist x.pagedlist . i've used nuget uninstall pagedlist , pagedlist.mvc packages , install x.pagedlist , x.pagedlist.mvc. when go update views, find myself in strange situation: can't seem reference pagedlist.mvc namespace detailed in the example this: @using x.pagedlist.mvc; @using x.pagedlist; in visual studio , when debugging, gives following exception: the type or namespace name 'mvc' not exist in namespace 'x.pagedlist' (are missing assembly reference?) ( as aside, if leave off using , exceptions missing definitions, expected. ) is there problem nuget package? there way manually add assembly reference package installed via nuget? so, in end did find hacky way work... all needed manually add reference x.pagedlist.mvc.dll . oddly, present in packages directory ( .\packages\x.pagedlist.mvc.5.3.0.5300\lib\net46 ) , has looks valid package file. not sure why didn't happen automatically, i'm

wordpress - Allow ony specific Email Address Domain to register as customer in Woocommerce -

need know can allow specific domain email addresses register customer in woocommerce. and redirect them specific page or url. also want know how can limit woocommerce transaction carried out per user. mean 5 translations per user should executed in time frame of 24 hours.

c - Multiplying large matrices is much slower with contiguous memory allocation -

while implementing neural network, noticed if allocate memory single contiguous block data set arrays, execution time increases several times. compare these 2 methods of memory allocation: float** alloc_2d_float(int rows, int cols, int contiguous) { int i; float** array = malloc(rows * sizeof(float*)); if(contiguous) { float* data = malloc(rows*cols*sizeof(float)); assert(data && "can't allocate contiguous memory"); for(i=0; i<rows; i++) array[i] = &(data[cols * i]); } else for(i=0; i<rows; i++) { array[i] = malloc(cols * sizeof(float)); assert(array[i] && "can't allocate memory"); } return array; } here results when compiling -march=native -ofast (tried gcc , clang): michael@pascal:~/nn$ time ./test 300 1 0 multiplying (100000, 1000) , (300, 1000) arrays 1 times, noncontiguous memory allocation. allocati

php - What happens to inserted records when a model function returns before it reaches to rollback or complete? -

i trying test transaction management in codeigniter. below method function in model class. if update_user_company_id method returns false, wrapper method save_user_and_company returns. in case, because method returns before reaches $this->db->trans_complete(); call, changes made save_company , delete_company_requests methods rolled back. want. but want learn instead of calling $this->db->rollback(); i directly return method. approach safe? there possibility may encounter lock or other problem in future? function save_user_and_company($user, $company_request) { $result[statu] = error; $this->db->trans_start(); $company = $this->companies_dao->save_company($company_request->company_name, $user->id); if (!$company) { $result[message] = company_save_error; return $result; } $company_request_result = $this->company_requests_model->delete_company_requests($company_request->id); if (!$c

python - numpy: is there an `allclose(np.array, scalar)`? -

in numpy can use allclose(x, y) function check element-wise approximate equality between 2 arrays. moreover, expression x==5 can check element-wise equality between array , scalar. is there function combines both functionalities?? is, can compare array , scalar approximate element-wise equality?? the term array or array-like in numpy documentation indicates input converted array np.asarray(in_arg) or np.asanyarray(in_arg) . if input scalar converted scalar array: >>> import numpy np >>> np.asarray(5) # or np.asanyarray array(5) and functions np.allclose or np.isclose element-wise comparison no matter if second argument scalar array, array same shape or array correctly broadcasts first array: >>> import numpy np >>> arr = np.array([1,2,1,0,1.00001,0.9999999]) >>> np.allclose(arr, 1) false >>> np.isclose(arr, 1) array([ true, false, true, false, true, true], dtype=bool) >>> np.isclose(arr, n

emacs - add a hook in prog-mode except a particular mode -

i have function (defun a--before-test-save-hook() "test of before save hook" (message "foobar")) and want run in prog-mode except python-mode , have no clue , add-hook in prog-mode including python-mode (add-hook 'prog-mode (lambda () (add-hook 'before-save-hook 'a-test-before-save-hook t t))) i have try (defun a-test-before-save-hook() "test of before save hook" (unless (eq major-mode 'python-mode) (message "foobar"))) but want better try,any solution appreciated. not sure if it's better, do: (add-hook 'prog-mode-hook (lambda () (unless (derived-mode-p 'python-mode) (add-hook 'before-save-hook #'a-test-before-save-hook t t)))) of course, own reflex ask "what makes python special?". answer might let replace (derived-mode-p 'python-mode) test goes more directly @ heart of

sql - Sequelize BelongsToMany with custom join table primary key -

i have many-to-many-relationship join table in middle. tables cookoff, participant, , cookoffparticipant. should mention not allowing sequelize create or modify tables, mapping existing relationships. need understanding relationship options tells sequelize call foreign key relates join table main table. as understand it, sequelize assumes cookoffid , participantid composite primary key on cookoffparticipant. in situation, require primary key identity column i'm calling cookoffparticipantid , creating unique index on cookoffid, participantid pair in cookoffparticipant table. when attempt cookoff , participant data querying through cookoffparticipant table, sequelize using wrong key accomplish join. there must simple not doing. below table structure , query results. cookoff table var cookoff = sequelize.define("cookoff", { // table columns cookoffid: { type: datatypes.integer, primarykey: true, autoincrement: true }, tit

python - Code runs while unit testing -

i'm trying unit test minesweeper game made in python. starting small 1 test on 1 definition, runs entire code of should testing minor part. unit testing code: import unittest minesweeper import setupgrid class testmyfunctions(unittest.testcase): def test_setup(self): self.asserttrue(setupgrid(9, [], 10)) if __name__ == '__main__' : unittest.main(exit=false) and function should checking: import random, re, time string import ascii_lowercase def setupgrid(gridsize, start, numberofmines): emptygrid = [['0' in range(gridsize)] in range(gridsize)] mines = getmines(emptygrid, start, numberofmines) i, j in mines: emptygrid[i][j] = 'x' grid = getnumbers(emptygrid) return (grid, mines) the default values emptygrid , numberofmines are, respectively, 9 , 10 , value start should empty, hence [].

android - List item is not visible in fragment -

Image
i developing music app. following code of songs list. when run app, music artworks showing. other information album name, duration not showing in listview . public class songs_list extends fragment { // adapter exposes data cursor listview widget. private songs_list.mediacursoradapter mediaadapter = null; private string currentfile=""; private boolean isstarted = true; private textview selelctedfile = null; private view v=null; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // use cursor data external resource cursor cursor = getactivity().getcontentresolver().query(mediastore.audio.media.external_content_uri, null, null, null, null); // check cursor has data or not if (null != cursor) { cursor.movetofirst(); mediaadapter = new mediacursoradapter(getactivity().getapplicationcontext(), r.layout.list_layout, cursor); v=inflater.inflate(

excel - VBA Loop Send Email With Attachment Using IBM Notes? -

i have workbook so: column g column w file1.xls recipient1@email.com file2.xls recipient2@email.com i want send email using ibm notes each recipient in list in column w. the same email can sent each recipient, email needs addressed each recipient separately. in addition, want attach each of corresponding files each email. i.e. email sent recipient 1 have file 1 attached etc. here code: sub email() 'for tips see: http://www.rondebruin.nl/win/winmail/outlook/tips.htm 'working in office 2000-2016 'variables dim cell range application.screenupdating = false dim maildb object dim maildoc object dim body object dim session object 'start session of lotus notes set session = createobject("lotus.notessession") 'this line prompts password of current id noted in notes.ini call session.initialize("perry2011") 'open mail database of lotus notes set maildb = session.getdatabase("", "c:\user

c# - GZIP in .net core not working -

Image
i'm attempting add gzip middleware asp.net core app. i have added following package : "microsoft.aspnetcore.responsecompression": "1.0.0" in startup.cs configure services method have following : public void configureservices(iservicecollection services) { services.configure<gzipcompressionprovideroptions>(options => options.level = compressionlevel.fastest); services.addresponsecompression(options => { options.providers.add<gzipcompressionprovider>(); }); services.addmvc(); } in configure method have following : public void configure(iapplicationbuilder app, ihostingenvironment env, iloggerfactory loggerfactory) { loggerfactory.addconsole(configuration.getsection("logging")); loggerfactory.adddebug(); app.useresponsecompression(); app.usemvc(); } however when try , load page, doesn't come through gzip compressed. have used both string response , outputting view. r

Run scala script from shell script -

i have scala project contains both scala classes/objects scripts. trying run scripts (that use classes/objects perform various actions) command line. way looking create shell passed argument name of script, arguments script takes. my folder structure follows: runner.sh -> script trying implement run scala scripts bin/ -> script trying implement run scala scripts lib/ -> -> rest of scala project, packed multiple jars i creating variable lib_classpath in shell script contains contents of lib/ folder , trying run scrips follows: java -cp $lib_classpath ./bin/<name_of_script.scala> <parameters of script> i same error: could not find or load main class: ..lib/<name of jar> -- <name of jar> first jar in lib/ folder i use guidance :) thanks you can use ammonite (written @lihaoyi). it's combination of better scala repl, shell, ops library, , script runner . see docs here - http://www.lihaoyi.com/ammonite/ 10 min talk

split - How to spilt a txt file into many smaller files by titles in linux -

i have large txt file contains hundreds of news articles, want spilt in several smaller txt files titles. can let me know how please? use split command split. $ split --help usage: split [option]... [input [prefix]] output fixed-size pieces of input prefixaa, prefixab, ...; default size 1000 lines, , default prefix `x'. no input, or when input -, read standard input. mandatory arguments long options mandatory short options too. -a, --suffix-length=n use suffixes of length n (default 2) -b, --bytes=size put size bytes per output file -c, --line-bytes=size put @ size bytes of lines per output file -d, --numeric-suffixes use numeric suffixes instead of alphabetic -l, --lines=number put number lines per output file --verbose print diagnostic before each output file opened --help display , exit --version output version information , exit size may (or may integer optionally follow

class - (C++)Syntax for instantiating and assigning new objects to 2D vector of pointers to same object type? -

my sincerest apologies if question has been asked, other answers have seen confusing me. have class want use build 2d matrix of type of object. i'm trying write method create new objects, , assign pointers in 2d vector new objects, can't seem syntax right. i create 2d vector this: std::vector<std::vector<csinusoid*>> *m_sinematrix; //2d vector of pointers csinusoid objects and try create method along these lines: void cwavematrix::init_sinematrix(int x, int y) { m_sinematrix[x][y] = new csinusoid(); } the line of code inside function i'm having trouble. don't know how tell specific pointer in 2d vector point new object. note both vector , method private members of same class. i think problem here: std::vector<std::vector<csinusoid*>> *m_sinematrix m_sinematrix isn't 2d vector of csinusoid pointers... it's pointer such vector. , c++ [] operator works on raw pointers vectors. code in function call [x]

c - Why my pipe ends only when i send a SIGINT -

basicaly, im writing shell in c.. im trying implement pipe feature, done: > ls | cat -e | wc | wc -l > 1 but have problem when trying pipe more slower/longer execution. indeed, when try pipe result of 'cat /dev/urandom', basicly waits... > cat /dev/urandom | cat > but, when send sigint (with ctrl + c) stop it, prints on stdout resulted buffer.. when ctrl + c , cat /dev/urandom so question is: should looking @ try fix ? parts of pipe execution: int exec_apipe(t_me *me, t_node *curs, int is_last) { int pfd[2]; int pid; if (pipe(pfd) == -1 || !curs) return (0); if (!(curs->pid = fork())) { dup2(me->fd_in, 0); me->fd_in > 0 ? close(me->fd_in) : 0; if (!is_last) dup2(pfd[1], 1); else if (curs->parent->parent && curs->parent->parent->fd_out >= 0) dup2(curs->parent->parent->fd_out, 1); c

vb.net - SolidWorks API, Macro working in VSTA but not from dll -

really appreciate can spend couple of minutes me out, in advance ! got myself situation running macro in vsta works (vb.net) , running dll files solid works not work. forgetting simple. principle text file in same folder dll files , default read folder without long location "string" this works in vsta , after building dll (very simple) partial class solidworksmacro public sub main() dim model modeldoc2 = swapp.activedoc dim layername string = "stamp" msgbox(layername) end sub public swapp sldworks end class no want same thing in way layer name read text file. works when running vsta , after building dll , running solid works gives error: cannot open "location"\macro.dll. partial class solidworksmacro public sub main() dim model modeldoc2 = swapp.activedoc dim layername string = "stamp" dim filename string = "layername.txt" dim layername string

android - how to insert navigation drawer and button inside AutoCompleteTextView -

Image
basically want insert navigation drawer , button inside autocompletetextview search text in google map. how do ? thank much. first need define layout (the searchbox), have imageview . can add onclicklistener() open navigationdrawer . you combine this: add search toolbar on google map in native android app

c# - Store in a variable the number of rows from a table where a column has a certain value in SQL Server Compact -

i have windows forms application , sql server compact 3.5 database. want store in variable number of rows table column has value. have count rows table: carsdataset carsdata = new carsdataset(); int nrcars = carsdata.carname.rows.count; how can information need? first you'll want write sql command returns number of rows in query (using count(*) operator). clause of sql statement can filter specific cars want (e.g. model = 'ford') string sql = "select count(*) cars somecolumn='{put_your_filter_here}'"; now create sqlcommand object execute on sqlceconnection. you'll need open sqlceconnection local sql compact edition database. sqlcecommand cmd = new sqlcecommand(sql, dbconnection.ceconnection); execute command returns count(*) number of rows , stores in cars variable int cars = (int)cmd.executescalar(); use/print result of query console.writeline("number of cars: " + cars);

list - Tree: Optional number of subtress -

i have data structure in haskell lets me build tree. data multtree b = datanode b | indexnode int int (multtree b) (multtree b) (multtree b) deriving (show) in case possible have indexnode needs 3 multtree's parameters. how can make indexnode able receive 0, 1, 2 or 3 multtree's ? implementing indexnode different number of parameters not seem work. so in end create tree that: t2 :: multtree int t2 = indexnode 3 42 (indexnode 3 15 (3) (11) (12)) (indexnode 19 42 (42) (23)) define own type containing 0 3 things: data from0to3 = 0 | 1 | 2 a | 3 a deriving (show) data multtree b = datanode b | indexnode int int (from0to3 (multtree b)) deriving (show) t2 :: multtree int t2 = indexnode 3 42 (two (indexnode 3 15 (three (datanode 3) (datanode 11) (datanode 12))) (indexnode 19 42 (two (datanode 42) (datanode 23)))) as requested, here's how dissect such tree. instance, following computes height of tree

jsf 2.2 - Implement callback method in JSF composite component -

i'd implement "callback" feature in composite component. method called backing component when necessary. the xhtml part is: <cc:interface componenttype="partnerselcomp"> <cc:attribute name="value" type="com.app.data.partner"/> <cc:attribute name="callback" method-signature="void notify(java.lang.long)"/> </cc:interface> <cc:implementation> <span id="#{cc.clientid}"> <p:inputtext id="code" binding="#{cc.partnercode}"> <p:ajax event="blur" update="code name msg" listener="#{cc.validate}" /> </p:inputtext> <p:outputlabel id ="name"

javascript - Send data out of visible form only -

i have 2 divs containing same input fields. when enter vales in both div fields, values submitted. want is, value of selected div (using radio button) should pass. appreciated :-) $(document).ready(function() { console.log('called'); $('input[type=radio][name=cancel_policy]').change(function() { if (this.value == '0') { $("#fixedpolicydiv").css("display", "block"); $("#percentagepolicydiv").css("display", "none"); $("#percentagepolicydiv").get(0).reset(); } else if (this.value == '1') { $("#fixedpolicydiv").css("display", "none"); $("#fixedpolicydiv").get(0).reset(); $("#percentagepolicydiv").css("display", "block"); } }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></scrip

angularjs - variable inside service change value and bind to controller -

using angular have created service signalr.service("signalrservice", function signalrservice() { var signalrconfig = { hub: $.connection.hub, platformhub: $.connection.platformhub, tryingtoreconnect: false, firstconnection: true, state: 'notconnected' } signalrconfig.hub.url = 'http://localhost:80/signalr'; signalrconfig.hub.logging = true; var starthub = function ($rootscope) { settimeout(function () { $rootscope.$apply(function () { signalrconfig.state = 'connected'; console.log('jhtfr') }); }, 5000); } return { starthub: starthub, getstate: function () { return signalrconfig.state; } } }) on singalr app, have part of code, signalr.run(['$rootscope', '$state', '$templatecache', '$http', 'signalrservice', function ($rootscope, $state, $templatecache, $http, signalrservice) { $rootscope.$state = $st

php - Relationship query orWhere overwrites other wheres -

case survey based on few questions returns x amount of apartments based on results. an apartment can have static price ( price ), or price range ( price_min , price_max ) - not apartments have static price yet being defined price range (for example 900-1000 monthly rent) problem without orwhere([['price_min', '!=', null], ['price_max', '!=', null], ['price_min', '<', '900']] works fine. apartments past where conditions being returned; although when orwhere condition being added all apartments price range (so no price ) being returned, no matter previous conditions such floor or sun code $selectedtype = type::where('slug', '=', $slug)->where('type', '=', 'studio')->with(['apartments' => function ($query) use ($request) { $query->where('status', '!=', 'sold'); if ($request->floor == 'low') {

javascript - Can MongoDB aggregation query other documents? In other words: recursive search in mongodb's side, not client's -

in mongodb aggregation pattern can work on many documents , aggregate them in new data structures sorting, filtering, removing , adding elements, in order produce new documents retrieved query. suppose, example, need find meaning of word in dictionary. if find word 'horse' in dictionary, i'll this: 'horse animal'. then, i'd know animal is, search again in dictionary meaning of 'animal'. if in like, python, i'd have find meaning of 'dog', wait arrive, read , extract word animal. i'd have query meaning of 'animal', wait arrive, , on... is there way delegate recursive task entirely mongodb, don't need query , wait each word? thought 'aggregate' solve, seems can map documents query new documents, not query data new ones mongo db aggregation framework works in steps. first select data collection , apply group, match, project, sort etc., on selected data set. data transformed based on operation applied on

arrays - How to use more than one dynamic allocation on C programming? -

i'm making program reads 2 sets of data (float) 2 different .txt files, , transfers these data 2 different arrays, used in further calculations. however, when try use dynamic allocation more once, goes wrong , data seem not stored in array. the following simplified program seems working fine: #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { float *vara; int n = 0; int *counter; int i; file *input1; input1 = fopen("c:\\users\\...test.txt","r"); vara = (float*)calloc(20001, sizeof(float)); for(i = 0; < 20001; i++) { fscanf(input1,"%f",&vara[i]); printf("%f\n",vara[i]); } free(vara); fclose(input1); return 0; } it shows data stored in array vara. however, if introduce new array count number of lines in file (which necessary further calculations), value 0.000000 every array element: #include <stdio.h> #include

excel - Follow-Up to VBA inheritance via construction, constructor not working? -

this follow-up this question. here's use case: want compare 2 excel files cell-by-cell , highlight cells different. each file have few sheets , each sheet have few columns, each header , few values (as typical). here draft activity diagram comparison code: activity diagram and here draft class diagram: class diagram my goal make vba less cumbersome types of things (such comparing new , old versions of spreadsheets). is, want work more python... in particular, want write code this: for each sheet1 in file1 name1 = sheet1.name if file2.sheet_dict.exists(name1) sheet2 = file1.sheets(file2.sheet_dict(name1)) sheet2.checked = true each col1 in sheet1.cols hdr = col1.header if sheet2.header_dict.exists(hdr) col2 = sheet2.cols(sheet2.header_dict(hdr)) col2.checked = true each val1 in col1.vals val2 = col2.vals(val1.row_number)

php - Can't find images over https -

i'm having question. i'm trying service webshop on https (using letsencrypt). i've added following in .htaccess file direct traffic on https: # https http. rewriteengine on rewritebase / rewritecond %{https} !on rewriterule (.*) https://www.domain.nl%{request_uri} [l,r=301] i'm using apache2 on ubuntu 16.04 server. have folder in root /domain_files/uploads 301's /var/www/domain/uploads/ now images not available anymore on https : https://www.domain.nl/uploads/profilepictures/mxy6x2r8t4u_facebook_profilepic.jpg http : http://www.domain.nl/uploads/profilepictures/mxy6x2r8t4u_facebook_profilepic.jpg i think following code helpful you. got solution using this. <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{https} off rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301] </ifmodule>

git - Error using Visual Studio, Xamarin Project with GitHub repo -

ok i'm using: mac, sierra visual studio community 7.0.1 (build 24) new github private repo initialized .gitignore file , readme.md file when creating project, i've kept "using git project" unchecked . attempted "publish version control" i following error "cannot push because reference trying update on remote contains commits not present locally". so did "update" , tried "pushing".... seems hang @ point. note when entire process on again without files in fresh repo works fine , can initial add , commit along subsequent commits (everything works fine). of course new project. doing wrong connecting visual studio/xamarin project existing github repo files in project already? thank in advance.

Python recursive function call with if statement -

i have question regarding function-calls using if-statements , recursion. bit confused because python seems jump if statements block if function returns "false" here example: 1 def function_1(#param): 2 if function_2(#param): 3 #do 4 if x<y: 5 function_1(#different parameters) 6 if x>y: 7 function_1(#different parameters) my function_2 returns "false" python continues code on line 5 example. can explain behavior? in advance answers. edit: sorry, forgot brackets concrete example: 1 def findexit(field, x, y, step): 2 if(isfieldfree(field, x, y)): 3 field[y][x] = filledmarker 4 findexit(field, x + 1, y, step+1) 5 findexit(field, x - 1, y, step+1) 6 findexit(field, x, y + 1, step+1) 7 findexit(field, x, y - 1, step+1) 8 elif(isfieldescape(field, x, y)): 9 way.append(copy.deepcopy(field)) 10

ios - Why is my UIView drawing behind my other views? -

Image
i have uiview opened , closed button onscreen. positioning on scrollable custom text area bunch of uilabels added uiscrollview. i've made sure added last in view hierarchy, in xib. have tried calling bringsubviewtofront , , have removed uiview parent view , re-added after doing layout. nothing have tried prevents being drawn behind uiscrollview. have verified uiview last uiview in hierarchy looking @ view hierarchy in debugger @ runtime. the uiview in question, shown smiley in picture here, has children. has 3x3 grid of invisible uibuttons, , uiimageview draw image, other smiley. operating on parent uiview, not children. is there can try, diagnose this? recap, have done following: the uiview added last in view hierarchy, after uiscrollview. child of same parent (the root view) scroll view - hence, sibling view of scroll view. after doing layout, i've tried [self.view bringsubviewtofront:myview] after doing layout, i've tried doing [myview removefro

python - pandas find two rolling max highs and calculate slope -

Image
i'm looking way find 2 max highs in rolling frame , calculate slope extrapolate possible third high. i have several problems :) a) how find second high? b) how know position of 2 highs (for simple slope : slope = (maxhigh2-maxhigh1)/(posmaxhigh2-posmaxhigh1))? i could, of course, this. work if high1 > high2 :) , not have highs of same range. import quandl import pandas pd import numpy np import sys df = quandl.get("wiki/googl") df = df.ix[:10, ['high', 'close' ]] df['max_high_3p'] = df['high'].rolling(window=3,center=false).max() df['max_high_5p'] = df['high'].rolling(window=5,center=false).max() df['slope'] = (df['max_high_5p']-df['max_high_3p'])/(5-3) print(df.head(20).to_string()) sorry bit messy solution hope helps: first define function takes input numpy array, checks if @ least 2 elements not null, , calculates slope (according formula - think), looks this: def

contactless smartcard - emv tag 0x9F37 unpredictable numbers length -

Image
i have noticed in of cases in emv transactions, tag 9f37(tag_unpredictable_number) length not 4 bytes, read tag cannot set it. please explain me must 4 bytes or can of length upto 4 bytes. , please guide me how number generated , can cause length. as name denotes should not predictable means , can use random number generation algorithm create value whether developing card application or terminal app explained below. unpredictable number used during offline enciphered pin verification ensure pin block generated different @ times. generated chip , length 8 bytes(image 1). unpredictable number not see @ host , need tool fime smartspy or keolab nomadlab value. another unpredictable number generated terminal used in cryptogram generation ensuring different cryptogram generated every time when other cdol elements same. length 4 bytes(image 2) image 2

objective c - Why atomic and nonatomic concept has removed from swift -

there no nonatomic keyword in swift, why nonatomic not required in swift exist in objective c. in swift nonatomic default (and only) choice, not required, unlike objective-c atomic default not desired behaviour. as why swift not offer atomic , well, guess has not been seen necessary feature language designers. of course can implement atomic properties synchronisation, mutexes, semaphores, etc. these solutions more verbose, allow making thread-safe class, unlike making properties atomic in objective-c.

uitextview - Correct way to dismiss keyboard from a TextView in Nativescript -

i have following textview: <textview id="textfieldbody" hint="some hint" text="{{ }}" editable="true" class="textfield" returnkeytype="done" /> i'm trying correctly implement that: when user presses "done", keyboard disappears when user touches outside (blur) of textview, keyboard disappears maybe when focus on textview, scroll rest of view doesn't disappear behind keyboard? (not sure yet one) it's unclear me how achieve that. kind of backend code need implement? ideally, i'm looking solution works both ios , android. when user press done, keyboard disappears for one, can put listener textview triggered when user press done button. had @ nativescript api , listener applied textfield, can give textview try: in xml: <textfield returnpress="donetap"/> in .js file: function donetap(args) { var mytextfield = args.object; mytextfield.dismi

android - Cannot invoke method hasAnnotation() on null object -

i'm trying upgrade realm database 0.86 2.1 version. but facing error along android studio error:execution failed task ':app:transformclasseswithrealmtransformerfordebug'. > cannot invoke method hasannotation() on null object update (3) clean assemble --stacktrace --info starting build creating configuration compile creating configuration apk creating configuration provided creating configuration wearapp creating configuration annotationprocessor creating configuration androidtestcompile creating configuration androidtestapk creating configuration androidtestprovided creating configuration androidtestwearapp creating configuration androidtestannotationprocessor creating configuration testcompile creating configuration testapk creating configuration testprovided creating configuration testwearapp creating configuration testannotationprocessor crea

javascript - How to search group words in div panel -

i made fiddle show want. have multiple panels words inside them. each word inside panel separated <br> . i have make filter , hide panel not match words on search bar. example : if type hamburger banana in search bar have show first panel , hide other. if type banana hamburger eggs show nothing. do know javascript library or jquery way ? seen fusejs.io make want see it's made search inside json. here html : <div class="row" style="margin-top: 20px;margin-bottom: 20px;"> <div class="col-md-12"> <input type="text" class="form-control" placeholder="search..." /> </div> </div> <div class="row"> <!-- first panel --> <div class="col-sm-6"> <div class="panel panel-default" style="min-height: 150px;"> <div class="panel-body"> banana<br> hamburger<br>

excel - Remove text from Cell if specific words show in another coumn -

i'm hoping simple 1 it's stumped me morning. i have spreadsheet in column has verbatim customers. in each cell of column there more 1 word. what want filter column , rows removes words found in column b , outputs left on words in column c. i thought using formula =substitute(a2,"this","") can't seem search column words , don't want have write each word individually within formula. any appreciated. thanks your formula close solving situation if understand request properly. attempt solution using formula in blank column: =substitute(trim(a1),trim(b1),"",1) and fill down far column b goes. copy, paste special values column a. i not sure mean "left over" words. if mean words "left over" after applying formula column a, put =a1 c1, copy down. again, not sure if understand problem correctly. if not, others surely post excellent answer.