Skip to content

Instantly share code, notes, and snippets.

View samuelkarani's full-sized avatar

Samuel Karani Mbaabu samuelkarani

  • University of California, Berkeley
  • Paris, France
View GitHub Profile
@buonzz
buonzz / docker-compose-cheatsheet.sh
Last active April 16, 2020 14:05
docker-compose cheatsheet
$ docker-compose up -d # start containers in background
$ docker-compose kill # stop containers
$ docker-compose up -d --build # force rebuild of Dockerfiles
$ docker-compose rm # remove stopped containers
$ docker ps # see list of running containers
$ docker exec -ti [NAME] bash # ssh to the container
# list all images
docker images
@hindol
hindol / clojure_in_15_minutes.md
Last active August 8, 2021 15:51
Clojure in 15 Minutes: A Crash-course

Clojure in 15 Minutes

Hello, Clojure!

(println "Hello, world!")
  • The same in Python,
@aresnick
aresnick / index.html
Last active October 22, 2021 12:58
Google Drive Export Client Side Export Example
<html>
<head>
<script type="text/javascript">
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '436763072331-rod105o2ppkpjrcdpsmrvmn2st3qg9el.apps.googleusercontent.com';
var SCOPES = ['https://www.googleapis.com/auth/drive.readonly'];
@vkarpov15
vkarpov15 / promise1.js
Created April 5, 2018 12:38
Write Your Own Node.js Promise Library from Scratch, Part 1
class MyPromise {
constructor(executor) {
if (typeof executor !== 'function') {
throw new Error('Executor must be a function');
}
// Internal state. `$state` is the state of the promise, and `$chained` is
// an array of the functions we need to call once this promise is settled.
this.$state = 'PENDING';
this.$chained = [];
@adamawolf
adamawolf / geojson_us.js
Created September 3, 2012 23:15
GeoJSON Multipolygon for the United States
{
"type": "MultiPolygon",
"coordinates":
[
[
[
[ -123.123779, 48.227039 ], // contig. u.s.
[ -123.318787, 49.000042 ],
[ -121.742592, 49.000267 ],
[ -95.157394, 49.000493 ],
@anantn
anantn / getusermedia_picture.html
Created February 17, 2012 09:12
Take a picture with getUserMedia
<html>
<body>
<video id="v" width="300" height="300"></video>
<input id="b" type="button" disabled="true" value="Take Picture"></input>
<canvas id="c" style="display:none;" width="300" height="300"></canvas>
</body>
<script>
navigator.getUserMedia({video: true}, function(stream) {
var video = document.getElementById("v");
var canvas = document.getElementById("c");
@sourcec0de
sourcec0de / js_obj_getter_by_reg.js
Created April 1, 2014 13:32
Select keys from a javascript object using a regular expression. Returns an object containing only the keys that matched the expression in the original object.
var keyMatch = function(o,r){
var c = 0;
var nO = {};
Object.keys(o).forEach(function(k){
c++;
no[k] = k.match(r) ? o[k] : void 0;
});
@raddeus
raddeus / App.js
Created April 4, 2020 06:14
React ReCAPTCHA v3
import React, { useEffect, useState } from 'react';
// Set this to your public ReCAPTCHA client key
const RECAPTCHA_SITE_KEY = 'YOUR_KEY_HERE';
// Set this to your backend URL that verifies ReCAPTCHA tokens
const RECAPTCHA_VERIFY_URL = 'http://www.mocky.io/v2/5e88253631000025303f4835';
/**
* Sends a request to your server to verify the given token
@vkarpov15
vkarpov15 / promise2.js
Created April 5, 2018 13:57
Write Your Own Node.js Promise Library from Scratch, Part 2
class MyPromise {
constructor(executor) {
if (typeof executor !== 'function') {
throw new Error('Executor must be a function');
}
// Internal state. `$state` is the state of the promise, and `$chained` is
// an array of the functions we need to call once this promise is settled.
this.$state = 'PENDING';
this.$chained = [];
@robwierzbowski
robwierzbowski / gitcreate.sh
Last active August 8, 2023 07:31
A simple litte script. Create and push to a new github repo from the command line.
#!/bin/bash
# https://gist.github.com/robwierzbowski/5430952/
# Create and push to a new github repo from the command line.
# Grabs sensible defaults from the containing folder and `.gitconfig`.
# Refinements welcome.
# Gather constant vars
CURRENTDIR=${PWD##*/}
GITHUBUSER=$(git config github.user)