Skip to content

Instantly share code, notes, and snippets.

View eddix's full-sized avatar

eddix eddix

  • Beijing
  • 06:58 (UTC +08:00)
View GitHub Profile
@eddix
eddix / gist:1922644
Created February 27, 2012 09:07
TextMate 2 .tm_properties

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

@eddix
eddix / _methods.scss
Created May 3, 2012 10:44
mixins for css3
@mixin rounded-corners ($radius: 5px) {
border-radius: $radius;
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
}
@mixin rounded_corner ($side: left, $radius: 5px) {
border-#{$side}-radius: $radius;
-webkit-border-#{$side}-radius: $radius;
-moz-border-#{$side}-radius: $radius;
@eddix
eddix / application.rb
Created January 18, 2013 09:04
customize field error proc
# config/application.rb
config.action_view.field_error_proc = Proc.new { |html_tag, instance|
"#{html_tag}".html_safe
}
@eddix
eddix / form_builder.rb
Created January 18, 2013 09:06
customize f.label in Rails
# config/initializers/form_builder.rb
class ActionView::Helpers::FormBuilder
alias :origin_label :label
def label(method, content_or_options = nil, options = nil, &block)
if content_or_options && content_or_options.class == Hash
options = content_or_options
else
content = content_or_options
@eddix
eddix / update_password.rb
Created March 11, 2013 07:03
Update password in devise. Integrated with Grape::Entities
if current_user.update_with_password({:current_password => params[:current_password], :password => params[:password]})
current_user.reset_authentication_token!
present current_user, :with => APIEntities::User
else
present current_user, :with => APIEntities::UserError
end
@eddix
eddix / object.lua
Created March 20, 2013 01:45
Lua Object Prototype
-- Lua Object Prototype
Robot = {name = "Eddix", id = 001}
function Robot:new()
self.__index = self
local t = setmetatable({}, self)
return t
end
@eddix
eddix / app_path.c
Created March 22, 2013 07:44
get application real path in c. it needs argv[0].
/* app_path
*
* get application path, it need argv[0], and store the result to path.
*
* */
char * app_path(char * path, const char * argv0)
{
char buf[PATH_MAX];
char * pos;
if (argv0[0] == '/') { // run with absolute path
@eddix
eddix / nginx.conf
Created May 15, 2013 10:28
capstrino + unicorn + nginx
upstream mostor_backend {
server unix:/tmp/unicorn.mostor-website.sock fail_timeout=0;
}
server {
listen 80;
root /home/work/www/mostor/current/public/;
client_max_body_size 1000m;
location ^~ /assets/ {
@eddix
eddix / gist:6619826
Created September 19, 2013 06:43 — forked from dhh/gist:1014971
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
" .vimrc by eddix
" $ git clone http://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" $ PluginInstall
if has("gui_macvim")
" cancel default hot-key
let macvim_skip_cmd_opt_movement = 1
let macvim_hig_shift_movement = 1
set transparency=2