Skip to content

Instantly share code, notes, and snippets.

View NARKOZ's full-sized avatar

Nihad Abbasov NARKOZ

  • Kyiv, Ukraine
View GitHub Profile
@jeremy
jeremy / gist:4211803
Created December 5, 2012 03:05
Template- and asset-aware ETags

Declared ETags, together with Russian Doll caching, can be used to automatically mix your template and asset versions into the ETags set in your controllers. This avoids the need to blow all browser caches on each deploy and neatly contains the scope of "freshness fallout" when you tweak a view.

To include the template's version in the ETag:

  # Incorporate the cache version for this action into our ETag.
  # This allows template changes to bubble up into HTTP cache
  # freshness and bust browser caches when we make changes.
  etag do
    begin
class Color
@regex: /(?:#([0-9a-f]{3,6})|rgba?\(([^)]+)\))/i
@fromHex: (hex) ->
if hex[0] is '#'
hex = hex.substring(1, 7)
if hex.length is 3
hex = hex.charAt(0) + hex.charAt(0) +
hex.charAt(1) + hex.charAt(1) +
@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.

@masuidrive
masuidrive / github-reporter.rb
Created November 22, 2012 15:00
JenkinsのPost build actionでgithubにコメントするスクリプト
#!/usr/bin/ruby
# require json gem. doen't support Ruby 1.8 bundled json library
#
# ex) /Users/Shared/Jenkins/Home/github-reporter.rb mobiruby mruby-cfunc "$GIT_COMMIT" "\*\*\* Passed tests \*\*\*"
require 'rubygems'
require 'yaml'
require 'github_api'
config = YAML.load(File.read(File.expand_path("~/.github.yml")))
anonymous
anonymous / upload.rb
Created November 5, 2012 16:35
Sinatra Upload
require 'rubygems'
require 'sinatra'
include FileUtils::Verbose
get '/up' do
erb :form
end
post '/up' do
tmpfile = params[:file][:tempfile]
@wesgarrison
wesgarrison / gist:3921560
Created October 20, 2012 01:10
October 19 2012 - rubygems.org - notes on server

[transcript from http://www.youtube.com/watch?v=z73uiWKdJhw and irc]

Why is the server unhappy?

  • Bundle API is 70%-80% of traffic and it has to resolve the dependency graph and Marshal
  • x Processes are spinning in Ruby with 380% (of 400% total CPU [4 x 100%])
  • x Bundle can only use vanilla gems, so that's why we have to use Marshal
  • Redis Heapsize
  • Diskspace

Timing - middle of the day US

@SaitoWu
SaitoWu / apply_patch.rb
Created October 8, 2012 17:31
grit patch apply
require'grit'
repo = Grit::Repo.new(".") #=> #<Grit::Repo "/Users/saito/hanwen/.git">
# check_applies => 0(can apply) or 1(can not)
repo.git.check_applies("master", "new") #=> 0
patch = repo.git.get_patch("new") #=> raw_patch
# apply_patch => tree_sha
repo.git.apply_patch("master", patch) #=> "c9a4861d9b3229974a0b1b05b87583ab3a887629"
# commit => commit_sha
# commit_message, array_of_commit, actor, tree_sha, head
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@miketheman
miketheman / Gemfile
Last active October 11, 2015 01:48
API-based addition of hooks to your repos
gem "octokit", "~> 1.24.0"
@joho
joho / gist:3735740
Created September 17, 2012 05:40 — forked from rafaelss/gist:3700977
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/