Skip to content

Instantly share code, notes, and snippets.

View lgmkr's full-sized avatar
🏠
Working from home

Oleh Makarov lgmkr

🏠
Working from home
View GitHub Profile
@lgmkr
lgmkr / gist:5014429
Last active December 14, 2015 02:29
Fun with Ruby Block Parameters
blk = ->list = (default = true; [1, 2, 3]) {puts default, list}
blk.([4,5,6])
4
5
6
=> nil
pry(main)> blk.()
true
1
@lgmkr
lgmkr / gist:4988297
Created February 19, 2013 18:04
zsh theme
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[green]%}$(rvm-prompt) %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@lgmkr
lgmkr / backbone-tutorial.js
Created August 30, 2012 15:42 — forked from jacob414/backbone-tutorial.js
Minimal example of data handling in Backbone.js
/* Scaled-down Backbone.js demonstration
* By Jacob Oscarson (http://twitter.com/jacob414), 2010
* MIT Licenced, see http://www.opensource.org/licenses/mit-license.php */
$(function() {
window.ulog = function(msg) { $('#log').append($('<div>'+msg+'</div>')); }
// Faking a little bit of Backbone.sync functionallity
Backbone.sync = function(method, model, succeeded) {
ulog('<strong>'+method + ":</strong> " + model.get('label'));
if(typeof model.cid != 'undefined') {
@lgmkr
lgmkr / backbone.rails.js
Created August 28, 2012 15:15 — forked from trydionel/backbone.rails.js
Makes Backbone.js play nicely with default Rails setup
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
@lgmkr
lgmkr / gist:3415106
Created August 21, 2012 12:50 — forked from ValeriiVasin/gist:1548808
[javascript patterns] Javascript inheritance.
var inherit = (function () {
var F = function () {};
return function (C, P) {
F.prototype = P.prototype;
C.prototype = new F();
C.uber = P.prototype;
C.prototype.constructor = C;
};
}());
@lgmkr
lgmkr / patterns.js
Created August 21, 2012 12:49
JavaScript Patterns
/**
* @memberOf __module
* @type module
*/
var module = (/** @constructor */ function() {
function privateMethod() {
...
}
@lgmkr
lgmkr / patterns.js
Created August 21, 2012 12:49
JavaScript Patterns
// source: http://webreflection.blogspot.com/2011/11/few-javascript-patterns.html
// duck typing ( maybe all you need )
var me = {name: "WebReflection"};
// basic class
function Person() {}
Person.prototype.getName = function () {
return this.name;
};
@lgmkr
lgmkr / patterns.js
Created August 21, 2012 12:43 — forked from jcleveley-zz/patterns.js
Javascript patterns
// namespace - single global variable for all news JS
var news = news || {};
// Example of a singleton as a revealing module
// When you only need one of something
news.preferences = (function (app, global) {
// Private variables
var persistent = true;
@lgmkr
lgmkr / git-rebase.markdown
Created August 21, 2012 08:51 — forked from tmcgilchrist/git-rebase.markdown
Git rebase workflow

Checkout a new working branch

 git checkout -b <branchname>

Make Changes

 git add
 git commit -m "description of changes"

Sync with remote

@lgmkr
lgmkr / gist:3413668
Created August 21, 2012 08:48 — forked from dmexe/gist:1508019
Git workflow

После установки

Указываем свое имя и почту

git config --global user.name "Your Name Comes Here"
git config --global user.email [email protected]

Делаем алиасы на команды