Skip to content

Instantly share code, notes, and snippets.

View ChillyBwoy's full-sized avatar
🕶️
(ノ ˘_˘)ノ ζ|||ζ ζ|||ζ ζ|||ζ

Eugene Cheltsov ChillyBwoy

🕶️
(ノ ˘_˘)ノ ζ|||ζ ζ|||ζ ζ|||ζ
  • 東京都
View GitHub Profile
@ChillyBwoy
ChillyBwoy / plural.js
Created October 25, 2010 16:02
plural ru
var pluralRu = function pluralRu(value) {
if (arguments.length != 4) throw "Wrong number of arguments"
var number = Math.abs(value),
one = arguments[1] || '', two = arguments[2] || '', five = arguments[3] || '';
number %= 100;
if (number >= 5 && number <= 20) return five;
number %= 10;
if (number == 1) return one;
if (number >= 2 && number <= 4) return two;
@ChillyBwoy
ChillyBwoy / gist:646974
Created October 26, 2010 14:16
Check for a leap year
Date.prototype.leap = function(){
var year = this.getFullYear();
return (!(year % 4) && (year % 100) || !(year % 400));
};
@ChillyBwoy
ChillyBwoy / in_groups_of.js
Created May 31, 2011 00:39
inGroupsOf function from prototype.js implementation for underscore.js
_.mixin({
inGroupsOf: function(array, number, fillWith) {
fillWith = fillWith || null;
var index = -number, slices = [];
if (number < 1) return array;
while ((index += number) < array.length) {
var s = array.slice(index, index + number);
while(s.length < number)
@ChillyBwoy
ChillyBwoy / LICENSE.txt
Created May 31, 2011 00:43 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@ChillyBwoy
ChillyBwoy / extends.js
Created June 5, 2011 22:59
JavaScript inherit
/* simple */
var extends = function(child, parent) {
var F = function() { }
F.prototype = parent.prototype
child.prototype = new F()
child.prototype.constructor = child
child.superclass = parent.prototype
}
/* from CoffeeScript */
@ChillyBwoy
ChillyBwoy / app.coffee
Created June 10, 2012 12:19
call function one per second
oneTimePer = (ms, func) ->
ms or (ms = 1000)
->
self = arguments.callee
self._lastTimeCalled = new Date unless self.hasOwnProperty("_lastTimeCalled")
if new Date - self._lastTimeCalled > ms
self._lastTimeCalled = new Date
func.apply this, arguments
myFunc = oneTimePer 2000, (x, y) -> x + y
@ChillyBwoy
ChillyBwoy / grid.scss
Last active October 11, 2015 01:38
960gs in SCSS mixin
$page_width: 850px;
@function grid_width($width, $margin, $columns) {
@return ($width - ($margin * ($columns - 1))) / $columns;
}
@mixin grid-column($columns, $prefix, $sufix, $gutter, $border_right, $border_left, $cw, $cm) {
$width: (($cw + $cm) * $columns) - $cm;
$prefix_width: ($cw + $cm) * $prefix;
$sufix_width: ($cw + $cm) * $sufix;
@ChillyBwoy
ChillyBwoy / server.sh
Last active October 13, 2015 14:18
django server script
#!/usr/bin/env bash
set -e
SETTINGS=$2
DB_USER="dbuser"
DB_NAME="dbname"
DB_PASS="dbpass"
DB_HOST=localhost
@ChillyBwoy
ChillyBwoy / fest.pegjs
Created October 20, 2015 10:51
peg.js rules for parsing fest-templates
start =
element
validchar = [0-9a-zA-Z\-_\{\}\.\:\/]
_ = [ \t\r\n]*
tagAttrs =
_ name:validchar+ '="' value:validchar+ '"' _ {
@ChillyBwoy
ChillyBwoy / index.js
Created January 20, 2016 13:55
FizzBuzz
// with array. More more more faster
Array.apply(null, Array(100)).map((_, i) => {
var n = i + 1;
return (n % 3 === 0 && n % 5 === 0 ? 'FizzBuzz' :
(n % 3 === 0 ? 'Fizz' :
(n % 5 === 0 ? 'Buzz' : n)))
});
// with recursion
const fizzBuzz = (size, acc = []) => {