Skip to content

Instantly share code, notes, and snippets.

View uptownhr's full-sized avatar

James Lee uptownhr

View GitHub Profile
@uptownhr
uptownhr / swagger.js
Last active May 9, 2016 19:15
swagger
{
"swagger": "2.0",
"info": {
"title": "Flashcards API",
"description": "Learn with flashcards API",
"version": "1.0.0"
},
"host": "api.flashcards.com",
"schemes": [
"http"
var test = new Promise( function(resolve, reject){
setTimeout( function(){
resolve('hello world')
}, 3000)
})
function anotherAsync(){
return new Promise( function(resolve){
throw new Error('testing')
setTimeout( resolve, 1000 )
@uptownhr
uptownhr / gist:82a50e9ae9e42ea4b2f16ece82cfa0ed
Created April 19, 2016 20:48
promise superagent example
function getSomething(){
return new Promise( (resolve, reject) => {
request
.post('/api/pet')
.send({ name: 'Manny', species: 'cat' })
.set('X-API-Key', 'foobar')
.set('Accept', 'application/json')
.end(function(err, res){
if(err) return reject(err);
@uptownhr
uptownhr / clipboard.js
Created April 15, 2016 02:12
copy to clipboard hack
function copy(string){
var dummy = document.createElement("input");
// Add it to the document
document.body.appendChild(dummy);
// Set its ID
dummy.setAttribute("id", "dummy_id");
// Output the array into it
document.getElementById("dummy_id").value = string;
// Select it
@uptownhr
uptownhr / docker-compose.repos.confirmed.json
Last active March 24, 2016 04:03
docker-compose projects on github
This file has been truncated, but you can view the full file.
[{"id":35866694,"name":"Rocket.Chat","full_name":"RocketChat/Rocket.Chat","owner":{"login":"RocketChat","id":12508788,"avatar_url":"https://avatars.githubusercontent.com/u/12508788?v=3","gravatar_id":"","url":"https://api.github.com/users/RocketChat","html_url":"https://github.com/RocketChat","followers_url":"https://api.github.com/users/RocketChat/followers","following_url":"https://api.github.com/users/RocketChat/following{/other_user}","gists_url":"https://api.github.com/users/RocketChat/gists{/gist_id}","starred_url":"https://api.github.com/users/RocketChat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RocketChat/subscriptions","organizations_url":"https://api.github.com/users/RocketChat/orgs","repos_url":"https://api.github.com/users/RocketChat/repos","events_url":"https://api.github.com/users/RocketChat/events{/privacy}","received_events_url":"https://api.github.com/users/RocketChat/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https:/
var teamSchema = new Schema({
name: {type: String},
king: {type: Schema.Types.ObjectId, ref: 'User'},
players: [{type: Schema.Types.ObjectId, ref: 'User'}],
subs: [{type: Schema.Types.ObjectId, ref: 'User'}]
})
var gameSchema = new Schema({
name: {type: String, default: ''},
status: {
function convert(num) {
console.log('number', num);
var romans = [
{ val: 1000, symbol: 'M' },
{ val: 500, symbol: 'D', odd: true },
{ val: 100, symbol: 'C' },
{ val: 50, symbol: 'L', odd: true },
{ val: 10, symbol: 'X' },
{ val: 5, symbol: 'V', odd: true },
{ val: 1, symbol: 'I' }
//how would you go from [1,2,3,4,5,6] to [ [1,2,3], [4,5,6] ]
@uptownhr
uptownhr / gist:8a204648bf0f05fb8aae
Created May 1, 2015 17:36
unique index not working
Sequel.migration do
up do
create_table :locations do
primary_key :id
String :address
String :lat
String :long
DateTime :created_at
DateTime :updated_at
end
$json = "{
rule_type: 'standard',
aggregate: {
action: 'sum',
column: 'amount'
},
trans_type: ['a','o','r'],
interval: 'monthly',
value: {
gt: 1000000