Skip to content

Instantly share code, notes, and snippets.

View anton-rudeshko's full-sized avatar
❄️
Snowflake

Anton Rudeshko anton-rudeshko

❄️
Snowflake
View GitHub Profile
@anton-rudeshko
anton-rudeshko / blogger-test.js
Created November 2, 2012 16:33
Blogger test gist
function sayHello() {
console && console.log('Hello');
}
function Person(name, age) {
this.name = name;
this.age = age;
}
var aaaa = new Person('aaaa', 12)
@anton-rudeshko
anton-rudeshko / DBConnector.java
Created November 21, 2012 12:49
АдовЪ код
public class DBConnector {
public GlobalSaver gs = new GlobalSaver();
// ...
}
public class GlobalSaver {
private static DBConnector dbc = new DBConnector();
// ...
}
@anton-rudeshko
anton-rudeshko / fun.js
Last active December 14, 2015 21:19
Всякие забавности в js
var a = [];
console.log(a == false); // true
console.log(!a == false); // true
console.log(!!a == false); // false
@anton-rudeshko
anton-rudeshko / gist:5744809
Created June 9, 2013 19:20
tracert -h 100 216.81.59.173
...
7 44 ms 47 ms 49 ms 30gigabitethernet1-3.core1.ams1.he.net [195.69.145.150]
8 56 ms 63 ms 56 ms 10gigabitethernet2-1.core1.par2.he.net [184.105.213.102]
9 134 ms 136 ms 137 ms 10gigabitethernet15-1.core1.ash1.he.net [184.105.213.93]
10 144 ms 149 ms 150 ms 10gigabitethernet1-2.core1.atl1.he.net [184.105.213.110]
11 143 ms 143 ms 143 ms 216.66.0.26
12 * * * Request timed out.
13 182 ms 183 ms 185 ms Episode.IV [206.214.251.1]
14 182 ms 183 ms 185 ms A.NEW.HOPE [206.214.251.6]
15 183 ms 183 ms 183 ms It.is.a.period.of.civil.war [206.214.251.9]
@anton-rudeshko
anton-rudeshko / version.js
Last active December 18, 2015 07:59
А как вы инкрементируете версию?
var version = '12.34';
version = (function (major, minor) {return major + '.' + (++minor); }).apply(null, version.split('.'));
console.log(version); // 12.35
<html>
<head>
<script type="text/javascript">
(function (d) {
var longTapTimer,
ael = 'addEventListener',
TAP_DELAY = 500, // ms
element = null,
onLongTap = function () {
#!/bin/bash
# Pre-commit Git hook to run JSHint on JavaScript files.
#
# If you absolutely must commit without testing,
# use: git commit --no-verify
filenames=($(git diff --cached --name-only HEAD))
which jshint &> /dev/null
if [ $? -ne 0 ];
@anton-rudeshko
anton-rudeshko / insertSeparatorSnippet.js
Created August 2, 2013 10:37
Аналог Array#join() для любых типов
function insertSeparator(array, separator) {
var index = array.length - 1;
while (index) array.splice(index--, 0, separator);
return array;
}
@anton-rudeshko
anton-rudeshko / stars.js
Last active December 21, 2015 10:39
Простой преобразователь цифрового рейтинга в дробно-звёздочный.
function modelRating(rating, maxStars) {
return Array.apply(0, new Array(maxStars || 5)).map(function(ignore, index) {
var step = rating - index;
return step >= 1 ? 'full' : step >= 0.5 ? 'half' : 'empty';
});
}
modelRating(3) // ["full", "full", "full", "empty", "empty"]
modelRating(4.5) // ["full", "full", "full", "full", "half"]
modelRating(0) // ["empty", "empty", "empty", "empty", "empty"]
function replaceUrl(key, newValue) {
var url = window.location.href,
separator = ~url.indexOf('?') ? '&' : '?',
re = new RegExp('([?&])' + key + '=(.*?)([?&]|$)', 'i'),
match = re.exec(url),
hasParam = !!match;
if (hasParam) {
if (match[2] === newValue || !newValue) {
return url.replace(re, '');