Skip to content

Instantly share code, notes, and snippets.

View dru's full-sized avatar

Andrii Melnyk dru

  • Unteleported.com
  • Kyiv, Ukraine
View GitHub Profile
@dru
dru / gist:99866
Created April 22, 2009 15:47
Pure & simple O3D example. Without helper js libraries.
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<object id="o3d" type="application/vnd.o3d.auto" style="width: 500px; height: 500px; "></object>
<div style="display:none">
<!-- Start of effect -->
// ==UserScript==
// @name SpyMaster Bot
// @namespace jadi
// @description Simple bot that plays spymaster for you while you're away. Leave your browser window open on the tasks screen and this will perform tasks for you every minute.
// @include http://playspymaster.com/tasks
// @include http://www.playspymaster.com/tasks
// ==/UserScript==
/*
* jQuery JavaScript Library v1.3.2
#!/usr/bin/ruby
# Супер рекурсивный индексер. Версия 3
def recurse_dir(o, dirname)
entries = Dir.entries(dirname)
directories = entries.find_all {|e| FileTest.directory? File.join(dirname, e)}.sort{|a,b| a.gsub(/[^0-9A-z]/, "").to_i <=> b.gsub(/[^0-9A-z]/, "").to_i}
files = entries.find_all {|e| FileTest.file? File.join(dirname, e)}.sort{|a,b| a.gsub(/[^0-9A-z]/, "").to_i <=> b.gsub(/[^0-9A-z]/, "").to_i}
directories.reject! {|a| a =~ /^\./}
# To make irb UTF-8 input work on Mac OS X Snow Leopard
$ sudo port install readline
$ svn co http://svn.ruby-lang.org/repos/ruby/tags/v1_8_7_72/ext/readline/ readline
$ cd readline
$ curl http://pastie.textmate.org/pastes/168767/download | patch readline/extconf.rb
$ ruby extconf.rb
$ make
$ sudo make install
@dru
dru / gist:1097090
Created July 21, 2011 12:27
compile geos with macports 2.0.0-rc1 on 10.7 lion
sudo port install geos configure.cc=gcc-4.2 configure.cxx=g++-4.2
@dru
dru / nginx_rails_3_1
Created March 14, 2012 12:47 — forked from shapeshed/nginx_rails_3_1
Nginx Config for Rails 3.1 with Unicorn and Asset Pipeline
upstream app {
server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.app.com;
rewrite ^/(.*) http://app.com/$1 permanent;
}
server {
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do
@dru
dru / active_admin_mongomapper_patches.rb
Created April 10, 2012 15:45 — forked from larsrottmann/active_admin_mongomapper_patches.rb
Enable basic MongoMapper support in ActiveAdmin
# config/initializers/active_admin_mongomapper_patches.rb
require "active_admin"
require "active_admin/resource_controller"
require 'ostruct'
module ActiveAdmin
class Namespace
# Disable comments
def comments?
@dru
dru / Rakefile
Created April 12, 2012 17:53 — forked from jeffreyiacono/Rakefile
rake task for precompiling assets using sprockets within a sinatra app + view helpers
require 'rubygems'
require 'bundler'
Bundler.require
require './application'
namespace :assets do
desc 'compile assets'
task :compile => [:compile_js, :compile_css] do
end
@dru
dru / gist:2642796
Created May 9, 2012 07:54
Rotate board puzzle
require 'rubygems' # sudo gem install gosu --no-ri --no-rdoc
require 'gosu'
class Board < Array
def rotate cw = false
rotated = if cw
transpose.map(&:reverse)
else
transpose.reverse