Skip to content

Instantly share code, notes, and snippets.

@ordoghl
ordoghl / polymorphic_ass_grape_entity
Created September 19, 2013 14:02
Polymorphic association in a grape entity
require_relative 'customer.rb'
require_relative 'contact.rb'
require_relative 'agent.rb'
module Api
module V1
module Entities
class Ticket < Grape::Entity
expose :id
@flesch
flesch / basic-auth.js
Last active July 27, 2022 12:39
HTTP Basic Authentication with Express, without express.basicAuth.
var express = require("express");
var app = express();
app.get("/restricted", function(req, res, next){
// Grab the "Authorization" header.
var auth = req.get("authorization");
// On the first request, the "Authorization" header won't exist, so we'll set a Response
// header that prompts the browser to ask for a username and password.
@pcreux
pcreux / Gemfile
Last active November 6, 2025 11:25
Fast Rails + Heroku Configuration
group :production do
gem 'unicorn'
# Enable gzip compression on heroku, but don't compress images.
gem 'heroku-deflater'
# Heroku injects it if it's not in there already
gem 'rails_12factor'
end
@bomberstudios
bomberstudios / sketch-plugins.md
Last active December 11, 2025 19:43
A list of Sketch plugins hosted at GitHub, in no particular order.
import numpy as np
def loadSparseMatrix(filename):
"""
Loads the sparse matrix in text file `filename` assuming the
Matlab format.
Each row of the file should specify the non-zero value
at a particular location, using 1 based indexes, formatted as follows:
@sebmarkbage
sebmarkbage / react-terminology.md
Last active December 26, 2025 06:20
React (Virtual) DOM Terminology
@mahmoudimus
mahmoudimus / 04run-envfile.patch
Created December 18, 2014 00:20
Patch to run on elastic beanstalk to allow docker to use an --env-file cmdline argument
--- elasticbeanstalk/hooks/appdeploy/pre/04run.sh 2014-12-12 11:07:47.000000000 -0800
+++ elasticbeanstalk/hooks/appdeploy/pre/04run.sh-new 2014-12-17 15:31:45.000000000 -0800
@@ -65,6 +65,14 @@
EB_CONFIG_DOCKER_ENV_ARGS+=(--env "$ENV_VAR")
done < <($EB_SUPPORT_FILES/generate_env)
+# build --env-file arguments for docker
+
+EB_CONFIG_DOCKER_ENVFILE=()
+
'use strict';
var React = require('react-native');
var {
Bundler,
StyleSheet,
Text,
TouchableHighlight,
View,
ScrollView,
@brianpetro
brianpetro / rails-4-new-options
Created April 28, 2015 18:11
Command line options for ` rails new --help ` (Rails 4.2). Useful for planning new Ruby on Rails app. 'Where can I find options for “rails new” command?'
Because I couldn't find these with a quick Google search on 28 April 2015:
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /home/brian/.rvm/rubies/ruby-2.2.0/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
[--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile
@juliandunn
juliandunn / post-mortem-template.md
Created April 29, 2015 00:53
Post mortem template

INCIDENT DATE - INCIDENT TYPE

Meeting

Waiving meetings

In some cases the IC might determine that a PM meeting for the incident isn't needed. If the IC decides to waive the meeting please replace the Meeting section with a note indicating the meeting has been waived (example: Meeting waived: Paul Mooring)