Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexandr Panchenko panych

View GitHub Profile
View imba_wiki.md

Personal wiki for imba progamming languare.

Basics

yes/no = true/false.

if status >= 200
  return yes
View Karabiner-modifications-readme.md

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 Dec 16, 2017
Template for renderign scss file of svgsprite library
View svgsprite-scss-tmpl.mustache
{{!
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 Oct 23, 2016
Copy method to class in ES2015
View script.js
class A {
constructor(msg) {
this.message = msg ? msg : 'default A message'
}
sayHello(additional) {
console.log(`${this.message}${additional ? ` and ${additional}` : ''}`)
}
}
class B {
View conver-node-to-mNode.js
// 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) {
View funnyURL.js
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);
View sublime.md
@panych
panych / map.js
Last active Aug 29, 2015
Yandex Map image overlay
View map.js
// 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
Simple Python server
View server.py
#!/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
@panych
panych / snapToPixel.jsx
Last active Aug 29, 2015
snapToPixel (Illustrator script)
View snapToPixel.jsx
/*
snapToPixel.jsx
Adobe Illustrator script.
Moves any selected objects to the nearest pixel.
*/
if ( documents.length > 0 ) {
var sourceDoc = activeDocument;