Skip to content

Instantly share code, notes, and snippets.

@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.
@mrsweaters
mrsweaters / README.md
Created October 25, 2015 17:13 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default and default-ssl to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@mrsweaters
mrsweaters / nginx.conf
Last active August 29, 2015 14:26 — forked from conorh/nginx.conf
Using Nginx as a caching proxy for Refile with Ruby on Rails
http {
...
proxy_cache_path /data/perch.squaremill.com/shared/image_cache levels=1:2 keys_zone=images:10m;
...
}
@mrsweaters
mrsweaters / docsplit-install.sh
Last active August 29, 2015 14:26 — forked from adilsoncarvalho/docsplit-install.sh
Installing Doc Split on Ubuntu/MacOS
#!/bin/bash
if [ $(uname -s) == "Darwin" ]; then
brew install graphicsmagick
brew install poppler
brew install ghostscript
brew install tesseract
wget -o ~/Downloads/pdftk_server-1.45-mac_osx-10.6-setup.pkg http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-1.45-mac_osx-10.6-setup.pkg
open ~/Downloads/pdftk_server-1.45-mac_osx-10.6-setup.pkg
else