Skip to content

Instantly share code, notes, and snippets.

@mrsweaters
mrsweaters / dc.rb
Created September 24, 2018 21:35
DC ZIP Codes
codes = ['20222','20515','20060','20226','20064','20229','20530','20533','20532','20250','20091','20543','20542','20546','20262','20268','20549','20303','20317','20319','20373','20593','20390','20402','20401','20001','20003','20002','20005','20004','20007','20006','20009','20008','20011','20010','20422','20012','20016','20015','20018','20017','20020','20019','20433','20431','20024','20032','20030','20037','20036','20202','20203','20044','20052','20057','20507','20510','20220','20059','20509']
@mrsweaters
mrsweaters / controller.ts
Created September 18, 2018 20:55 — forked from thecodefish/controller.ts
AngularJS component example for loading GrapesJS editor
class MyController {
editor: any;
grapesJsConfig: {
//whatever
}
constructor(private readonly $scope: ng.IScope) {}
@mrsweaters
mrsweaters / tune.rb
Created July 12, 2018 17:14
PGTune
# DB Version: 10
# OS Type: linux
# DB Type: web
# Total Memory (RAM): 8 GB
# CPUs num: 2
# Connections num: 856
# Data Storage: ssd
max_connections = 856
shared_buffers = 2GB
@mrsweaters
mrsweaters / helpful.sh
Created July 5, 2018 22:06
Helpful Mac Config
# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool true
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Disable the warning when changing a file extension
@mrsweaters
mrsweaters / subdomain-localhost-rails-5.md
Created May 11, 2018 15:28 — forked from indiesquidge/subdomain-localhost-rails-5.md
how to access subdomains locally with Rails 5

Subdomaining Localhost with Rails 5

I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api

Rails.application.routes.draw do
  constraints subdomain: "api" do
    scope module: "api" do
@mrsweaters
mrsweaters / lambda-redirect-to-trailing-slash.js
Created May 9, 2018 01:13 — forked from nabilfreeman/lambda-redirect-to-trailing-slash.js
Redirect to trailing slashes on CloudFront with AWS Lambda. (all this because S3 uses 302 redirects instead of 301)
'use strict';
const path = require('path')
exports.handler = (event, context, callback) => {
//get request object
const { request } = event.Records[0].cf
const url = request.uri;
@mrsweaters
mrsweaters / normalize.rb
Created April 16, 2018 17:27
Normalize data in Rails Example
class CreateAddresses < ActiveRecord::Migration
def self.up
create_table :addresses do |t|
t.integer :customer_id
t.string :address
t.string :city
t.string :state
t.integer :zip_code
t.timestamps
end
@mrsweaters
mrsweaters / nohup.sh
Created March 6, 2018 20:52
Run command in background
nohup sh -c 'mycommand' > /dev/null &
@mrsweaters
mrsweaters / settings.json
Created February 21, 2018 04:21
sublime settings
{
"caret_extra_width": 2,
"color_scheme": "Packages/Theme - Spacegray/base16-eighties.dark.tmTheme",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"folder_exclude_patterns":
[
".git",
"node_modules"
],
@mrsweaters
mrsweaters / turboLinksPreFetch.js
Created February 8, 2018 19:39 — forked from Ch4s3/turboLinksPreFetch.js
decaffeinated version of https://gist.github.com/Enalmada/6e11191c1ea81a75a4f266e147569096 with a flag for turning it on or off
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const OldHttpRequest = Turbolinks.HttpRequest;
Turbolinks.CachedHttpRequest = class CachedHttpRequest extends Turbolinks.HttpRequest {
constructor(_, location, referrer) {
super();