This file contains hidden or 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
class SessionFileStore < ActionDispatch::Session::AbstractStore | |
def get_session(env, sid) | |
sid ||= generate_sid | |
session = Marshal.load(IO.binread(tmp_file(sid))) rescue nil | |
[sid, session.presence || {}] | |
end | |
def set_session(env, sid, session, options) | |
Dir.mkdir(sessions_path) unless Dir.exist? sessions_path | |
IO.binwrite(tmp_file(sid), Marshal.dump(session)) |
This file contains hidden or 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 blackList = [ | |
"00000000000", | |
"11111111111", | |
"22222222222", | |
"33333333333", | |
"44444444444", | |
"55555555555", | |
"66666666666", |
This file contains hidden or 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 graphQLFragments = (fragments = {}) => req => { | |
const uniq = list => list.filter(value => list.indexOf(value) == list.lastIndexOf(value)); | |
const hasFragment = graphQL => graphQL.match(/\.{3}\s*([A-Za-z0-9\_]+)/g) != null; | |
const findFragments = graphQL => | |
graphQL | |
.match(/\.{3}\s*([A-Za-z0-9\_]+)/g) | |
.map(fragment => fragment.trim().replace(/^\.{3}/, "")) | |
.filter(fragment => fragment.match(/\s+on\s+/) == null) | |
.map(fragment => { | |
if (fragment in fragments) { |
This file contains hidden or 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 fs = require("fs"); | |
const path = require("path"); | |
const promisify = fn => (...args) => | |
new Promise((resolve, reject) => | |
fn(...args, (err, res) => err === null ? resolve(res) : reject(err)) | |
); | |
const mkdir = promisify(fs.mkdir); | |
const stat = promisify(fs.stat); |
This file contains hidden or 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 React, { | |
Component, | |
PropTypes, | |
} from "react"; | |
import { | |
Animated, | |
View, | |
} from "react-native"; |
This file contains hidden or 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 { curry, splitEvery } = require("ramda"); | |
const batchMap = curry((batchSize, fn, list) => | |
splitEvery(batchSize, list) | |
.map(batch => all => Promise.all(batch.map(fn)).then(res => all.concat(res))) | |
.reduce((results, batch) => results.then(batch), Promise.resolve([])) | |
); | |
module.exports = batchMap; |
This file contains hidden or 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
// @flow | |
import { | |
always, | |
memoize, | |
pick, | |
} from "ramda"; | |
type ParsedURL = { | |
protocol: string, |
This file contains hidden or 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 http = require("http"); | |
const path = require("path"); | |
const target = process.env.TARGET; // ex: google.com | |
const port = process.env.PORT || 80; | |
http | |
.createServer(({ url, headers }, res) => { | |
const protocol = headers["x-forwarded-proto"] || "http"; | |
res.writeHead(308, { Location: `${protocol}://${path.join(target, url)}` }); |
This file contains hidden or 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 { h1, div, p } from "./html"; | |
div([ | |
h1({ class: "title" }, "Title"), | |
p("A nice text"), | |
]); |
This file contains hidden or 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 http = require("http"); | |
const { PORT, PROXY_HOST, PROXY_PORT } = process.env; | |
http | |
.createServer((req, res) => { | |
const proxyRequest = http | |
.request({ | |
hostname: PROXY_HOST, | |
port: PROXY_PORT || 80, |