Skip to content

Instantly share code, notes, and snippets.

View sethwebster's full-sized avatar

Seth Webster sethwebster

View GitHub Profile
@sethwebster
sethwebster / README.md
Last active April 12, 2023 19:06
Make Docker Cache Gem Installs to speed up Bundle Install

Gem Install Dockerfile Hack

If you're hacking on your Gemfile and using Docker, you know the pain of having the bundle install command run after you've added or removed a gem. Using docker-compose you could mount a volume and stage your gems there, but this adds additional complexity and doesn't always really solve the problem.

Enter this imperfect solution:

What if we installed every gem into it's own Docker layer which would be happily cached for us?

gem-inject-docker does just that. It takes the list of gems used by your app via bundle list and transforms it into a list of RUN gem install <your gem> -v <gem version> statements and injects them into the Dockerfile at a point of your choosing.

class ThereCanBeOnlyOne {
timeout = null;
performAction(waitMs, action) {
if (this.timeout) this.cancelPrevious();
return new Promise((resolve, reject) => {
this.timeout = setTimeout(() => {
this.cancelPrevious();
const value = action();
if (value.then && value.catch) {
{
"caret_style": "phase",
"color_scheme": "Packages/Colorsublime - Themes/Afterglow.tmTheme",
"fade_fold_buttons": false,
"folder_exclude_patterns":
[
"node_modules",
"bower_components",
".svn",
".git",
addUser() {
echo "Adding user $1..."
adduser $1
gpasswd -a $1 sudo
}
enableSwap() {
echo "Enabling Swap..."
sudo fallocate -l 4G /swapfile
sudo mkswap /swapfile
@sethwebster
sethwebster / GoDaddySSLHAProxy.md
Created December 29, 2015 21:29
Creating a PEM for HaProxy from GoDaddy SSL Certificate

GoDaddy SSL Certificates PEM Creation for HaProxy (Ubuntu 14.04)

1 Acquire your SSL Certificate

Generate your CSR This generates a unique private key, skip this if you already have one.

sudo openssl genrsa -out  etc/ssl/yourdomain.com/yourdomain.com.key 1024

Next generate your CSR (Certificate Signing Request), required by GoDaddy:

### Keybase proof
I hereby claim:
* I am sethwebster on github.
* I am sethwebster (https://keybase.io/sethwebster) on keybase.
* I have a public key whose fingerprint is 1455 B70C 6E9D EACA DF22 1E58 FDE6 0C0B 581B 3A8A
To claim this, I am signing this object:
@sethwebster
sethwebster / update-authors.sh
Last active May 15, 2017 17:26
Script to rewrite a list of authors in git history
#!/bin/bash
#
# +-----------------------+
# | Update Authors Script |
# +-----------------------+-------------------------------------------------------------------------+
# | |
# | Updates wrong authors and maps them to the new Git authors |
# | |
@sethwebster
sethwebster / FbPageInviteAllBookMarklet.js
Created November 30, 2013 13:26
For Facebook Pages only, invite all friends to like page. At the time of this writing, this works. Facebook changes things up pretty frequently so YMMV. First, add this code as bookmarklet, then, when inviting friends, scroll to the bottom of your list to ensure they're all loaded. Finally, click the bookmarklet. Viola, all friends invited.
javascript:function inviteNext(e,t){if(e<t.length){total++;t[e].click();e++;setTimeout(function(){inviteNext(e,t)},100);updateCount()}else{destroyPopup()}}function updateCount(){var e=document.getElementById("invite-all-count-sw");e.innerText=total+"/"+els.length}function createPopup(){var e=document.getElementsByTagName("head")[0];var t=document.getElementsByTagName("body")[0];var n=document.createElement("div");n.setAttribute("id","add-all-div-sw");n.setAttribute("style",'text-align:center;font-family:"lucida grande",tahoma,verdana,arial,sans-serif;padding:20px;width:25%;height;20%;border:2px solid #ccc;background-color:#fff;position:relative;margin:0 auto 0 auto');n.innerHTML='Inviting Everyone in the List...<span id="invite-all-count-sw">0</span> invited so far...';t.appendChild(n);popup=n}function destroyPopup(){popup.parentElement.removeChild(popup)}var popup=null;var total=0;var els=document.getElementsByClassName("uiButton _1sm");createPopup();inviteNext(0,els)
@sethwebster
sethwebster / FbPageInviteAll.js
Created November 30, 2013 13:22
*** NOTE: This is the non-minified version for reading. A minified, bookmarklet-ready version of this is here: https://gist.github.com/sethwebster/7719079 For Facebook Pages only, invite all friends to like page. At the time of this writing, this works. Facebook changes things up pretty frequently so YMMV. First, add this code as bookmarklet, th…
var popup = null;
var total = 0;
function inviteNext(currentIndex,list){
if (currentIndex<list.length) {
total++;
list[currentIndex].click();
currentIndex++;
setTimeout(function() { inviteNext(currentIndex,list); },100);
updateCount();
}
@sethwebster
sethwebster / gist:1707024
Created January 30, 2012 21:53
S3 Upload Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Amazon.S3.Transfer;
using System.Collections.Specialized;
using System.Configuration;
using Amazon.S3.Model;
using System.IO;
using Amazon.S3.Util;