Skip to content

Instantly share code, notes, and snippets.

@sinslav
sinslav / gist:4fb99bcb5d1d1718c719
Created May 21, 2015 22:22
HTML->Bootstrap empty template
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/styles.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
@sinslav
sinslav / .bashrc
Last active August 29, 2015 14:22 — forked from dmons/.bashrc
# setup color variables
color_is_on=
color_red=
color_green=
color_yellow=
color_blue=
color_white=
color_gray=
color_bg_red=
color_off=
@sinslav
sinslav / rAF.js
Last active August 29, 2015 14:23 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@sinslav
sinslav / gist:7d623ba0c7bd99940d4b
Created June 30, 2015 13:21
functional fizzbuzz
function fizzbuzz (counter) {
if ((counter % 5 === 0) && (counter % 3 === 0)) return 'fizzbuzz';
if (counter % 3 === 0) return 'fizz';
if (counter % 5 === 0) return 'buzz';
return counter;
}
function consl () {
for (var i = 1; i <= 100; i++){
console.log(fizzbuzz(i));
var valuta, sum, uah_kurs, usd_kurs, eur_kurs;
uah_kurs=1;
usd_kurs=1/28;
eur_kurs=1/32;
valuta=prompt('Какую валюту вы хотите обменять? \(usd\, uah или eur\)');
// if (valuta !== 'usd' || 'USD' || 'uah' || 'UAH' || 'EUR' ||'eur') {alert('Введите валюту в формате USD, UAH или EUR')};
sum=+prompt('Сколько у вас валюты?');
switch(valuta) {
case 'usd'||'USD': {alert('Ваши ' + sum + ' ' + valuta + ' равны ' + sum/usd_kurs + ' uah ' + ' или ' + sum/usd_kurs * eur_kurs + ' eur'); break;}
case 'uah'||'UAH': {alert('Ваши ' + sum + ' ' + valuta + ' равны ' + sum*usd_kurs + ' usd ' + ' или ' + sum*eur_kurs + ' eur' ); break;}
@sinslav
sinslav / gist:d9fb377143417c812d72
Created July 31, 2015 16:05
CSS -> component position righ side of centred block element
//styles
.abs
position absolute
.abs-helper
position relative
white-space nowrap
.abs
top 0
@sinslav
sinslav / object-watch.js
Created October 23, 2015 10:06 — forked from eligrey/object-watch.js
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
window.uniClick = if (document.ontouchstart isnt null) then 'click' else 'touchstart'
$.fn.textWidth = (text, font) ->
if (!$.fn.textWidth.fakeEl)
$.fn.textWidth.fakeEl = $('<span>').css("white-space", "pre").hide().appendTo(document.body)
$.fn.textWidth.fakeEl.text(text or this.val() or this.text()).css('font', font or this.css('font'))
return $.fn.textWidth.fakeEl.width()
function throttle(func, ms) {
var isThrottled = false,
savedArgs,
savedThis;
function wrapper() {
if (isThrottled) { // (2)
savedArgs = arguments;