Skip to content

Instantly share code, notes, and snippets.

View christos's full-sized avatar

Christos Zisopoulos christos

View GitHub Profile
@christos
christos / profile_options_for_select.rb
Created July 27, 2011 13:59
Profile testing options_for_select
require 'rubygems'
require 'thread'
require 'rails/all'
require 'benchmark'
include ActionView::Helpers::FormOptionsHelper
puts "Using #{`ruby -v`}"
@choices = 700.times.collect { [(0...50).map{ ('a'..'z').to_a[rand(26)] }.join, rand(10000)] }
curl "https://raw.github.com/gist/1386087/2f757de4b575a632acc3d59c1224e2134ef7973c/ssh-copy-id" -o ~/bin/ssh-copy-id
chmod +x ~/bin/ssh-copy-id
@christos
christos / monit.conf
Created December 17, 2011 22:22 — forked from shapeshed/monit.conf
Upstart script for monit on Ubuntu 10.04
# This is an event.d (upstart) script to keep monit running.
# To install disable the old way of doing things:
#
# /etc/init.d/monit stop && update-rc.d -f monit remove
#
# then put this script here:
#
# /etc/init/monit.conf
#
# and reload upstart configuration:
@christos
christos / gist:1716942
Created February 1, 2012 13:20
Install ruby-debug19 with the latest ruby 1.9.3
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
gem install linecache19-0.5.13.gem
gem install ruby-debug-base19-0.11.26.gem -- --with-ruby-include=$rvm_path/src/`rvm current`
rm ruby-debug-base19-0.11.26.gem linecache19-0.5.13.gem
@christos
christos / gist:2037118
Created March 14, 2012 15:10
Twitter url shortener mangles iCloud journal urls
The original URL:
https://www.icloud.com/journal/#p=02&t=CAEQARoQIx7SyDPX1G1Fn4_lEqnNoA==&f=/82J93X7T25~com~apple~mobileiphoto/Public/46D1774C-ECAE-4DA5-8EEB-65793AB2EF9A.jb/index.json
...when shortened to
https://t.co/dKSWfYh
...which incorrectly expands to:
@christos
christos / README.md
Created June 15, 2012 13:26
RubyMotion runtime freeze on syntax error in an `each` block, when called from a callback

Hello everyone,

I've already asked on IRC and no one seemed to have an idea why the following is happening:

I can consistently get the RubyMotion runtime and the device to freeze when running this simple code (https://gist.github.com/2936457) with rake device and then hitting the Cancel button on the UIImagePicker. I am guessing this is related to callbacks in general, but I couldn't come up with a simpler example.

As you can see, the UIImagePicker callback method simply uses each to iterate over an array of strings, but as soon as it hits the syntax error on line 28 (putd) it stops. No exception in the logs, nothing. The process has to be killed to exit it.

Any ideas? Am I supposed to release/retain something? I know blocks are a bit tricky but I can't figure out what could possibly be causing the freeze, even if it was a NULL pointer or a missing reference

@christos
christos / osx-for-hackers.sh
Created November 13, 2015 15:40 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@christos
christos / README.md
Created November 27, 2015 15:04 — forked from wvengen/README.md
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

RSpec.configure do |config|
config.around do |example|
# For examples using capybara-webkit for example.
# Remove this if you don't use it or anything similar
if example.metadata[:js]
example.run
ActiveRecord::Base.connection.execute("TRUNCATE #{ActiveRecord::Base.connection.tables.join(',')} RESTART IDENTITY")
else
ActiveRecord::Base.transaction do
# in rails application.rb
initializer "postgresql.no_default_string_limit" do
ActiveSupport.on_load(:active_record) do
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:string].delete(:limit)
end
end