Skip to content

Instantly share code, notes, and snippets.

View CharlyJazz's full-sized avatar
🧭
I may be slow to respond.

CharlyJazz

🧭
I may be slow to respond.
View GitHub Profile
@dhoeric
dhoeric / Ubuntu 16.04
Last active October 28, 2025 12:26
install-docker-aws-ec2-user-data
#!/bin/bash
# Install docker
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
@rich-97
rich-97 / filter.js
Last active June 10, 2021 14:21
Example of pattern design oriented object in JavaScript.
$(document).ready(function () {
var $btn = $('.btn');
var $image = $('#img');
function Filter (config) {
this.target = config.target;
this.image = config.image;
this.filters = config.filters;
this.support = config.support === undefined ? true : config.support;
@getify
getify / number-prototype-iterator.js
Created January 25, 2017 23:52
Make JavaScript Great Again
Object.defineProperty(Number.prototype,Symbol.iterator,{
*value({ start = 0, step = 1 } = {}) {
var inc = this > 0 ? step : -step;
for (let i = start; Math.abs(i) <= Math.abs(this); i += inc) {
yield i;
}
},
enumerable: false,
writable: true,
configurable: true
@trezy
trezy / Head.jsx
Last active October 10, 2019 02:54
import NextHead from 'next/head'
import React from 'react'
import ReactGA from 'react-ga'
import Router from 'next/router'
/*****************************************************************************\
@collinalexbell
collinalexbell / basic_flask_server.py
Last active October 19, 2017 12:41
A flask server used to inject javascript into a window to test using PhantomJS
import threading
from yattag import Doc
from flask import Flask
js_scripts = []
app = (Flask(__name__))
thread = None
def start(host='0.0.0.0', port = 6969):
"""Gets app listening on host:port. Call inject before starting the
@kentcdodds
kentcdodds / README.md
Created October 25, 2017 22:01
Rendering a function with React

Rendering a function with React

No, this isn't about render props

I'm going to clean this up and publish it in my newsletter next week!

Context

So react-i18n (not the npm one... one we made at PayPal internally) has this

@rich-97
rich-97 / git_alias.sh
Last active March 3, 2018 12:09
Common alias for Git.
alias gits='git status -s'
alias gitl='git log --oneline'
alias gitc='git commit -m'
alias gita='git add --all'
alias gitp='git push -u origin master'
alias gitd='git diff'
alias gitpl='git pull'
alias gitpb='git push origin'
@dfee
dfee / graphene_subscription.py
Created November 25, 2017 03:17
Example of how subscriptions work with graphene
from collections import OrderedDict
import graphene
import rx
subject = rx.subjects.Subject()
class Author(graphene.ObjectType):
@rayfarer
rayfarer / script.js
Created April 1, 2018 15:47
Add Timestamp When Document Created Firestore
/*
Using Cloud Functions, here's what I've come up with for anyone who wants to
add a timestamp field in a Firestore document. You need to have the Firebase Admin SDK installed in
addition to the general setup for Cloud Functions as detailed in the Firebase documentation.
*/
const functions = require('firebase-functions');
// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require('firebase-admin');
@vladfr
vladfr / 1-standard.js
Last active May 9, 2023 07:34
Use async/await and for..of in Cloud Firestore
// In a Firestore standard example, we quickly create a 'xmas tree' of nested stuff
// We use Promises directly: get().then(callback) and use snapshot.forEach() to iterate
let campaignsRef = db.collection('campaigns');
let activeCampaigns = campaignsRef.where('active', '==', true).select().get()
.then(snapshot => {
snapshot.forEach(campaign => {
console.log(campaign.id);
let allTasks = campaignsRef.doc(campaign.id).collection('tasks').get().then(
snapshot => {
snapshot.forEach(task => {