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 jwtDecode(token) { | |
const [header, claims, signature] = token.split('.'); | |
try { | |
return JSON.parse(atob(claims)); | |
} catch (e) { | |
return false; | |
} | |
} |
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
type TAction<T: $Subtype<string>, P> = { | |
type: T, | |
payload: P, | |
}; | |
const ActionTypes = { | |
STRING: 'STRING', | |
NUMBER: 'NUMBER', | |
LOGIN: 'LOGIN', | |
LOGIN_PAGE: 'LOGIN_PAGE', |
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 ajax = (function () { | |
var getAjaxRequest = function (callback) { | |
var ajaxRequest = new XMLHttpRequest(); | |
ajaxRequest.onreadystatechange = function() { | |
if (ajaxRequest.readyState === 4) { | |
callback(ajaxRequest.responseText); | |
} | |
}; | |
return ajaxRequest; | |
}; |
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 leadingZeros = function(num, length) { | |
length = length || 2; | |
num = String(num); | |
while (num.length < length) { | |
num = "0" + num; | |
} | |
return num; | |
}; | |
var validDate = function(value) { |
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 pubsub = (function () { | |
'use strict'; | |
var observers = []; | |
return { | |
subscribe: function (events, listener) { | |
var event, i; | |
events = events.split(' '); | |
for (i in events) { | |
if (events.hasOwnProperty(i)) { | |
event = events[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
Show hidden characters
{ | |
"close_windows_when_empty": false, | |
"color_scheme": "Packages/Theme - Flatland/Flatland Monokai.tmTheme", | |
"dictionary": "Packages/Language - English/en_GB.dic", | |
"draw_white_space": "all", | |
"ensure_newline_at_eof_on_save": true, | |
"folder_exclude_patterns": | |
[ | |
".svn", | |
".git", |
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
[ | |
{ | |
"keys": ["alt+space"], | |
"command": "insert_snippet", | |
"args": { | |
"contents": " " | |
} | |
} | |
] |
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 defer = function (cb, t, ctx) { | |
t = t || 0; | |
ctx = ctx || this; | |
return function () { | |
var args = Array.prototype.slice.call(arguments); | |
setTimeout(function() { | |
cb.apply(ctx, args); | |
}, t); | |
}; | |
}; |
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 http = require('http'); | |
http.createServer(function requestHandler(clientRequest, clientRespose) { | |
clientRequest.pipe(http.request({ | |
host: 'localhost', | |
port: 3003, | |
path: clientRequest.url, | |
method: clientRequest.method, | |
headers: clientRequest.headers | |
}, function(serverResponse) { | |
clientRespose.writeHead(serverResponse.statusCode, serverResponse.headers); |
NewerOlder