Skip to content

Instantly share code, notes, and snippets.

@mrgcohen
mrgcohen / role.sql
Created March 10, 2014 20:59
add role postgres
create role myapp with createdb login password 'password1'
@mrgcohen
mrgcohen / strongpasswords.js
Created March 27, 2014 12:55
strong passwords
// strong password validation
jQuery.validator.addMethod("strongPassword", function(value, element) {
return value.match(/[a-z]/)
&& value.match(/[A-Z]/)
&& value.match(/[1-9]/)
&& value.match(/[^0-9a-zA-Z]/)
&& value.length >= 8;
}, "Password must be 8 characters long, contain at least one lowercase character (a-z), one uppercase character (A-Z), at least one digit (0-9), and at least one special character.");
@mrgcohen
mrgcohen / intercom.rb
Last active August 29, 2015 14:00
Intercom hash setup secure mode
intercom_hash = Base64.encode64(
OpenSSL::HMAC.digest(
OpenSSL::Digest::Digest.new('sha256'),
IntercomRails.config.api_secret,
the_user_id_if_being_sent_otherwise_users_email_address
)
).strip()
@mrgcohen
mrgcohen / group_by_date_postgres.rb
Created August 1, 2014 13:52
group by date postgres, nice cast
Table.select("field1, created_at::timestamp::date").group("field1, created_at::timestamp::date")
@mrgcohen
mrgcohen / GroupRidesBaltimore.md
Last active August 29, 2015 14:05
Group Rides Baltimore, Maryland

Times change to 5:30 after daylight savings

Monday @ 6pm

  1. Race Pace Key Highway, easy ride
  2. Lutherville Bike Shop, faster ride

Tuesday @ 6pm

  1. Race Pace Ellicot City, faster ride
<!DOCTYPE html>
<html>
<head>
<script src="background.js"></script>
</head>
<body>
<textarea id="sandbox"></textarea>
</body>
# WINDOWS: Add domain user and put them in Domain Admins group
net user username password /ADD /DOMAIN
net group "Domain Admins" username /ADD /DOMAIN
# WINDOWS: Add local user and put them local Administrators group
net user username password /ADD
net localgroup Administrators username /ADD
# LINUX: Add a new user to linux and put them in the wheel group
useradd -G wheel username
@mrgcohen
mrgcohen / DirectionsForLoadingCSVInToMysql.md
Last active August 29, 2015 14:11
Mysql Import from excel on mac

Import Excel file (mac) into Mysql

  1. Save as csv
  2. run sql 'mysql_import_csv_from_excel.sql'
@mrgcohen
mrgcohen / rails-intro-with-generators.md
Created February 7, 2015 16:50
Rails Intro and Scaffolding

Prototyping in Rails

I'm assuming you're on Linux or a Mac. If you aren't - Google is your friend. Fortunately there's a ton of documentation out there so you shouldn't have too much trouble setting things up.

Machine Setup

RVM and Ruby-2.2.0 Installation

  1. Install RVM to manage Ruby - Go to https://rvm.io/ and install (should be 1-2 calls to install)
  2. Lets install ruby-2.2.0 and make it our default
@mrgcohen
mrgcohen / psql_dump_tables.sh
Created June 2, 2015 14:41
dump tables from psql as csv
psql -c "COPY tablename TO stdout DELIMITER ',' CSV HEADER" datasbasename -U username -h hostname -W > filename.csv