Skip to content

Instantly share code, notes, and snippets.

View k2052's full-sized avatar
🦄
awesome

K k2052

🦄
awesome
View GitHub Profile
@k2052
k2052 / Eva.rb
Created January 13, 2013 00:36
Eva Zebra In Code
class Eva < Zebra
include MongoMapper::Document
include Vegan::Powers
include MongoMapperExt::Taggable
include MongoMapper::Tweetable
## Keys
key :scarves_count, Integer, :default => 20
key :compliments_count, Integer, :default => 100
@k2052
k2052 / emacsCoreCommands.md
Created November 16, 2012 18:45
Emacs Shortcuts + Commands

Emacs Commands

Text

  • C-f: move cursor forward one char
  • C-b: mover cursor back one chart
  • C-n: mover cursor to next line
  • C-p: go to previous line
  • M-f: forward one word
  • M-b: move backward one word
@k2052
k2052 / my_template.rb
Created October 23, 2012 22:40 — forked from xavierRiley/my_template.rb
Kyan Custom Admin Template for Padrino
project :test => :shoulda, :orm => :mongomapper, :mock => :none, :script => :jquery, :renderer => :slim, :stylesheet => :compass, :admin_renderer => :erb
# include additional generators
inject_into_file destination_root('config/boot.rb'), "\# include additional generators\nPadrino::Generators.load_paths << Padrino.root('generators', 'kyan_admin_page_generator.rb')\nPadrino::Generators.load_paths << Padrino.root('generators', 'kyan_admin_generator.rb')\n\n", :before => "Padrino.load!"
require_dependencies 'kaminari', :require => 'kaminari/sinatra'
require_dependencies 'bcrypt-ruby', :require => 'bcrypt'
git :init
git :add, "."
@k2052
k2052 / CommandWithErrors.rb
Created October 12, 2012 00:07
Imperator Command With Errors
class CommandWithErrors < Imperator::Command
def initialize(*args)
super(*args)
@errors = ActiveModel::Errors.new(self)
end
end
(eval-when-compile
(require 'color-theme))
;;;###autoload
(defun color-theme-molokai ()
"Color theme based on the Molokai color scheme for vim."
(interactive)
(color-theme-install
'(color-theme-molokai
((foreground-color . "#F8F8F2")
.form-actions
== f.submit :submit, :class => 'btn'
== f.cancel :submit, :class => 'btn'
require 'mongo'
require 'mongo_mapper'
MongoMapper.connection = Mongo::Connection.new('localhost', nil)
MongoMapper.database = 'sandbox_poly'
class Commentable
include MongoMapper::Document
many :comments, :as => :commentable
@k2052
k2052 / Joomla3.0LegacyMVC.md
Created September 18, 2012 17:11
Quick Joomla 3.0 Compatibility

So you want to add Joomla! 3.0 compatibility to your component? The old MVC is still available but unfortunately, the names of the classes have changed.

Just add the following somewhere, then rename all your classes to extend the legacy classes. After that all you have to do is make sure you're not using any depreciated methods. Of course, eventually you should work on full compatibility you lazy developer!

<?php 

jimport('joomla.application.component.controller');
jimport('joomla.application.component.view');
jimport('joomla.application.component.model');
@k2052
k2052 / testParentChildMongoMapper.rb
Created August 6, 2012 19:25
Test Parent Child MongoMapper
require 'mongo_mapper'
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = 'playground'
class Parent
include MongoMapper::Document
key :name, String
many :children
end
@k2052
k2052 / haml2slimdir.sh
Created August 6, 2012 19:23
Haml 2 Slim Dir
#!/bin/bash
if [ -z "$1" ]; then
wdir="."
else
wdir=$1
fi
for f in $( find . -name '*.erb' ); do
out="${f%.erb}.haml"
if [ -e $out ]; then