Skip to content

Instantly share code, notes, and snippets.

View NARKOZ's full-sized avatar

Nihad Abbasov NARKOZ

  • Kyiv, Ukraine
View GitHub Profile
# Controller for the LostInAspen leaf.
require 'cgi'
require 'facets/random'
class Controller < Autumn::Leaf
MESSAGES = {
/THE RULES/ =>
" ~ The Memory Management Rules everyone should know are at: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html",
@jnunemaker
jnunemaker / authentication.rb
Created July 15, 2009 03:33
a starting point for authentication with mongomapper and rails
# include this in application controller
module Authentication
protected
# Inclusion hook to make #current_user and #signed_in?
# available as ActionView helper methods.
def self.included(base)
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method
end
# Returns true or false if the user is signed in.
@alkema
alkema / seed.rake
Created August 17, 2009 04:37
rails 3 rake db:seed for now
namespace :db do
desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.'
task :reset => [ 'db:drop', 'db:setup' ]
desc 'Create the database, load the schema, and initialize with the seed data'
task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ]
desc 'Load the seed data from db/seeds.rb'
task :seed => :environment do
seed_file = File.join(Rails.root, 'db', 'seeds.rb')
<a href="http://www.google.com/" class="target-blank">Google</a>
<script type="text/javascript">
$j(document).ready(function() {
$j('a.target-blank').click(function() {
this.target = '_blank';
});
}
</script>
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
require 'ipaddr'
module Rack
#
# BanHammer is a Rack middleware app that restricts access to your server
# using a black-list of IPv4/IPv6 addresses and ranges.
#
# MIT License - Hal Brodigan (postmodern.mod3 at gmail.com)
#
# Needlessly modified by Mike Frawley
@leah
leah / gist:216443
Created October 22, 2009 23:07 — forked from steida/gist:216120
:⌉
=⌉
¦-) as opposed to |
⍥ om nom nom
@shapeshed
shapeshed / flv_convert.sh
Created November 1, 2009 10:21
Batch convert flv files to ogv and mp4 formats
#!/bin/bash
# File: flv_convert.sh
# Description: Converts flv files to ogv and mp4
#
# Copyright 2009 George Ornbo (Shape Shed)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@onewland
onewland / cron-test.js
Created November 18, 2009 03:19
simple cron API for node.js
var cron = require('./cron'), sys = require('sys');
cron.Every((2).seconds(), function() { sys.puts('Working!'); });
@kneath
kneath / _README.md
Created November 18, 2009 21:42 — forked from defunkt/bundle.rake
Intelligent asset bundling for Rails (GitHub's asset bundling)

GitHub Javascript Strategy

Unless otherwise necessary (such as mobile development), the GitHub javascript codebase is based off jQuery. You can safely assume it will be included on every page.

File naming

  • All jquery plugins should be prefixed with jquery, such as jquery.facebox
  • All github-specific jquery plugins should be prefixed with jquery.github. Like jquery.github.repo_list.js
  • All page-specific files (that only run on ONE page) should be prefixed with page. page.billing.js