Skip to content

Instantly share code, notes, and snippets.

View coffeesam's full-sized avatar
:octocat:
GitHubbing..

Sam Hon coffeesam

:octocat:
GitHubbing..
View GitHub Profile
@azagniotov
azagniotov / beautiful.rest.api.docs.in.markdown.md
Last active May 6, 2024 01:05
Example to create beautiful REST API docs in Markdown, inspired by Swagger API docs.
@choonkeat
choonkeat / html2sprockets.rake
Last active May 7, 2016 03:35
`html2sprockets:assets` is a quick way to add 3rd-party js/css to your rails app that is asset pipeline compatible; creates local gem in `vendor/gems` and apply them in your `Gemfile`
require 'fileutils'
namespace :html2sprockets do
desc "Setup env for gem creation"
task :env do
@gemname = ENV.fetch('NAME')
@gemdir = File.join(ENV.fetch('GEMDIR', 'vendor/gems'), @gemname)
@asset_dst_path = File.join(@gemdir, ENV.fetch('DST', 'vendor/assets'))
@asset_src_paths = ENV.fetch('SRC').each_line.collect(&:strip)
@coffeesam
coffeesam / bootstrap-progress-animation.scss
Last active October 2, 2019 21:09
Bootstrap progress animating stripes for all HTML elements
@-webkit-keyframes u-progress-stripes {
from { background-position: 0 0 }
to { background-position: 40px 0 }
}
@-moz-keyframes u-progress-stripes {
from { background-position: 0 0 }
to { background-position: 40px 0 }
}
@keyframes u-progress-stripes {
from { background-position: 0 0 }
@aarongustafson
aarongustafson / backup-to-s3.sh
Created January 22, 2014 19:36
backup to S3 as a shell command (uses s3cmd)
#!/bin/bash
##
# Backup Server to S3 script
#
# Creates a local cached backup of the source folder using rsync and then
# synchronises that with Amazon S3.
#
#
# It is assumed you have rsync installed on the server.
@eddiemoore
eddiemoore / nric-validation.js
Last active October 17, 2022 05:39
Validation for Singapore NRIC and FIN number
//Based on http://www.samliew.com/icval/
function validateNRIC(str) {
if (str.length != 9)
return false;
str = str.toUpperCase();
var i,
icArray = [];
for(i = 0; i < 9; i++) {
@wsargent
wsargent / docker_cheat.md
Last active August 31, 2023 12:10
Docker cheat sheet
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@cheeaun
cheeaun / rdrc2013.md
Last active December 18, 2015 04:59
RedDotRubyConf 2013 links & resources
@dqminh
dqminh / applause_formatter.rb
Last active December 18, 2015 04:59
rspec formatter that applause you when your tests pass
require "rspec/core/formatters/progress_formatter"
class ApplauseFormatter < RSpec::Core::Formatters::ProgressFormatter
def initialize(output)
super(output)
unless File.exists? "/tmp/applause.mp3"
p "Downloading applause for awesomeness"
system "wget http://www.soundjay.com/human/applause-1.mp3 -O /tmp/applause.mp3"
end
end

Security is Hard

Massive Assignment

  • watch for ActiveRecord Relation, like has_many, has_many :through
  • watch for user_roles, `group_users
  • UPDATE action

Admin