Skip to content

Instantly share code, notes, and snippets.

View rohozhnikoff's full-sized avatar

Murad R. rohozhnikoff

  • Kyiv, Ukraine
View GitHub Profile
$('<script>', {src: '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js'}).appendTo('head');
$(function(){
var arr = [];
$('*').each(function(i, el){
var classe = $(el).attr('class');
if(classe && classe.length) {
arr.push(classe.split(' '));
}
});
arr = _(arr).sortBy();
@rohozhnikoff
rohozhnikoff / gist:74a2a5ff04af6414e1c2
Created July 28, 2014 10:24
bootstrap grid standalone
//
// Grid system
// --------------------------------------------------
//## Define your custom responsive grid.
//** Number of columns in the grid.
@grid-columns: 12;
//** Padding between columns. Gets divided in half for the left and right.
@rohozhnikoff
rohozhnikoff / gist:e6f925a6b78c010f7bc1
Created August 29, 2014 22:39
keyCodes on browsers, name => code
{
"backspace": "8",
"tab": "9",
"enter": "13",
"shift": "16",
"ctrl": "17",
"alt": "18",
"pause/break": "19",
"caps lock": "20",
"escape": "27",
@rohozhnikoff
rohozhnikoff / gist:ee6a14727f0674b67b7b
Created August 29, 2014 22:40
keyCodes on browsers, code => name
{
"8": "backspace",
"9": "tab",
"13": "enter",
"16": "shift",
"17": "ctrl",
"18": "alt",
"19": "pause/break",
"20": "caps lock",
"27": "escape",
@rohozhnikoff
rohozhnikoff / equalHelper.coffee
Created September 3, 2014 13:40
block helper to check if arguments is equal
`import Em from 'ember'`
equal = (args..., options) ->
arr = for arg in args
value = @get(arg)
if typeof value isnt 'undefined' then value else arg
method = if _.isEqual.apply(_, arr) then 'fn' else 'inverse'
return options[method](@)
@rohozhnikoff
rohozhnikoff / gist:9c4c1090b2963ee0dc7f
Created September 3, 2014 13:41
simple helper to add 's' if length more then 1
`import Ember from 'ember'`
oneormany = (length, value) ->
return "There are no #{value}s" if length is 0
suffix = if length > 1 then 's' else ''
return "#{length} #{value}#{suffix}"
OneormanyHelper = Ember.Handlebars.helper 'oneormany', oneormany
`export { oneormany }`
@rohozhnikoff
rohozhnikoff / look_methods_call
Last active August 29, 2015 14:06
observe all methods calls
# hard to perfomance
className = getClassName(@)
newProto = {}
_(@__proto__).each((value, name) =>
newProto[name] = do =>
if typeof value is 'function'
return =>
consoleMe = ['>>', [className, name].join('.')]
consoleMe.push '| call with', arguments if arguments.length > 0
console.log.apply console, consoleMe
@rohozhnikoff
rohozhnikoff / findInArray.js
Last active August 29, 2015 14:07
simle and fast finder in js-array
function findInArray(array, callback) {
for (var i = 0, element = array[i], length = array.length; i < length; i++) {
if (callback.apply(callback, [element, i, array])) return element;
}
}
@rohozhnikoff
rohozhnikoff / git-backup.php
Created October 28, 2014 00:20
simple half-auto backup to git on php (just for concept)
<%
$default_branch = 'master';
$message = 'auto-commit';
if (isset($_GET['message']) && $_GET['message'] != '') {
$message = $_GET['message'];
}
$message .= 'from ' . date("Y-m-d H:i:s")
$results = array();
@rohozhnikoff
rohozhnikoff / randomize.coffee
Last active August 29, 2015 14:11
randomize
start = 10
maxV = 100000
# ---------------------------------------------
begin = process.hrtime()
getRandom = (acc, max) ->
while acc.indexOf(random) isnt -1
random = Math.floor(Math.random() * max) + 1
random