Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
working on puppetry 2.1 - new awesome ideas

Dmitry Sheiko dsheiko

💭
working on puppetry 2.1 - new awesome ideas
View GitHub Profile
@dsheiko
dsheiko / dabblet.css
Created Apr 10, 2012
Ellipse out of an element (C) http://lea.verou.me
View dabblet.css
body {
padding: 50px;
font-family: Arial;
}
div {
color: white;
border: 2px solid white;
background: red;
border-radius: 50%;
width: 200px;
View dabblet.css
body {
padding: 50px;
font-family: Arial;
}
a {
display: inline-block;
color: black;
font-weight: bold;
text-decoration: none;
padding: 5px 10px;
View dabblet.css
body { padding: 100px; }
div {
display: inline-block;
width: auto;
text-align: center;
background-color: red;
color: white;
padding: 10px;
box-shadow: 0 0 0 5px white, 0 0 0 10px black, 0 0 0 15px gold;
}
@dsheiko
dsheiko / prefixed-css-properties
Created May 10, 2012
Allows you to deal with prefixed properties in jQuery
View prefixed-css-properties
(function( $, document, window ) {
var _isPropertySupported = function(prop) {
var vendorProp, supportedProp,
capProp = prop.charAt(0).toUpperCase() + prop.slice(1),
prefixes = [ "Moz", "Webkit", "O", "ms", "Khtml", "Icab" ],
div = document.createElement( "div" );
if ( prop in div.style ) {
supportedProp = prop;
} else {
@dsheiko
dsheiko / sleep.js
Created May 10, 2012
JS port of PHP's sleep function
View sleep.js
var sleep = function(millis) {
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < millis);
return this;
}
sleep(1500).alert("Script is released");
@dsheiko
dsheiko / object-create-from-module.js
Created May 24, 2012
Prototypal Inheritance for Modules
View object-create-from-module.js
/**
* Prototypal Inheritance for Modules
*
* Prototypal inheritance in its generic case was described by Douglas Crockford at http://javascript.crockford.com/prototypal.html
* However it doesn't work with modules (http://addyosmani.com/largescalejavascript/). This implementation allows to inherit from modules
*
* @author Dmitry Sheiko
* @version object-create-from-module.js, v 1.0
* @license MIT
* @copyright (c) Dmitry Sheiko http://dsheiko.com
@dsheiko
dsheiko / placeholder.js
Created Aug 15, 2012
Emulates H5Forms placeholders on legacy browsers
View placeholder.js
/*
* Emulates H5Forms placeholders on legacy browsers
*
* <input placeholder="Search" />
*
* @author $Author: sheiko $
* @license MIT
* @copyright (c) Dmitry Sheiko http://www.dsheiko.com
*/
View Asynchronous Observable
async function* getStocksStream() {
var reader = new AsyncFileReader(“stocks.txt”);
try {
while(!reader.eof) {
var line = await reader.readLine();
await yield JSON.parse(line);
}
}
finally {
await reader.close();
@dsheiko
dsheiko / index.html
Last active Mar 8, 2018
Service-worker to prefetch remote images (with expiration) and respond with fallback one when image cannot be fetched
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Service-worker demo</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
if ( "serviceWorker" in navigator ) {
View pre-commit
#!/bin/bash
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".*Marketplace.*\.js$")
if [[ "$STAGED_FILES" = "" ]]; then
exit 0
fi
PASS=true