Skip to content

Instantly share code, notes, and snippets.

@finico
finico / dateParserJSON.js
Created October 21, 2015 12:24
JSON date parser
function dateParser(key, value) {
if (typeof value === 'string') {
var matched = /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)$/.exec(value);
if (matched) {
return new Date(value);
}
if (!JSON.parseMsAjaxDate) {
return value;
@finico
finico / closest.shim.js
Created October 20, 2015 20:14
closest shim
(function (elProto) {
if (elProto.hasOwnProperty('closest')) {
return;
}
elProto.matches = elProto.matches || elProto.webkitMatchesSelector || elProto.mozMatchesSelector || elProto.msMatchesSelector || elProto.oMatchesSelector;
elProto.closest = function closest (selector) {
var element = this;
@finico
finico / apt-key
Created July 6, 2015 09:13
GPG error: http://ppa.launchpad.net trusty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY $KEY$
sudo apt-key adv --keyserver-options http-proxy="http://user:password@host:port" --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $KEY$
@finico
finico / site.conf
Last active August 29, 2015 14:15 — forked from paskal/site.conf
# read more at https://terrty.net/2014/ssl-tls-in-nginx/
# latest version on https://gist.github.com/paskal/628882bee1948ef126dd/126e4d1daeb5244aacbbd847c5247c2e293f6adf
# security test score: https://www.ssllabs.com/ssltest/analyze.html?d=terrty.net
# your nginx version might not have all directives included, test this configuration before using in production against your nginx:
# $ nginx -c /etc/nginx/nginx.conf -t
server {
# public key, contains your public key and class 1 certificate, to create:
# (example for startssl)
# $ (cat example.com.pem & wget -O - https://www.startssl.com/certs/class1/sha2/pem/sub.class1.server.sha2.ca.pem) | tee -a /etc/nginx/ssl/domain.pem > /dev/null
@finico
finico / sudoers
Created March 4, 2014 07:57
sudo: нет tty и не указана программа askpass (sudo: no tty present and no asppass program specified)
# добавить в (add in file) /etc/sudoers
Defaults visiblepw