Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View NewAlexandria's full-sized avatar
🍄
My responses are limited; you must ask the right questions.

NewAlexandria

🍄
My responses are limited; you must ask the right questions.
View GitHub Profile
@jgamblin
jgamblin / digicertacm.sh
Created November 4, 2017 23:52
Automating Digicert Certificates Into AWS ACM
#!/bin/bash
#Required
apikey=
domain=
commonname=$1
orgid=
#Change to your company details
country=
@vitorbritto
vitorbritto / rm_mysql.md
Last active April 18, 2024 19:00
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql
    
@karanrajs
karanrajs / VFRemoteObject.html
Last active September 27, 2017 09:07
A Visualforce page to demonstrate the functionality of Visualforce Remote Objects
<!---
@author : Karanraj
@Description : A Visualforce page to demonstrate the functionality of Remote Objects
-->
<apex:page showHeader="false" standardStylesheets="false">
<!-- Boostrap and jQuery file -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css" />
@pachacamac
pachacamac / 2048.rb
Last active August 29, 2015 13:57
2048 game in concise but not golfed Ruby
def rgb(r, g, b)16+(r.to_i*36)+(g.to_i*6)+b.to_i end
def colorize(s, fg, bg = nil) "#{fg ? "\x1b[38;5;#{fg}m" : ''}#{bg ? "\x1b[48;5;#{bg}m" : ''}#{s}\x1b[0m" end
def rainbow(n)f,w,o=5.0/n,3,3; (0...n).map{|i| rgb(Math.sin(f*i+0)*o+w, Math.sin(f*i+2)*o+w, Math.sin(f*i+4)*o+w)} end
def display(board, goal=2048)
@palette ||= rainbow(Math.log2(goal))
puts board.map{|r| r.map{|c| colorize((c==0 ? ?. : c).to_s.center(6), @palette[Math.log2(c+1)])}.join}.join("\n\n")
end
def compress(board, direction)
t=->(a){z=0;a.reduce([]){|s,e| z+=e==s[-1]? (s[-1]+=e;1): e>0? (s<<e;0): 1;s}+Array.new(z,0)} # trivial case: 1D array to the left
@sumardi
sumardi / nginx.default.conf
Last active November 3, 2023 18:49
Install PHP-FPM, Nginx & MySQL on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and PHP-FPM
sudo yum install -y nginx php-fpm
# Install PHP extensions
sudo yum install -y php-devel php-mysql php-pdo \
php-pear php-mbstring php-cli php-odbc \
@egonelbre
egonelbre / gist:3437746
Created August 23, 2012 15:27
State Machine
function Machine(first, $){
var cur = {}, next = $[first];
var self = {
go : function(to){ next = next ? next : ($[to] || $.undefined); },
trigger : function(event){ var t = cur.tx && cur.tx[event]; t && self.go(t); }
};
return function(){
if(next){
cur.exit && cur.exit.call(self);
cur = next; next = undefined;
@jboner
jboner / latency.txt
Last active April 22, 2024 15:20
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@flavio
flavio / gemfile_lock2geminabox.rb
Created February 2, 2012 09:21
Parse Gemfile.lock, download all gems from rubygems and then upload them to a local instance of geminabox
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
require 'fileutils'
require 'net/http'
require 'net/https'
require 'uri'
TMP_DIR = "/tmp/gems"
@arnorhs
arnorhs / gist:1517095
Created December 24, 2011 10:40 — forked from tessro/gist:1515117
gitopen - Open all files from a git diff or show command
#!/bin/bash
# This script will open all files from a git diff or a git show in vim.
# My bash skills are a bit primitive so this can probably be done more intelligently
# Usage:
# gitopen -- opens all added files that have changed since HEAD
# gitopen diff HEAD -- these are the default parameters
# gitopen diff master -- opens files that have changed from master
@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/