View cleanup-docker.sh
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
View demo.php
<?php
date_default_timezone_set('America/Los_Angeles');
session_start();
include("ratelimiter.php");
// in this sample, we are using the originating IP, but you can modify to use API keys, or tokens or what-have-you.
$rateLimiter = new RateLimiter($_SERVER["REMOTE_ADDR"]);
$limit = 100; // number of connections to limit user to per $minutes
$minutes = 1; // number of $minutes to check for.
View time
function toUserTimeZone(utc_date, offset){
if (utc_date.slice(-3) !== "UTC") {
utc_date += " UTC";
}
var local_date = new Date(utc_date);
var local_offset = local_date.getTimezoneOffset() * 60000;
var utc_time = local_date.getTime() + local_offset;
return new Date(utc_time + (3600000 * offset));
}
View todo.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>React Tutorial</title>
<link rel="stylesheet" href="css/base.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.16/browser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
View queue.js
/* Creates a new queue. A queue is a first-in-first-out (FIFO) data structure -
* items are added to the end of the queue and removed from the front.
*/
function Queue(){
// initialise the queue and offset
var queue = [];
var offset = 0;
// Returns the length of the queue.
View leftpad.js
function leftpad (str, len, ch) {
str = String(str);
var i = -1;
if (!ch && ch !== 0) ch = ' ';
len = len - str.length;
while (++i < len) {
str = ch + str;
}
return str;
}
View notify.html
<!-- Learn about this code on MDN: https://developer.mozilla.org/en-US/docs/Web/API/notification -->
<script src="notify.js"></script>
<button onclick="notifyMe()">Notify me!</button>
View gist:5cf5e85456494f5265ce
git fetch --all
git reset --hard origin/master
git pull origin master
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View install_ruby_1.9.3
Step 1: Upgrade Packages
# yum update
# yum -ygroupinstall "Development Tools"
Step 2: Installing Recommended Packages
# yum -y install gcc-c++ patch readline readline-devel zlib zlib-devel
# yum -y install libyaml-devel libffi-devel openssl-devel make
# yum -y install bzip2 autoconf automake libtool bison iconv-devel
Step 3: Install RVM ( Ruby Version Manager )