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
| -- Collision-resistant ids optimized for horizontal scaling and performance, for PL/PgSQL. | |
| -- Based on https://github.com/ericelliott/cuid | |
| -- Version 1.0.0 | |
| -- Usage: SELECT cuid(); | |
| -- BEGIN CONFIG --- | |
| -- Put a unique host ID (int) here per server instance. | |
| -- Once set, this value should not be changed. |
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
| module 'sentiment' { | |
| interface ConstructorOptions { | |
| } | |
| interface AnalyzeOptions { | |
| extras: any; | |
| language: 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
| # Regex by Jonathan Stassen. http://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags | |
| /(?:@)([A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:\.(?!\.))){0,28}(?:[A-Za-z0-9_]))?)/g |
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
| // Iterated from: https://stackoverflow.com/questions/10599933/convert-long-number-into-abbreviated-string-in-javascript-with-a-special-shortn | |
| function abbreviateNumber(value) { | |
| let newValue = value; | |
| const suffixes = ["", "K", "M", "B","T"]; | |
| let suffixNum = 0; | |
| while (newValue >= 1000) { | |
| newValue /= 1000; | |
| suffixNum++; | |
| } |
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 firebase from 'firebase' | |
| import { filter, map } from 'lodash' | |
| import { makeExecutableSchema } from 'graphql-tools' | |
| firebase.initializeApp({ | |
| databaseURL: 'https://grafire-b1b6e.firebaseio.com', | |
| }) | |
| const mapSnapshotToEntity = snapshot => ({ id: snapshot.key, ...snapshot.val() }) | |
| const mapSnapshotToEntities = snapshot => map(snapshot.val(), (value, id) => ({ id, ...value })) |
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
| var CryptoJS = require('crypto-js'); | |
| function uploadImage(uri) { | |
| let timestamp = (Date.now() / 1000 | 0).toString(); | |
| let api_key = 'your api key' | |
| let api_secret = 'your api secret' | |
| let cloud = 'your cloud name' | |
| let hash_string = 'timestamp=' + timestamp + api_secret | |
| let signature = CryptoJS.SHA1(hash_string).toString(); | |
| let upload_url = 'https://api.cloudinary.com/v1_1/' + cloud + '/image/upload' |
While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.
Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.
lib/is intended for code that can run as-issrc/is intended for code that needs to be manipulated before it can be used
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
| // Create our server | |
| var server; | |
| server = http.createServer(function(req,res){ | |
| // Set CORS headers | |
| res.setHeader('Access-Control-Allow-Origin', '*'); | |
| res.setHeader('Access-Control-Request-Method', '*'); | |
| res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET'); | |
| res.setHeader('Access-Control-Allow-Headers', '*'); | |
| if ( req.method === 'OPTIONS' ) { | |
| res.writeHead(200); |