Skip to content

Instantly share code, notes, and snippets.

View mindreframer's full-sized avatar
🎯
Focusing

Roman Heinrich mindreframer

🎯
Focusing
View GitHub Profile

HTML Building:

  • Forms:
  • Forme: Great simple form building
  • HTML
  • Tiny: Framework agnostic markup builder, useful for defining view helpers or as a micro templating dsl, plays nice with erb and haml (Examples: http://forme.heroku.com/)
@mindreframer
mindreframer / list_starred_projects_for_somebody.rb
Created January 8, 2013 12:34
somebody's starred projects
require 'dbm'
require 'github_api'
class Cache
attr_accessor :db
def initialize
@db = DBM.open('starred', 666, DBM::WRCREAT)
end
def load(key)
@mindreframer
mindreframer / recover_corrupted_files.rb
Created August 12, 2012 20:26
Restore deleted zeroed (deleted) files in Dropbox
## gem install dropbox-api
##### Dropbox
require 'dropbox-api'
## for client config:
## create Rakefile
>require "dropbox-api/tasks"
>Dropbox::API::Tasks.install
## execute: rake dropbox:authorize
Dropbox::API::Config.app_key = YOUR_API_KEY
@mindreframer
mindreframer / import_active_record_schema.rb
Created July 27, 2012 12:52
Import active_record schema without rake tasks
### sometimes your migrations don't works without already pre-populated database and your need only something to bootstrap the shell, use this script to import schema.rb without Rake-tasks and Rails!
require 'active_record'
require 'mysql2'
ROOT = File.join(File.dirname(__FILE__), '..')
DB_NAME = 'your_db_name'
['/db'].each do |folder|
$:.unshift File.join(ROOT, folder)
@mindreframer
mindreframer / gist:3187442
Created July 27, 2012 11:14
RBENV testing
https://github.com/jamis/rbenv-gemset/
Otherwise, clone rbenv-gemset to the `$HOME/.rbenv/plugins` directory:
$ mkdir -p ~/.rbenv/plugins
@mindreframer
mindreframer / gist:3181974
Created July 26, 2012 13:13
html/erb prettifying stuff
require 'timeout'
require 'htmlbeautifier'
def log(msg)
puts msg
end
view_files = Dir["app/**/**/**.erb"]
def beautify(file_name)
@mindreframer
mindreframer / cleanup_rails_views.rb
Created July 26, 2012 01:13
Cleanup views with tidy (erb)
require 'tidy'
#Tidy.path = '/opt/local/lib/libtidy.dylib' # or where ever your tidylib resides
Tidy.path = '/usr/lib/libtidy.A.dylib'
def generate(files)
tidy = Tidy.open(:show_warnings=>true) do |tidy|
tidy.options.indent = 'auto'
tidy.options.show_body_only = true
tidy.options.output_xhtml = true
ProjectRazor Image Service Web Server started and listening on:8026
Image root path: /opt/razor/image
{"@image_svc_host":"192.168.2.83","@persist_mode":"mongo","@persist_host":"127.0.0.1","@persist_port":27017,"@persist_timeout":10,"@admin_port":8025,"@api_port":8026,"@image_svc_port":8027,"@mk_tce_mirror_port":2157,"@mk_checkin_interval":60,"@mk_checkin_skew":5,"@mk_uri":"http://192.168.2.83:8026","@mk_register_path":"/razor/api/node/register","@mk_checkin_path":"/razor/api/node/checkin","@mk_fact_excl_pattern":"(^facter.*$)|(^id$)|(^kernel.*$)|(^memoryfree$)|(^operating.*$)|(^osfamily$)|(^path$)|(^ps$)|(^ruby.*$)|(^selinux$)|(^ssh.*$)|(^swap.*$)|(^timezone$)|(^uniqueid$)|(^uptime.*$)|(.*json_str$)","@mk_log_level":"Logger::ERROR","@mk_tce_mirror_uri":"http://localhost:2157/tinycorelinux","@mk_tce_install_list_uri":"http://localhost:2157/tinycorelinux/tce-install-list","@mk_kmod_install_list_uri":"http://localhost:2157/tinycorelinux/kmod-install-list","@image_svc_path":"/opt/razor/image","@register_timeout":