Skip to content

Instantly share code, notes, and snippets.

@jeremy2
jeremy2 / postgres.md
Created January 18, 2022 23:10 — forked from phortuin/postgres.md
Set up postgres + database on MacOS (M1)

Based on this blogpost.

Install with Homebrew:

$ brew install postgresql

Run server:

@jeremy2
jeremy2 / mysql2-mojave.md
Created March 9, 2020 21:12 — forked from fernandoaleman/mysql2-mojave.md
Install mysql2 on MacOS Mojave

Problem

Installing mysql2 gem errors on MacOS Mojave.

Solution

Make sure openssl is installed on Mac via Homebrew.

brew install openssl
@jeremy2
jeremy2 / lorem-ipsum.js
Created December 13, 2017 23:36 — forked from rviscomi/lorem-ipsum.js
JavaScript Lorem Ipsum Generator
/**
* @fileOverview Generates "Lorem ipsum" style text.
* @author rviscomi@gmail.com Rick Viscomi,
* tinsley@tinsology.net Mathew Tinsley
* @version 1.0
*/
/**
* Copyright (c) 2009, Mathew Tinsley (tinsley@tinsology.net)
* All rights reserved.
@jeremy2
jeremy2 / random_password.rb
Created November 14, 2012 17:54
generate a string of random alpha-numeric characters suitable as a password
# inspired by http://stackoverflow.com/questions/88311/how-best-to-generate-a-random-string-in-ruby
(0...16).map{ (('a'..'z').to_a + (0..9).to_a)[rand(36)] }.join
@jeremy2
jeremy2 / add_jquery_via_console.js
Created November 1, 2012 00:27
run this in your browser's javascript console, then jQuery should be available... (from http://stackoverflow.com/questions/7474354/include-jquery-in-the-javascript-console)
var jq = document.createElement('script');
jq.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
@jeremy2
jeremy2 / gist:2479338
Created April 24, 2012 12:44
HTML input fields used for Zip Codes should be type=text and use the pattern attribute to provide hints to the browser
<!--
-
- US Zip Codes are text (not numbers) made up of digits (and optionally the dash character, if you accept 9 digit codes)
-
- Number input fields will drop leading zeros and may add numeric formatting (ie- add commas) to the input. This behavior
- is incorrect for Zip Codes which can have leading zeros and should not include commas.
-
- This Gist shows the incorrect and correct way to tell the browser what is expected in a Zip Code field. Oddly, HTML5
- adds 'date', 'time' and 'tel' types to input elements, but does not include 'zip'.
-
@jeremy2
jeremy2 / database.yml.erb
Created March 6, 2012 23:17
Engine Yard custom Chef Recipe for generating database.yml configuration file
#
# This file should be in .../cookbooks/database/templates/default/database.yml.erb
#
<%= @environment %>:
adapter: <%= @adapter %>
database: <%= @database %>
username: <%= @username %>
password: <%= @password %>
host: <%= @host %>
@jeremy2
jeremy2 / colorsExtractor
Created January 30, 2012 16:20
dumb less parser to extract color info as JSON. TODO: clean this up, test and make it into a generally usable tool
function readColors() {
var file = 'public/stylesheets/less/_colors.less';
var data = fs.readFileSync(file, 'utf-8');
data = data.replace(/(.*): *(.*);/gm, '"$1":"$2",');
data = data.replace(/\/\/.*$/gm, '');
var i = data.lastIndexOf(',');
data = data.substring(0,i);
data = '{'+ data +'}';
data = JSON.parse(data);
console.log('json: '+ JSON.stringify(data));