Skip to content

Instantly share code, notes, and snippets.

@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@jboesch
jboesch / pg_import_csv_to_heroku.sh
Last active April 5, 2022 22:11
Importing a CSV dump of Postgres data into Heroku
# You have your csv data and it looks like so... It's in a file named "my_data.csv" and we want to import it into a table named "my_things".
"1", "Something", "0.50", "2013-05-05 10:00:00"
"2", "Another thing", "1.50", "2013-06-05 10:30:00"
# Now you want to import it, go to the command line and type:
$ PGPASSWORD=PWHERE psql -h HOSTHERE -U USERHERE DBNAMEHERE -c "\copy my_things FROM 'my_data.csv' WITH CSV;"
# Voila! It's impoted. Now if you want to wipe it out and import a fresh one, you would do this:
@anantn
anantn / firebase_detect_data.js
Created December 18, 2012 00:54
Firebase: Detecting if data exists. This snippet detects if a user ID is already taken
function go() {
var userId = prompt('Username?', 'Guest');
checkIfUserExists(userId);
}
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users';
function userExistsCallback(userId, exists) {
if (exists) {
alert('user ' + userId + ' exists!');
@cee-dub
cee-dub / postgres_timestamp_defaults.rb
Created January 29, 2012 20:53
Convenient methods to let PostgresQL manage created/updated_at
require 'active_support/core_ext/string/filters'
module PostgresTimestampDefaults
def add_timestamp_defaults(table_name)
add_default_now(table_name, :created_at)
add_default_now(table_name, :updated_at)
add_updated_at_trigger(table_name)
end
def add_default_now(table_name, column_name)
@manast
manast / interval.js
Last active November 15, 2023 22:08
Accurate Javascript setInterval replacement
function interval(duration, fn){
var _this = this
this.baseline = undefined
this.run = function(){
if(_this.baseline === undefined){
_this.baseline = new Date().getTime()
}
fn()
var end = new Date().getTime()
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh