Posts

Showing posts from August, 2012

css - <html> and <body> not respecting 100% height -

i've been having no-end of issues heights of late. i managed solve heights of elements flex:auto , flex-shrink:0 . i can't html , body tags play ball (visible in element inspector after scroll line.) i have html , body height specified 100% due fact homepage doesn't exceed browser window , need push footer bottom , fill space. i suspect though potentially cause of me experiencing issues when page content exceeds browser window. please advise? here current attempt: @import 'https://fonts.googleapis.com/css?family=open+sans:400,600'; a, a:hover { text-decoration: none; } html, body { height: 100%; } body { font-family: 'open sans', sans-serif; background: #fff; font-size: 16px; min-height: 100%; display: flex; flex-direction: column; } #page_wrap { display: flex; flex-direction: column; flex-shrink: 0; min-height: 100%; } header { background: #fff; text-align: center; padding: 0.62...

ruby - How to test retries and failures in resque-retry and Rails 4? -

i trying write spec tests retry functionality of resque-retry , can not seem tests hit binding.pry's correctly. there way test functionality using rspec 3 can verify functioning intended? this request spec , trying simulate live request via fixtures, no matter try can't seem job retry. gem 'resque', require: 'resque/server' gem 'resque-web', require: 'resque_web' gem 'resque-scheduler' gem 'resque-retry' gem 'resque-lock-timeout' i using resque_rspec , , trying testing strategy . partial spec it 'retries it' stub_request(:any, /.*api.bigcartel.*/).to_return(body: '{}', status: 200) @order_shipped_json['order']['originator_id'] = @provider_order post "/hook/shops/#{@shop.id}", @order_shipped_json.to_json, format: :json resquespec.perform_all(queue_name) ??? end queue job class queuehook extend resque::plugins::locktimeout extend resque::plugins::retry...

python - Throw ValueError for two digit year dates with dateutil.parser.parse -

while doing data cleaning, noticed dateutil.parser.parse failed reject malformed date, thinking first number in 2 digit year. can library forced treat 2 digit years invalid? example: from dateutil.parser import parse parse('22-23 february') outputs: datetime.datetime(2022, 2, 23, 0, 0) i managed work around passing custom dateutil.parser.parserinfo object via parserinfo parameter dateutil.parser.parse . luckily, dateutil.parser.parserinfo has convertyear method can overloaded in derived class in order perform validations on year. from dateutil.parser import parse, parserinfo class notwodigityearparserinfo(parserinfo): def convertyear(self, year, century_specified=false): if year < 100 , not century_specified: raise valueerror('two digit years not supported.') return parserinfo.convertyear(self, year, century_specified) parse('22-23 february', parserinfo = notwodigityearparserinfo()) outputs: tr...

botframework - Effective way of training the bot, language processing APIs -

i'm using microsoft bot framework build bot helps users answer questions related specific topic. have list of these questions , correct answers each question. need teach bot these answers. when user asks similar, bot should give correct answer. kind of nature language processing apis can use? know luis, , know how build own model using luis. i'm not sure can train bot in way well. give me directions regarding effective way of training bot ? thank in advance! in luis, can take advantage of 1 of model features : phrase lists, allow categorize similar words/phrase, , improve performance of training.

pycharm auto indentation settings -

i'm using pycharm 2016.2.1 , when try enter new line, doesn't insert tab in it. for example this. for x in range(5): print('hello') how can change pycharm indent? i've tried 'smart tabs', 'use tab characters' , on can't fix it. the 'use tab character' here can use tab character (\t) instead of sequence of spaces indentation. in file > settings > editor > code style > python > tabs , indents, check indent size value not zero. if so, change 4 (recommended pep8) or length want indent be. hope helps.

google maps - android.view.InflateException: Binary XML file line #8: Error inflating class fragment -

i trying make google map activity find travel distance.but unfortunately layout.xml file throw , below error , stop app. used min sdk version - 16. tried lot of thing still error remain.i run app in real device.expect expert help. 2218/? e/androidruntime: fatal exception: main java.lang.runtimeexception: unable start activity componentinfo{scpp.globaleye.com.scppclient/scpp.globaleye.com.scppclient.ui.mapsactivity}: android.view.inflateexception: binary xml file line #8: error inflating class fragment @ android.app.activitythread.performlaunchactivity(activitythread.java:2184) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2211) @ android.app.activitythread.access$600(activitythread.java:149) @ android.app.act...

php - PDO and openssl_public_decrypt failing -

i trying decrypt , update password mysql database table. while doing giving me weird error. php warning: pdo::exec(): ssl operation failed code 1. openssl error messages: error:0906d06c:pem routines:pem_read_bio:no start line in .../vendor/robmorgan/phinx/src/phinx/db/adapter/pdoadapter.php on line 306 php warning: pdo::exec(): mysql server has gone away in .../vendor/robmorgan/phinx/src/phinx/db/adapter/pdoadapter.php on line 306 php warning: pdo::exec(): error reading result set's header in ../vendor/robmorgan/phinx/src/phinx/db/adapter/pdoadapter.php on line 306 passwords encrypted using private key. openssl_private_encrypt function used encryption. decryption done using openssl_public_decrypt encryption along insertion databse works fine decryption along update not work. pdo::exec fails reason platform using ubuntu, php 5.6.24-1+deb.sury.org~xenial+1 encrypt-insert, decrypt-update order of operations. mysql connection open before encr...

laravel 5.2 - How do I create a custom class for the general restful methods, which can be extended to the controllers? -

i noticed been writing same lines of code(index, store, show, update, destroy) following controllers, except model name query data. itemscontroller, measurescontroller how extract base functions index, store, show, update, destroy class 'restfulmethods' , show how pass model 'restfulmethods' class, extending itemscontroller or measurescontroller?

angular - Angular2 Routing: what does it mean that it creates an instance of the component associated? -

i'm teaching myself angular2 , text i'm looking @ says: the router locates or creates instance of component associated route, , component’s view displayed in location defined routeroutlet directive. the code example: import { component } 'angular2/core'; import {productlistcomponent} './products/product-list.component'; import {productservice} './products/product.service'; import {http_providers} 'angular2/http'; import {router_providers, routeconfig, router_directives} 'angular2/router'; import 'rxjs/rx'; //load features import {welcomecomponent} './home/welcome.component' @component({ selector: 'pm-app', template:` <div> <nav class='navbar navbar-default'> <div class='container-fluid'> <a class='navbar-brand'>{{pagetitle}}</a> <ul class='nav navbar-nav'> ...

Android - White space below statusbar in screenshot -

Image
i'm using part of code somewhere around : private static bitmap getscreenshot(view v) { bitmap b = bitmap.createbitmap(v.getwidth(), v.getheight(), bitmap.config.argb_8888); canvas c = new canvas(b); v.draw(c); /*v.setdrawingcacheenabled(true); bitmap bitmap = bitmap.createbitmap(v.getdrawingcache()); v.setdrawingcacheenabled(false);*/ return b; } to screenshot of view. how activity's view : getwindow().getdecorview().getrootview() everytime that, gets whole screen, white space of statusbar 's height above toolbar . i'm @ lost here, please ask me info should've provided haven't. edit : forgot, use in conjunction of blurring : public static bitmap blur(context ctx, bitmap image) { final float bitmap_scale = 0.4f; final float blur_radius = 7.5f; int width = math.round(image.getwidth() * bitmap_scale); int height = math.round(image.getheight() * bitmap_scale); bitmap inputbitmap = bitmap.createscaledbi...

Linux command to count number of occurrences of a string in a specific file type within the whole dir -

i used following cmd count lines of class appears within h extension files grep -rc 'class' --include \*.h mydirc|wc -l however, think result wrong when add number of occurrence each file, it's wrong. found wc -l counting number of files searched , printed on screen. exmaple, /afs/eos/dist/ds5-2013.06/fastmodelstools_8.2/osci/syst...sc_buffer.h:6 i added number of h: up, didn't match final value. final value matches number of printed lines on sreen same number of .h extension files has searched. how about find . -name \*.h | xargs grep class | wc -l

Yii2: Omit controller ID from module route -

a typical yii2 route action in module controller follows: <moduleid>/<controllerid>/<actionid> how configure/structure our module (which has 1 controller) may reach actions directly using following route: <moduleid>/<actionid> without having override routes in main application's urlmanager ? if "without having override routes in main application's urlmanager" mean not modifying urlmanager routes think it's not possible. but if mean "without new route rules added in app's configuration file" here way: you can setting rules inside module. add module bootstrap section of configuration if it's not there yet. now in main module's file (default module.php) add: public function bootstrap($app) { if ($app instanceof \yii\web\application) { $app->urlmanager->addrules([ ['your-module/<action>' => 'your-module/controllers-name/<action...

mysql - multiple if statement in PHP form -

i have "subscribe" form on website , want check each entry database before submitting it, here form coded want complete it. form code <div class="col-lg-8 col-md-12 col-sm-12 col-xs-12"> <h1> subscribe </h1> </div> <div class="col-lg-4 col-lg-offset-2 col-md-12 col-sm-12 col-xs-12"> <form action="" method="post" class="inp_txt horizontal-form" enctype="multipart/form-data"> <?php echo $result;?> <?php echo $error1;?> <?php echo $error2;?> <?php echo $error3;?> <div class="form-group"> <label for="name"> name: </label> <input type="text" name="name" class="form-control" value="<?=(isset($name) ? $name : "")?>" placeholder="please enter name" required> </div> <div c...

javascript - Why getting an error: 'should not push route with duplicated key' with NavigationStateUtils in React Native? -

in react native + redux, have following reducer set navigation using navigationstateutils: import { push_route, pop_route } '../constants/actiontypes' import { navigationexperimental } 'react-native' import login '../components/login' const { stateutils: navigationstateutils } = navigationexperimental const initialstate = { index: 0, key: 'root', routes: [{ key: 'login', title: 'login', component: login }] } function navigationstate (state = initialstate, action) { switch(action.type) { case push_route: if (state.routes[state.index].key === (action.route && action.route.key)) return state return navigationstateutils.push(state, action.route) case pop_route: if (state.index === 0 || state.routes.length === 1) return state return navigationstateutils.pop(state) default: return state } } export default navigationstate and got button component calls on navig...

api - Serve JSON Data from Github Pages -

i have repository on github contains number of csv, json, yml data files in root directory of repository. how serve files using github pages? so eg: when go http://username.github.io/reponame/ followed by /posts - serve contents of posts.json file /users - serve contents of users.json file /comments - serve contents of comments.json file /posts.csv - serve contents of posts.csv file you need add .json files in repository , can access them normal json api in following repository username.github.io/reponame add following files posts.json [ {"id": 1, "title": "title 1"}, {"id": 2, "title": "title 2"} ] users.json [ {"name": "abc", "email": "abc@example.com"}, {"name": "xyz", "email": "xyz@example.com"} ] comments.json [ {"post_id": "1", "text": "comment 1...

php - Laravel Validation Rules -

my need laravel validation rules.i want use laravel validation check variables. , show custom errors returning string in controller.(i dont use view, blade, session,... return string) if(strlen($username) < 4) return '{"r": "us","msg": "username short"}'; if(strlen($username) > 64) return '{"r": "ul","msg": "username long"}'; if(strlen($address) > 200) return '{"r": "a","msg": "wrong address"}'; i want this: if($validation->username->min has error) return 'string:username short'; if($validation->address->max has error) return 'string:address long'; if($validation->username->unique has error) return 'string:username exists'; have @ official documentation of validation in laravel. don't have handle every case manually. validator::make() generate valida...

javascript - Reject future dates in jsp -

i have date of birth field in html form follows: date of birth <input type="date" name="dob" id="dob" onchange="agecalculation()"> in agecalculation function want reject future dates , age should not greater 8 years.the javascript is: function agecalculation(){ var currentdate = new date(); var birthdate = new date(document.getelementbyid("dob").value); var difference = currentdate - birthdate; var differenceinyears = math.floor(difference / (1000 * 60 * 60 * 24 * 365.25)); if(birthdate.after(currentdate)|| differenceinyears>8) { window.alert("age should less 8 years"); } else{ document.getelementbyid("age").value = differenceinyears ;} } however getting uncaught typeerror: birthdate.after not function at beginning of htnl form have written <%@ page import="java.util.date"%> instead of after use comp...

javascript - Nodejs Expressjs app.get interval -

i need call app.get() multiple times keep updating page. have function calls app.get every , know function writetopage() gets called app.get() gets called once. how can keep updating page app.get() or there better/alternate way achieve want. reason need content variable changes , need update page. function writetopage(content, page) { console.log('writetopage called'); app.get(`/${page}`, function (req, res) { res.send(content); console.log('content sent'); }); } app.get() registering handlers called express when client makes matching http request. not call repeatedly. can't cause browser page auto-update in manner. besides, call res.send() once on original page request. after it's been called once, page has been sent browser , work done http request. if want browser page auto-update, have these types of options: you can have browser page auto-reload every often. can done either javascript or meta refresh ta...

curl - Partial download with wget -

i see curl supports partial downloads -r, --range range retrieve bytes within range example curl -r 0-99 http://foo.com/bar.mp4 however, can wget accomplish similar? unfortunately wget doesn't have feature(at least gnu wget 1.10.2 (red hat modified) ), annoying. can send range header http request, doesn't work. wget "http://www.example.com" -c --header="range: bytes=0-99" it returns http request sent, awaiting response... 206 partial content giving up. it seemed wget had proper response, strangely, didn't finish it. example verbose mode output: http request sent, awaiting response... http/1.0 206 partial content accept-ranges: bytes cache-control: max-age=604800 content-range: bytes 0-99/1270 content-type: text/html date: fri, 24 jan 2014 08:35:18 gmt etag: "359670651" expires: fri, 31 jan 2014 08:35:18 gmt last-modified: fri, 09 aug 2013 23:54:35 gmt server: ecs (ftw/fba9) x-cache: hi...

javascript - Strange jquery 'viewport' behaviour -

i'm developing wordpress site has lot of animations effects - fade-in , fade-out on changeing tabs etc. 1 of them slideing in boxes bottom when element in viewport. i'm using script: function checkvisible() { var elm = this; var eval = eval || "visible"; var vph = $(window).height(), st = $(window).scrolltop(), y = $(elm).offset().top, elementheight = $(elm).height(); if (eval == "visible") return ((y < (vph + st)) && (y > (st - elementheight))); } $(window).scroll(function(){ $('.module').filter(checkvisible).addclass('come-in'); }); $( document ).ready(function() { $('.module').filter(checkvisible).addclass('come-in'); }); it's not mine, found smowhere on stackoverflow. problem is, worked while, after time started act strange: on subpages adds 'come in' class without checking if 'module' in viewport or not. , on 'post' pag...

javascript - Stretch navigation bar to full width using uikit -

i know can done if navigation bar used basic html. how can navbar stretched full width using uikit ? navbar code : <nav class="uk-navbar"> <a href="#" class="uk-navbar-brand">web</a> <ul class="uk-navbar-nav"> <li><a href="">home</a></li> <li><a href="">contact us</a></li> </ul> </nav> i've reproduced example , it's working fine: http://codepen.io/untmat/pen/jkgzlw <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.26.4/css/uikit.min.css" /> <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.26.4/css/uikit.min.css"></script> <nav class="uk-navbar"> <a href="#" class=...

javascript - Count the number of same values in array -

i have data in database below vm.result = [ { "_id": objectid("57c036a75f7635e80c5d5bc8"), "sharedpersonid": objectid("570dec75cf30bf4c09679deb"), "notificationdetails": [ { "userid": "570dfae0e79bd384255b6471", "username": "vinay", "isred": true } ] }, { "_id": objectid("57bef418600b4350280f0b2f"), "sharedpersonid": objectid("570dec75cf30bf4c09679deb"), "notificationdetails": [ { "userid": "56fe44836ce2226431f5388f", "username": "hemanth", "isred": true } ] }, { "_id": objectid("57bef1a1d985a82c24e0c49b"), "sharedpersonid": objectid("570dec75cf30bf4c09679deb"), "notificationdetails": [ { "userid": "57443657ee5b5ccc30c4e6f8...