Skip to content

Instantly share code, notes, and snippets.

@panych
panych / happymeeple_glastonbury.us.js
Last active December 16, 2022 22:02
Glastonbury helper for site happymeeple.com
// ==UserScript==
// @name Glastonbury helper
// @namespace http://tampermonkey.net/
// @version 1.1
// @description
// @author a.s.panchenko@gmail.com
// @match https://www.happymeeple.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=happymeeple.com
// @grant none
// ==/UserScript==

Personal wiki for imba progamming languare.

Basics

yes/no = true/false.

if status >= 200
  return yes
@panych
panych / Karabiner-modifications-readme.md
Last active January 29, 2018 20:55
Karabiner modifications

My personal modifications for Karabiner

Reference: https://pqrs.org/osx/karabiner/json.html

  1. Add panych.json to ~/.config/karabiner/assets/complex_modifications
  2. Activate in Karabiner menu: Complex Modifications / Add rule
@panych
panych / svgsprite-scss-tmpl.mustache
Last active December 16, 2017 12:43
Template for renderign scss file of svgsprite library
{{!
Template for rendering .scss sprite file of svg sprite library (https://github.com/jkphl/svg-sprite).
Author: Panchenko Alexandr (github.com/panych)
source: https://gist.github.com/panych/b83287549f77535c08e8878a2c9e9e33
This template:
1. Resolve issue with default padding model of svg-sprite library (https://github.com/jkphl/svg-sprite/issues/200). You have "real" margins
2. Uses px instead of % in background-position
3. Doesn't create ready to use classes, like `.icon-search`, but has mixin for that.
@panych
panych / script.js
Last active October 23, 2016 12:58
Copy method to class in ES2015
class A {
constructor(msg) {
this.message = msg ? msg : 'default A message'
}
sayHello(additional) {
console.log(`${this.message}${additional ? ` and ${additional}` : ''}`)
}
}
class B {
@panych
panych / conver-node-to-mNode.js
Last active August 8, 2016 09:30
Mithril Wiki
// Convert node to mithril fragment (mNode)
var DOMFragment = function(markup) {
if (markup.indexOf("<!doctype") > -1) return [new DOMParser().parseFromString(markup, "text/html").childNodes[1]]
var container = document.createElement("div");
container.insertAdjacentHTML("beforeend", markup);
return container.childNodes;
}
var VirtualFragment = function recurse(domFragment) {
function funnyURL(word, interval, prevID) {
prevID = prevID ? prevID : this.prevID; // assume that undefined is OK
clearInterval(prevID);
var i = 0, ID;
ID = setInterval(function() {
history.replaceState(null, '', word.slice(0,i+1));
i = i+1;
if (i >= word.length) clearInterval(ID);
}, interval);
@panych
panych / sublime.md
Created June 1, 2015 08:14
Sublime wiki
@panych
panych / map.js
Last active August 29, 2015 14:21
Yandex Map image overlay
// 1. Variant. Use existing pane element. Can overlay map objects like placemark, ballons.
// https://tech.yandex.ru/maps/doc/jsapi/2.0/ref/reference/map.pane.Manager-docpage/
map.panes.get('events').getElement().style.backgroundImage = 'my/background/image.png';
// 2. Variant. Create custom element. Pros: set z-index.
var patternEl = document.createElement('div');
patternEl.className = 'map__pattern';
myMap.panes.getInnerElement().appendChild(patternEl);
// then you add styles like:
// .map__pattern {
@panych
panych / server.py
Created May 26, 2015 08:23
Simple Python server
#!/usr/bin/python
"""
(https://snipt.net/raw/f8ef141069c3e7ac7e0134c6b58c25bf/?nice)
Save this file as server.py
>>> python server.py 0.0.0.0 8001
serving on 0.0.0.0:8001
or simply