Skip to content

Instantly share code, notes, and snippets.

View andreif's full-sized avatar
👾
invading spaces

Andrei Fokau andreif

👾
invading spaces
View GitHub Profile
http://xrvg.rubyforge.org/
XRVG stands for "eXtended Ruby Vector Graphics". The purpose of this project is to define and implement a high-level and powerful programming environment for vector graphics generation.
XRVG does not consist in "yet another" graphical front end to draw vector graphics. XRVG even does not produce images by itself.
XRVG must rather be viewed as an abstract and computational way of designing graphics by programmatic means (see philosophy for further discussion).
XRVG is a Ruby extension, that generates SVG content.
http://rubyforge.org/projects/ruby-gd/
http://rgplot.rubyforge.org/
class ERB
class Compiler
def compile(s)
enc = s.encoding
raise ArgumentError, "#{enc} is not ASCII compatible" if enc.dummy?
s = s.dup.force_encoding("ASCII-8BIT") # don't use constant Enoding::ASCII_8BIT for miniruby
enc = detect_magic_comment(s) || enc
out = Buffer.new(self, enc)
@andreif
andreif / gist:666142
Created November 7, 2010 14:13
A better alternative to MATLAB's disp()
function pr(varargin)
if nargin == 0, return, end % stop if no arguments
% check if the first argument is a string with output format:
if ischar(varargin{1}) && ~isempty(regexp(varargin{1},'\%[^\s]','ONCE'))
cmd = 'sprintf(varargin{1}';
for i=2:nargin,
if iscell(varargin{i}),
% if an argument is a cell array, then consider it as collected parameters:
for j=1:length(varargin{i})
cmd = sprintf('%s, varargin{%d}{%d}', cmd, i, j);
@andreif
andreif / sort_test.rb
Created May 23, 2011 16:44
Problem with sorting algorithm in RailsWizard
require 'yaml'
require 'pp'
hash = YAML.load '
a:
after:
before:
l:
after:
before:
n:
@andreif
andreif / db.rake
Created July 25, 2011 09:19 — forked from ches/db.rake
Rake task to open MongoDB console for a Rails app with Mongoid
namespace :db do
desc 'Open a MongoDB console with connection parameters for the current Rails.env'
task :console => :environment do
conn = Mongoid.master.connection
opts = ''
opts << ' --username ' << conn.username if conn.username rescue nil
opts << ' --password ' << conn.password if conn.password rescue nil
opts << ' --host ' << conn.host
opts << ' --port ' << conn.port.to_s
system "mongo #{opts} #{Mongoid.master.name}"
@andreif
andreif / .irbrc
Created July 25, 2011 09:20 — forked from ches/gist:630625
.irbrc for logging goodies like SQL/Mongo queries to $stdout if in Rails 3 console
# .irbrc to log goodies like SQL/Mongo queries to $stdout if in Rails 3 console
if defined?(Rails) && Rails.respond_to?(:logger)
require 'logger'
Rails.logger = Logger.new($stdout)
if defined?(Mongoid)
Mongoid.logger = Rails.logger
end
end
@andreif
andreif / bootstrap.sh
Created August 19, 2011 19:46 — forked from anonymous/bootstrap.sh
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@andreif
andreif / django-heroku.log
Created August 19, 2011 19:56
Django on Heroku log
https://raw.github.com/gist/866c79035a2d066a5850/c1b28c7d756aa87217923020b663601e1c6b7281/README.txt
~/app $ virtualenv --no-site-packages .
~/app $ bin/pip install Django psycopg2
~/app $ bin/pip freeze > requirements.txt
~/app $ bin/django-admin.py startproject mysite
~/app $ cat >.gitignore <<EOF
@andreif
andreif / bootstrap.sh
Created August 19, 2011 19:56 — forked from utsengar/bootstrap.sh
Django on Heroku with Postgres, Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@andreif
andreif / create_django_heroku_project.sh
Created August 19, 2011 19:57 — forked from tkopczuk/create_django_heroku_project.sh
Script to create a new Heroku-ready Django project.
#!/bin/bash
mkdir prancing_heroku
cd prancing_heroku
django-admin.py startproject prancing_heroku
echo "Django==1.3" > requirements.txt
echo "psycopg2" >> requirements.txt
echo "web: prancing_heroku/run_heroku_run.sh" > Procfile