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) {
@panych
panych / 1_helper.rb
Last active December 26, 2015 07:59
Block alias in Ruby on Rails
# application_helper.rb
def b(block_name, options={}, &block)
options.merge!(:body => capture(&block)) if block_given?
render :partial => block_name, :locals => options
end
@panych
panych / erb_slim_haml.erb
Last active December 26, 2015 07:29
ERB vs Slim vs Haml
<div class="dev-diagram">
<% steps.each_with_index do |step, index| %>
<% if index.even? %>
<% step_class = 'dev-diagram__step dev-diagram__step_right' %>
<% else %>
<% step_class = 'dev-diagram__step dev-diagram__step_left' %>
<% end %>
<div class="#{step_class}">
<div class="dev-diagram__ic">
@panych
panych / enable_drafts_parents
Created February 4, 2013 10:44
Wordpress. Allow to set draft page as a parent page
/*
* Allow to set draft page as a parent page
*/
add_filter( 'page_attributes_dropdown_pages_args', 'enable_drafts_parents' );
add_filter( 'quick_edit_dropdown_pages_args', 'enable_drafts_parents' );
function enable_drafts_parents( $args ) {
$args['post_status'] = 'draft,publish,pending';
return $args;
}
@panych
panych / sublime.md
Created June 1, 2015 08:14
Sublime wiki