made with esnextbin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
import Hapi from 'hapi'; | |
import Promise from 'bluebird'; | |
const server = new Hapi.Server(); | |
server.register([ | |
require('hapi-async-handler') | |
], function(error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def formatPhone(phone): | |
formatted = '' | |
i = 0 | |
# clean phone. skip not digits | |
phone = ''.join(x for x in phone if x.isdigit()) | |
# set pattern | |
if len(phone) == 12: | |
pattern = '(XXX) XXXXX-XXXX' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
CREATE_TABLE_STATEMENT = re.compile('CREATE\s+TABLE\s+(IF\s+NOT\s+EXISTS\s+)?`?(\w+)`?\s+\(', re.I) | |
END_CREATE_TABLE_STATEMENT = re.compile('\)\s*(ENGINE\s*=\s*(\w+))?\s*;', re.I) | |
STRUCTURE_FIELD = re.compile('\s+((?!UNIQUE)(?!PRIMARY)(?!KEY)(?!INDEX)`?\w+`?.*),', re.I) | |
CONSTRAING_FIELD = re.compile('\s+(UNIQUE.*|KEY.*|INDEX.*),?', re.I) | |
EXTRACT_VARCHAR_TYPE = re.compile('`?\w+`?\s+(VARCHAR\((\d+)\))\s+', re.I) | |
EXTRACT_INT_TYPE = re.compile('`?\w+`?\s+(INT\((\d+)\))\s+', re.I) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function.prototype.partial = function() { | |
// CODE HERE | |
var fn = this, args = Array.prototype.slice.call(arguments); | |
return function() { | |
var replace = function(arr) { | |
var pos = 0; | |
return { | |
next : function() { | |
return arr[pos++]; |
made with esnextbin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const R = require('ramda'); | |
const http = require('http'); | |
const log = function() { | |
const args = [].slice.call(arguments); | |
if (R.all(v => v, args)) { | |
console.log.apply(console.log, args); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const log = function(args) { | |
args = Array.isArray(args) ? args : Array.prototype.slice.call(arguments) | |
console.log.apply(console, args); | |
}; | |
const tOut = function(time) { | |
return new Promise(function(resolve) { | |
setTimeout(() => { | |
resolve(time); | |
}, time); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [ | |
[-1, 1, -1, 0, 0, 0], | |
[ 0, -1, 0, 0, 0, 0], | |
[-1, -1, -1, 0, 0, 0], | |
[ 0, -9, 2, -4, -4, 0], | |
[-7, 0, 0, -2, 0, 0], | |
[ 0, 0, -1, -2, -4, 0] | |
]; | |
const sum = (a, b) => a + b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given a time in AM/PM format, convert it to military (2424-hour) time. | |
Note: Midnight is 12:00:00AM12:00:00AM on a 1212-hour clock, and 00:00:0000:00:00 on a 2424-hour clock. Noon is 12:00:00PM12:00:00PM on a 1212-hour clock, and 12:00:0012:00:00 on a 2424-hour clock. | |
Input Format | |
A single string containing a time in 1212-hour clock format (i.e.: hh:mm:ssAMhh:mm:ssAM or hh:mm:ssPMhh:mm:ssPM), where 01≤hh≤1201≤hh≤12. | |
Output Format |