Skip to content

Instantly share code, notes, and snippets.

View DKunin's full-sized avatar
🎯
Focusing

Dmitri Kunin DKunin

🎯
Focusing
View GitHub Profile
@DKunin
DKunin / base64 encodedecode
Created December 5, 2012 16:06
base64 encode/decode
https://developer.mozilla.org/en-US/docs/DOM/window.btoa
https://developer.mozilla.org/en-US/docs/DOM/window.atob
<html>
<head>
<title>base64 Encoding/Decoding</title>
</head>
<script type="text/javascript">
<!--
@DKunin
DKunin / gist:4944646
Created February 13, 2013 13:37
UUID -generator
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
};
function guid() {
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
@DKunin
DKunin / Arrows and wheels
Last active December 17, 2015 06:08
Arrows and wheels capture for some stuff on the page
$(document).on('keydown',function(e){
document.passTime = setTimeout(function(){passMatch=""},2000);
var passWord = 'IDDQD';
var keys = {
73:"I",
68:"D",
81:"Q"
};
if(e.keyCode===73||e.keyCode===68||e.keyCode===81||e.keyCode===40){
passMatch+= keys[e.keyCode];
@DKunin
DKunin / document fragment
Created June 15, 2013 18:02
doc fragment
var somewhere = document.getElementById('here'),
fragment = document.createDocumentFragment(),
i, li;
for(i = 0; i < 1000; i++){
li = document.createElement('li');
li.innerText = i;
fragment.appendChild(li);
}
@DKunin
DKunin / drop-shadow-mixin
Created July 15, 2013 05:48
drop-shadow-mixin
.drop-shadow(@x-axis: 0, @y-axis: 1px, @blur: 2px, @alpha: 0.1) {
-webkit-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
-moz-box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
box-shadow: @x-axis @y-axis @blur rgba(0, 0, 0, @alpha);
}
.gradient(@color,@color2){
background: @color; /* Old browsers */
background: -moz-linear-gradient(top, @color 0%, @color2 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,@color), color-stop(100%,@color2)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, @color 0%,@color2 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, @color 0%,@color2 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, @color 0%,@color2 100%); /* IE10+ */
background: linear-gradient(to bottom, @color 0%,@color2 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=@color, endColorstr=@color2,GradientType=0 ); /* IE6-9 */
}
@DKunin
DKunin / flat colors
Created August 15, 2013 07:45
flat colors
var colors = [
"#7451ce",
"#563d6e",
"#ad4c4a",
"#4878a2",
"#ccd05a",
"#52b54c"
];
@DKunin
DKunin / css3.styl
Created September 9, 2013 06:40 — forked from mattmcmanus/css3.styl
Stylus mixins
// MIXINS
vendor(prop, args)
-webkit-{prop} args
-moz-{prop} args
-o-{prop} args
{prop} args
animation()
vendor('animation', arguments)
@DKunin
DKunin / gist:6806223
Last active December 24, 2015 13:39
Adding sarcasm and Irony tags to fb
javascript:(function(){function e(e){if(e.tagName==="TEXTAREA"||e.tagName==="INPUT"&&e.type==="text"){return e.value.substring(e.selectionStart,e.selectionEnd)}return null}var t=e(document.activeElement);document.activeElement.value=document.activeElement.value.replace(t.toString(),"<sarcasm>"+t.toString()+"</sarcasm>")})()
javascript:(function(){function e(e){if(e.tagName==="TEXTAREA"||e.tagName==="INPUT"&&e.type==="text"){return e.value.substring(e.selectionStart,e.selectionEnd)}return null}var t=e(document.activeElement);document.activeElement.value=document.activeElement.value.replace(t.toString(),"<irony>"+t.toString()+"</irony>")})()
@DKunin
DKunin / new_gist_file
Created October 14, 2013 11:24
Form words from array
function formatWords(words){
if (!words) return "";
return words.filter(function(a) { return a !== ''}).join(', ').replace(/(, )+(\S+)$/, ' and $2');
}