Posts

javascript - HTML5 Pattern fallback for Safari -

safari not support html5 pattern... input pattern below works fine in need of workable fall back. <input type="password" required pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\w+))(?![.\n])(?=.*[a-z])(?=.*[a-z]).*$" name="password" id="password"> fallback attempt... (from answer dated 2011) var input = document.getelementsbyname('password')[0]; input.addeventlistener('change', function() { console.log('is valid?', input.value.search(new regexp(input.getattribute('pattern'))) !== -1); }, false); the problem event you're listening to. event change same blur in case. change event listen keyup or input : input.addeventlistener('input', function() { console.log('is valid?', input.value.search(new regexp(input.getattribute('pattern'))) !== -1); }, false);

Scala macros referring to a member type -

i have trait member type, , want have macro signature containing type: trait foo { class bar[a] { ... } def baz[a](x: bar[a]): bar[a] = macro bazimpl[a] def bazimpl[a: c.weaktypetag](c: blackbox.context)(x: c.expr[bar[a]]) = ... } this doesn't work, since bazimpl must belong either static (i.e. non-member) object or macro bundle. in neither case have foo: foo write foo.bar[a] . one workaround can think of use foo#bar[a] , add casts: trait foo { class bar[a] { ... } def baz[a](x: bar[a]): bar[a] = foo.baz1(x).asinstanceof[bar[a]] def bazimpl[a: c.weaktypetag](c: blackbox.context)(x: c.expr[bar[a]]) = ... } object foo { def baz1[a](x: foo#bar[a]): foo#bar[a] = macro bazimpl[a] def bazimpl[a: c.weaktypetag](c: blackbox.context)(x: c.expr[foo#bar[a]]): c.expr[foo#bar[a]] = ... } but i'd avoid (both because it's not type-safe , because real case more complicated). alternatives? if you're using scala 2.11, write c.tree everyw...

pip - Installing psycopg2 into virtualenv when PostgreSQL is not installed on development system -

is possible install psycopg2 virtualenv when postgresql isn't installed on development system—macbook pro os x 10.6? when run pip install psycopg2 within virtualenv , received error shown below. i'm trying connect legacy database on server using django, , i'd prefer not install postgresql on development system if possible. why not install postgresql? i received error when installing postgresql using homebrew. have xcode4—and xcode4—installed on macbook pro , thinking it's related missing gcc 4.0. however, problem stackoverflow question. update 8:37 on april 12, 2011: i'd still know if possible without installing postgresql on macbook pro. however, ran brew update , forced reinstallation of ossp-uuid brew install --force ossp-uuid , brew install postgresql works. postgresql installed, able pip install psycopg2 within virtualenv. error pip install psycopg2 $ pip install psycopg2 downloading/unpacking psycopg2 running setup.py egg_info packa...

python - Using a context processor in conjunction with Jinja template variables -

i in midst of deploying stripe , requires that payment values being passed stated in "cents" rather dollars. can handle on backend (i.e can process payment appropriate amount) in order render in stripe's ui, must convert price cents. ($400 becomes 40000 cents) i attempting use context processor convert dollar price store in database dollars can following code in views.py file: @buy_blueprint.context_processor def utility_processor(): def format_price(amount): return u'{0:.0f}'.format(amount) return dict(format_price=format_price) and following inserted in template.html file course price: {{ format_price(40000) }} which renders 40000 - perfect. but want like: {% course in courses %} <p> course name: {{ course.course_name }} course price: {{ course.price }} max number of students: {{ course.max_number_students}} remaining space: {{ course.spaces_left }} {% if course.spaces_left > 0 %} <form action="{{ url_for('buy.buy...

javascript - Error: [ngModel:datefmt] Expected `2015-05-29T19:06:16.693209Z` to be a date - Angular -

i'm working on angular application django rest-framework .. the app receives it's info json server.. 1 of keys created_time ... value of field format according iso-8601 , example 2015-05-29t19:06:16.693209z . in client have field: <input type="time" ng-model="created_time"> but when data arriving error: error: [ngmodel:datefmt] expected `2015-05-29t19:06:16.693209z` date http://errors.angularjs.org/1.3.13/ngmodel/datefmt?p0=2015-05-29t19%3a06%3a16.693209z @ regex_string_regexp (angular.js:63) @ array.<anonymous> (angular.js:19807) @ object.ngmodelwatch (angular.js:23289) @ scope.$get.scope.$digest (angular.js:14235) @ scope.$get.scope.$apply (angular.js:14506) @ done (angular.js:9659) @ completerequest (angular.js:9849) @ xmlhttprequest.requestloaded (angular.js:9790) i tried :( format instructions in docs of angular... this must happening angular 1.3+. 1.3+ on wards ng-model date/time input needs valid date object, stri...

c# - Disable button on a specific page -

i made web application in asp.net mvc5. in application have products. on every product logged user can press button. how can disable button after logged user pressed it. want other users able press button, not users have pressed button. i don't want save in database users have liked product because have many values in database. can give me advice how should this? @ least maybe save in session. thanks! just create simple db table called userlikes it can have 2 columns: userid , productid whenever user likes product, make entry in table. when user viewing product page, if see entry in table user , product, disable like button.

python - Output separated HBase columns using happybase -

i have such hbase-table: total date1:tcount1 date2:tcount2 ... url1 date1:clickcount1 date2:clickcount2 ... url2 date1:clickcount1 date2:clickcount2 ... ... url1, url2, ... row keys. table has only one column family. i have date range (from datei datej ) input. need output shares of clicks in day each url. the output must have such format: datei url1:share1 url2:share1... ... datej url1:share1 url2:share1... where datei.url1:share1 = url1.datei:clickcount1 / total datei:tcount1 i started write happybase-script, don't know, how select separate columns row using happybase. happybase-script below: import argparse import calendar import getpass import happybase import logging import random import sys usage = """ query daily data year, run: $ {0} --action query --year 2014 query daily data particular month, run: $ {0} --action query --year 2014 --month 10 query daily data particular day, run: $ {0} --action query --year 2014 --month 10 ...