Skip to content

Instantly share code, notes, and snippets.

View refriedchicken's full-sized avatar

Mike Benner refriedchicken

View GitHub Profile
@garretttaco
garretttaco / diff_ids_update.ex
Created May 9, 2019 17:34
Use MapSets to find differences in new ids vs current/existing ids. This really could be used for any many to many ids table.
def diff_ids_update(new, existing) do
# Use MapSets to find differences in new ids vs current/existing ids. This really could be used for any many to many ids table.
new = new |> MapSet.new()
existing = existing |> MapSet.new()
remove = MapSet.difference(existing, new) |> MapSet.to_list()
add = MapSet.difference(new, existing) |> MapSet.to_list()
{remove, add}
end
@chrismccord
chrismccord / phx-1.4-upgrade.md
Last active June 16, 2023 06:22
Phoenix 1.3.x to 1.4.0 Upgrade Guides

Phoenix 1.4 ships with exciting new features, most notably with HTTP2 support, improved development experience with faster compile times, new error pages, and local SSL certificate generation. Additionally, our channel layer internals receiveced an overhaul, provided better structure and extensibility. We also shipped a new and improved Presence javascript API, as well as Elixir formatter integration for our routing and test DSLs.

This release requires few user-facing changes and should be a fast upgrade for those on Phoenix 1.3.x.

Install the new phx.new project generator

The mix phx.new archive can now be installed via hex, for a simpler, versioned installation experience.

To grab the new archive, simply run:

@rusilko
rusilko / dev_start.sh
Last active April 15, 2017 04:48
Simple bash script to quickly fire up your Rails working environment.
#!/bin/bash
# Function displaying wrong usage information
# Proper usage is: ./dev_start.sh Rails-Project-Folder
usage()
{
cat << EOF
usage: $0 Rails-Project-Folder
EOF
}
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@yorkxin
yorkxin / KeyBindings.json
Last active November 29, 2018 20:40
My Sublime Text 2 Config
/* Default (OS X).sublime-keymap */
/* Key Bindings - User */
[
{ "keys": ["ctrl+shift+."], "command": "erb", "context":
[
{
"key": "selector",
"operator": "equal",
"operand": "text.html.ruby, text.haml, source.yaml, source.css, source.scss, source.js, source.coffee"
}
@oodavid
oodavid / README.md
Created March 26, 2012 17:05
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@petewarden
petewarden / webpage2png.rb
Created November 28, 2011 02:44
An example of using PhantomJS from Ruby to do server-side rendering of a web page into a PNG
require 'rubygems' if RUBY_VERSION < '1.9'
require 'tempfile'
require File.join(ENV['JETPAC_PATH'], 'library/logger')
require File.join(ENV['JETPAC_PATH'], 'library/email')
def image_command(command)
log "IMG: Running '#{command}'"
result = system(command)
if !result
@simple
simple / gist:1364716
Created November 14, 2011 18:43 — forked from kwilczynski/gist:1170467
Upstart configutation file for MongoDB with NUMA support
# Ubuntu upstart file at /etc/init/mongodb.conf
limit nofile 32768 32768
kill timeout 300 # wait 300s between SIGTERM and SIGKILL.
pre-start script
mkdir -p /data/mongodb &> /dev/null
mkdir -p /data/logs/mongo &> /dev/null
chown mongodb:nogroup /data/mongodb &> /dev/null
@davist11
davist11 / gist:1204569
Last active January 19, 2024 15:03
Campfire sounds
56k: "https://123.campfirenow.com/images/56k.gif"
bell: ":bell:"
bezos: ":laughing::thought_balloon:"
bueller: "anyone?"
butts: ":open_hands: :smoking:"
clowntown: "https://123.campfirenow.com/images/clowntown.gif"
cottoneyejoe: ":notes::hear_no_evil::notes:"
crickets: "hears crickets chirping"
dadgummit: "dad gummit!! :fishing_pole_and_fish:"
dangerzone: "https://123.campfirenow.com/images/dangerzone.png"
@bryanl
bryanl / campfire-emoji.txt
Created January 27, 2011 16:34
campfire emoji
Surround these with : e.g. :calling:
+1
-1
bulb
calling
clap
cop
email
feet