Skip to content

Instantly share code, notes, and snippets.

View spajus's full-sized avatar
🌴
On vacation

Tomas Varaneckas spajus

🌴
On vacation
View GitHub Profile
#!/usr/bin/env ruby
require 'glusterfs'
50.times do
volume = GlusterFS::Volume.new('dist-volume')
volume.mount('distfs')
volume.unmount
_, size = `ps ax -o pid,rss | grep -E "^[[:space:]]*#{$$}"`.strip.split.map(&:to_i)
puts "Mem usage: #{size}"
end
require 'singleton'
require 'gosu'
class TestGameWindow < Gosu::Window
include Singleton
def initialize
super(640, 480, false)
self.caption = "Esc = quit"
end
class Player
def draw
@sprite.draw(@x, @y, 0) # Gosu::Image
# is there any way to find out value of @x and @y after all transformations it will go through?
end
end
class GameWindow < Gosu::Window
def draw
transform(@cam_x, @cam_y) do
scale(@cam_zoom_x, @cam_zoom_y, @cam_x, @cam_y) do
stack level too deep
/Users/spajus/Dropbox/rubygamedev/manuscript/code/09-polishing/game_window.rb:11:in `update'
/Library/Ruby/Gems/2.0.0/gems/gosu-0.7.50/lib/gosu/swig_patches.rb:15:in `block (2 levels) in <class:Window>'
/Library/Ruby/Gems/2.0.0/gems/gosu-0.7.50/lib/gosu/swig_patches.rb:37:in `show'
/Library/Ruby/Gems/2.0.0/gems/gosu-0.7.50/lib/gosu/swig_patches.rb:37:in `show'
09-polishing/main.rb:28:in `<main>'
@spajus
spajus / arrays.rb
Last active August 29, 2015 14:04
Ruby benchmark: call a method on every object in array.
require 'benchmark'
class Something
def initialize(stuff)
@stuff = stuff
end
def update
@stuff += 0.1
end
end
@spajus
spajus / rake.txt
Created August 17, 2014 12:17
gosu ruby app
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/spajus/.rvm/rubies/ruby-2.1.2/lib/libruby.2.1.0.dylib and UniversalRuby/libruby.2.1.0.dylib have the same architectures (x86_64) and can't be in the same fat output file
rake aborted!
Command failed with status (1): [lipo /Users/spajus/.rvm/rubies/ruby-2.1.2/...]
/Users/spajus/GitHub/ruby_app/Rakefile:19:in `merge_lib'
/Users/spajus/GitHub/ruby_app/Rakefile:49:in `block in <top (required)>'
Tasks: TOP => default => merge_current_platform_into_universal_ruby
ssh-dss AAAAB3NzaC1kc3MAAACBAIJ+UCYFJ1mKfFqORYzMYmid9DxBF3JMh8+1/qw06Y/Npi3Tjh11PDu2KXJeJ8TP3m/ZC0Tk8WgKpOE5ypMof+jq8KEmdan1qnln+b0pj4yOhNAn6QPx1PeON/ExaQWT4A5zuGUY0ozDPu6MiQ/P0AwYTXzo2obgO/2KeuO08JT3AAAAFQCLISGoMcdeXjfGHgNZRtsC+JAvkQAAAIBkDNadD8MepoLIHcK5/RfbdK8bKLb5z+WJYi6UNmevVLFK4BOq81qWqzN4k2Boe+XK6ZS8CadAHEypC52Nmp+6FXGcMGPJNONUdrzW0EfC5957ee93W5/qmScrBom0CTOtIK0Jz+0oO5h9dNkLI31hhaKc36Y/yQjdnh8epq4VyAAAAIAC0kIG8yLyc9lX21KXdh0myRcvtJhMiRRxnDbfwDkyciwicBMLpti5D8oXQ2OPOtQU3J+aNkL7efkZbkZqahtIhxbB31aTQhbF0YQO5ol6t+tIxWAgU36N5eQbN1GgHMpg/3ZX93rfreL0HBnQypwcUAHY6rxqzpxPzkUmUBib/A== tomasv
#routes.rb
get "blog/category/:category/" => "posts#by_category", as: :post_category
get "blog/category/:category/index.html" => "posts#by_category"
get "blog/page-:page/" => "posts#index", as: :blog
get "blog/page-:page/index.html" => "posts#index"
get "blog/:slug/" => "posts#by_slug", as: :post_slug
get "blog/:slug/index.html" => "posts#by_slug"
get "blog" => "posts#index", as: :blog
get "blog/index.html" => "posts#index"
``````````````````````````````````````````````````````````````````````......,::;;;''''''''++++++++++++++++++++++++++++'++''++++++++++++#++++#+++++++++++++++#
````````````````````````````````````````````````````````````````````````....,,::;;;'''''''++++++++++++++++++++++++++++++'''''+++++++++++++++++++++++++++++++#
````````````````````````````````````````````````````````````````````````....,,::;;;''''''''+++++++++++++++++++++++++++++'''''++++++++++++++++++'++++++++++++#
````````````````````````````````````````````````````````````````````````...,,,::;;;''''''''+++++++++++++'+++++++++++''++'''''''+''++'+++++++''''+++++++++++++
````````````````````````````````````````````````````````````````````````...,,,::;;;;''''''''+++++++++''+'+++++''++''''''''''''''''''''+''+++'''''++++++++++++
``````````````````````````````````````````````````````````````````````````..,,:::;;;;;;;'''''''++'''''''''''''''''''''''''''''''+''''''''''+''''''''''''+++++
```````````````````````````````````````````````````````````````````````````.
@spajus
spajus / gist:5213420
Created March 21, 2013 14:26
delete all git tags locally and remotely with exclusion list
for t in `git tag`
do
arr=("keep_this" "keep_that" "and this")
if [[ "${arr[@]}" =~ ${t} ]]; then
echo keeping $t
else
git push origin :$t
git tag -d $t
fi
done