A collection of Linux commands and concepts I tend to forget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
user ||= User.new # guest user (not logged in) | |
if user.has_role? :admin # rolify | |
can :manage, :all | |
can :access, :ckeditor | |
# Performed checks for actions: | |
can [:read, :create, :destroy], Ckeditor::Picture |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"description": "JSON:API Schema", | |
"type": "object", | |
"properties": { | |
"link": { "$ref": "file://schemata/link.json#" }, | |
"meta": { "$ref": "file://schemata/meta.json#" } | |
} | |
} |
Step 0. Install Docker
Step 1. For your chosen project, decide where you want to store your notebooks and files in a workingfolder
.
Step 2. Open that folder in the terminal cd workingfolder
Step 3. Run this command
docker run -it --rm -v $PWD:/home/jovyan/work -p 8888:8888 jupyter/all-spark-notebook
Leanstack.io list of cloud services
Analytics
- New Relic
- ScoutApp
- Librato
- Instrumental
- DataDog
- AppNeta
- Skylight.io (very alpha, invite-only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
install() { | |
brew cask list lunchy >/dev/null || brew cask install lunchy | |
pwd=$(pwd) | |
reinstall_openssl | |
reinstall_nginx | |
cd # In case user uses gemsets, ensure we're installing powder outside of a project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import webbrowser | |
total_breaks = 8 | |
break_count = 0 | |
while (break_count < total_breaks): | |
time.sleep(3600) | |
webbrowser.open("https://31.media.tumblr.com/288d6e631cd930de65547ef5044fefb8/tumblr_mlksb86paT1qbuvyto1_500.gif") | |
break_count = break_count + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use inverse_of to 'just work' | |
class User < ActiveRecord::Base | |
has_many :contributions, inverse_of: :user | |
has_many :posts, through: :contributions | |
end | |
 | |
class Post < ActiveRecord::Base | |
has_many :contributions, inverse_of: :post | |
has_many :contributors, through: :contributions, | |
source: :user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Finds and yields relations in batches. Adapted from record.find_in_batches since that yields | |
# arrays and we want to operate on relationships. | |
# Adapted from: | |
# https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_record/relation/batches.rb#L98-L115 | |
def find_in_batches(target, batch_size: default_batch_size, start: nil) | |
relation = target | |
if logger && (target.arel.orders.present? || target.arel.taken.present?) | |
logger.warn("Scoped order and limit are ignored, it's forced to be batch order and batch size") | |
end | |
relation = relation.reorder(target.send(:batch_order)).limit(batch_size) |