Skip to content

Instantly share code, notes, and snippets.

@mrsweaters
mrsweaters / setup.sh
Created February 5, 2012 04:18 — forked from erotte/server_setup.md
Vagrant Box Setup Ruby 1.9.3/Nginx/Passenger/MySQL
#!/usr/bin/env bash
# login as root and run this script via bash & curl:
apt-get update
apt-get install -y build-essential bison openssl libreadline5 libreadline5-dev curl \
git-core zlib1g zlib1g-dev libopenssl-ruby libcurl4-openssl-dev libssl-dev \
libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libmysqlclient-dev \
mysql-client mysql-server
@mrsweaters
mrsweaters / usingRootScopeController.js
Created October 18, 2018 16:43 — forked from pablotdl/usingRootScopeController.js
AngularJS service instead of $rootScope
'use strict'
/**
* A sample controller that stores data in the $rootScope
*/
angular.module('sample').controller('usingRootScopeController', ['$rootScope', '$scope', function ($rootScope, $scope) {
// Resets the list of items.
$scope.reset = function () {
$rootScope.someList = [];
}
@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 / 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 / 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();
@mrsweaters
mrsweaters / imagemagick7.sh
Created January 2, 2018 22:10 — forked from marcinwol/imagemagick7.sh
Compile ImageMagick 7 on Ubuntu 16.04
sudo apt install build-essential autoconf automake autopoint chrpath cm-super-minimal debhelper dh-autoreconf dh-strip-nondeterminism doxygen doxygen-latex gir1.2-rsvg-2.0 graphviz libbz2-dev libcairo-script-interpreter2 libcairo2-dev libcdt5 libcgraph6 libclang1-3.6 libdjvulibre-dev libexif-dev libfftw3-bin libfftw3-dev libfftw3-long3 libfftw3-quad3 libfile-stripnondeterminism-perl libfontconfig1-dev libfreetype6-dev libgdk-pixbuf2.0-dev libglib2.0-dev libgvc6 libgvpr2 libharfbuzz-dev libharfbuzz-gobject0 libice-dev libilmbase-dev libjasper-dev libjbig-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libjs-jquery liblcms2-dev libllvm3.6v5 liblqr-1-0-dev liblzma-dev libobjc-5-dev libobjc4 libopenexr-dev libpango1.0-dev libpathplan4 libpcre3-dev libpcre32-3 libpcrecpp0v5 libperl-dev libpixman-1-dev libpng12-dev libpotrace0 libptexenc1 libpthread-stubs0-dev librsvg2-bin librsvg2-dev libsigsegv2 libsm-dev libsynctex1 libtexlua52 libtexluajit2 libtiff5-dev libtiffxx5 libwmf-dev libx11-dev li
@mrsweaters
mrsweaters / README.md
Last active July 24, 2017 19:42 — forked from tristanm/README.md
Migrating a Rails project from MySQL to PostgreSQL

Migrating a Rails project from MySQL to PostgreSQL

This brief guide is written from my own experience with migrating a large (~5GB) MySQL database to PostgreSQL for a Rails project.

No warranties, guarantees, support etc. Use at your own risk and, as always, ENSURE YOU MAKE BACKUPS FIRST!

I chose [pgloader][1] because it's extremely fast. YMMV.

  1. Replace mysql2 gem with pg in Gemfile.
  2. Update config/database.yml for PostgreSQL. I used [Rails' template][2] as a starting point.
#!/bin/sh
# Output file for HTML5 video
# requirements: ffmpeg .6+
# usage: ./html5video.sh infile.mp4 640x360
target_directory='converted'
file=`basename $1`
filename=${file%.*}
filepath=`dirname $1`

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname