Skip to content

Instantly share code, notes, and snippets.

View zvlex's full-sized avatar

Aleksandre Zutikov zvlex

View GitHub Profile
@zvlex
zvlex / .emacs
Last active August 29, 2015 14:12
;; MELPA
(require 'package) ;; You might already have this line
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
;; Hide menu and tool bar
(menu-bar-mode -1)
@zvlex
zvlex / mash.rb
Last active August 29, 2015 14:12
my Hashie Mash basic implementation
class Mash
def initialize
@mash = {}
end
def method_missing(method_id, *args)
string_method = method_id.to_s
if is_predicate?(method_id)
key = string_method[0...-1]
@zvlex
zvlex / gist:f8ed7a8673f79d62b7ae
Created October 14, 2014 20:43
URI Regexp for Rails 4
/\A(http|https):\/\/(([a-z0-9]+\:)?[a-z0-9]+\@)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?\z/ix
@zvlex
zvlex / rename.sh
Created September 22, 2014 07:14
Rename all *.txt to *.text
# Rename all *.txt to *.text
for f in *.txt; do
mv -- "$f" "${f%.txt}.text"
done
{
"cmd": ["/home/zvlex/.rvm/bin/rvm-auto-ruby", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
@zvlex
zvlex / Preferences.sublime-settings
Last active August 29, 2015 14:06
Ruby build system for sublime text 2, utf-8 fixed.
{
"default_encoding": "UTF-8",
"tab_size": 2,
"translate_tabs_to_spaces": true,
"theme": "Soda Dark.sublime-theme",
"soda_folder_icons": true,
"ignored_packages":
[
"Vintage"
],
doctype html
/[if lt IE 7]
| <html class="ie6">
/[if IE 7]
| <html class="ie7">
/[if IE 8]
| <html class="ie8">
/[if IE 9]
| <html class="ie9">
| <!--[if (gte IE 9)|!(IE)]<!--> <html> <!--<![endif]-->
# This snippet shows how TokenAuthenticatable works in Devise today.
# In case you want to maintain backwards compatibility, you can ditch
# devise's token mechanism in favor of this hand-rolled one. If not,
# it is recommended to migrate to the mechanism defined in the following
# snippet (2_safe_token_authenticatable.rb).
#
# In both snippets, we are assuming the User is the Devise model.
class User < ActiveRecord::Base
# You likely have this before callback set up for the token.
before_save :ensure_authentication_token
@zvlex
zvlex / Rakefile
Created May 22, 2014 17:59
Jekyll-s rake post:new
namespace :post do
desc 'create a new jekyll post'
task :new do
title = ENV['title']
time = Time.now
slug = "#{time.strftime("%Y-%m-%d")}#{title.downcase.gsub(/[^\w]+/, '-')}"
file = File.join(
File.dirname(__FILE__),
'_posts',
@zvlex
zvlex / application.rb
Created April 30, 2014 10:00
/lib/tasks/ckeditor.rake
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
config.assets.precompile += Ckeditor.assets
config.assets.precompile += %w(ckeditor/*)