Skip to content

Instantly share code, notes, and snippets.

@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
@leon
leon / ui-router-resolve.js
Created September 13, 2013 13:47
ui-router resolve
$stateProvider.state('main', {
abstract: true,
url: '/:account',
resolve: {
auth: function ($q, $state, $stateParams, $location, AccountRepo, Security) {
return AccountRepo.auth().then(function (user) {
// If not logged in redirect to login with path preserved
if (user === false) {
$state.go('account.login', {redirect: $location.url()});
return $q.reject('not logged in');
@henrik
henrik / rules.md
Last active May 23, 2022 12:31
Sandi Metz' four rules from Ruby Rogues episode 87. Listen or read the transcript: http://rubyrogues.com/087-rr-book-clubpractical-object-oriented-design-in-ruby-with-sandi-metz/
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.

@funny-falcon
funny-falcon / changes.md
Last active March 23, 2024 05:53
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@1st8
1st8 / gist:3128135
Created July 17, 2012 08:47
God process monitoring + Upstart + rbenv
description "God Process Monitoring"
author "Christoph Geschwind <christoph@mixxt.net>"
start on runlevel [2345]
stop on runlevel [!2345]
respawn # respawn the service if it dies
respawn limit 5 10 # stop respawning if it fails 5 times in 10 seconds
pre-start script
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@nogweii
nogweii / sysctl.changed.conf
Created February 22, 2012 20:30
A massive collection of various sysctl files, designed for drop-in CCDC fixing
fs.file-max = 65535
fs.inode-max = 32768
fs.suid_dumpable = 0
kernel.core_uses_pid = 1
kernel.exec-shield = 1
kernel.maps_protect = 1
kernel.msgmax = 65536
kernel.msgmnb = 65536
kernel.panic = 30
kernel.panic_on_oops = 30
@chetan
chetan / yardoc_cheatsheet.md
Last active May 4, 2024 11:12
YARD cheatsheet
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

require "uri"
(URI::REGEXP.constants - ["PATTERN"]).each do |rc|
puts "#{rc}: #{URI::REGEXP.const_get(rc)}"
end
URI::REGEXP::PATTERN.constants.each do |pc|
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}"
end