Skip to content

Instantly share code, notes, and snippets.

View syavorsky's full-sized avatar

Sergiy Yavorsky syavorsky

View GitHub Profile
@syavorsky
syavorsky / example.ts
Created August 6, 2022 00:24
How do I do this in Java?
interface Cat {
id: number
typ: "cat"
data: {purrs: boolean}
}
interface Dog {
id: number
typ: "dog"
<script src="http://bgpatterns.com/widget.js" data-bgpatterns></script>
<script>
BGPatterns
.on('update', function(url) { document.body.style.backgroundImage = 'url(' + url + ')'; })
.on('open', function() { console.log('Open' );})
.on('close', function() { console.log('Closed' );})
.open();
</script>
@syavorsky
syavorsky / SassMeister-input.scss
Created October 29, 2015 22:15
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
// --- a3-fe ---
// uncomment one of these 2, both sjhould work
$utk-color: #444;
//$oldVarName: #555;
@syavorsky
syavorsky / parser.js
Last active September 17, 2015 05:07
'use strict';
/**
* // parser middleware
* // parse `git blame --line-porcelain` output
* app.use(function(req, res, done) {
* req
* .pipe(new Parser())
* .pipe(new Result(function(blamed) {
* req.blamed = blamed;
@syavorsky
syavorsky / 0.html
Last active December 21, 2015 09:59
<frameset cols="50%,50%">
<frame src="1.html" />
<frame src="2.html" />
</frameset>
var onload = function() {
api_ready = true;
window.CD.conf(conf);
callback();
};
script.onload = onload;
script.onreadystatechange = function() {
if ('loaded' === script.readyState) {
@syavorsky
syavorsky / gist:3720800
Created September 14, 2012 08:38
ConnectionError: Tried to read from non-existent connection
import tornadoredis
import tornado.httpserver
import tornado.ioloop
import tornado.web
import tornado.gen
class Handler(tornado.web.RequestHandler):
@syavorsky
syavorsky / champagne.js
Created July 5, 2012 14:31 — forked from mislav/champagne.js
Emulate "submit" and "change" events bubbling in IE for Prototype 1.7
/** Emulate "submit" and "change" events bubbling
*
* This plugin enables handling bubbling submit/change events by browsers which
* natively don't support this. It only augments `Element.on()` method and doesn't
* fix when this events are observed with `observe()`.
*/
;(function() {
// Technique from Juriy Zaytsev
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
function isEventSupported(eventName) {
@syavorsky
syavorsky / gist:2908981
Created June 11, 2012 07:54
PHP Singleton with child classes
<?php
abstract class ParentClass {
private static $instances = array();
function getInstance($obj) {
$class = get_called_class();
if (!array_key_exists($class, self::$instances)) {