This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Asmodeus | |
attr_accessor :pid_file | |
def info text | |
puts 'Asmodeus: %s' % text | |
end | |
def pid_check no_check=false | |
return unless @pid_file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for svelte js, or any othe widget provider | |
let bindSvelteToDOM = function(name, klass) { | |
DOMCustomElement.define(name, function(node, opts) { | |
node.classList.add('mounted') | |
new klass({ target: node, props: opts }) | |
}) | |
} | |
import SvelteCheckbox from './svelte/checkbox.svelte' | |
bindSvelteToDOM('s-checkbox', SvelteCheckbox) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import babel from 'rollup-plugin-babel' | |
import svelte from 'rollup-plugin-svelte' | |
import { scss } from '@kazzkiq/svelte-preprocess-scss'; | |
import nodeResolve from 'rollup-plugin-node-resolve' | |
import commonjs from 'rollup-plugin-commonjs' | |
import { terser } from 'rollup-plugin-terser' | |
import coffee from 'rollup-plugin-coffee-script' | |
import livereload from 'rollup-plugin-livereload' | |
const production = !process.env.ROLLUP_WATCH; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Thread::Simple | |
attr_accessor :que, :size, :named | |
def initialize size: 5, sleep: 0.01 | |
@sync = Mutex.new | |
@sleep = sleep | |
@size = size | |
@que = [] | |
@threds = [] | |
@named = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# asciinema rec --overwrite tmp/demo.case | |
# bash demo.bash | |
type_and_run () { | |
printf '\033[01;37m@app $\033[0m ' | |
for ((i=0; i<${#1}; i++)); do echo "after `jot -r 1 20 60`" | tclsh; printf "${1:$i:1}"; done; | |
echo; | |
$1; | |
echo; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Defines class variable | |
def Object.class_attribute name, default=nil, &block | |
raise ArgumentError.new('name must be symbol') unless name.class == Symbol | |
ivar = "@cattr_#{name}" | |
instance_variable_set ivar, block || default | |
define_singleton_method(name) do |arg=:_undefined| | |
# define and set if argument given |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class FolderModel | |
class << self | |
def find(key) | |
new(key) | |
end | |
def all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails style callbacks | |
# for controllers, execute from AppController to MainController | |
# class_callback :before | |
# before do | |
# ... | |
# end | |
# before :method_name | |
# instance = new | |
# Object.class_callback :before, instance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# call just after body tag or $ -> window.MediaBodyClass.init() | |
# sets body class for | |
# mobile to "mobile not-tablet not-desktop" | |
# tablet to "not-mobile tablet not-desktop" | |
# desktop to "not-mobile not-tablet desktop" | |
@MediaBodyClass = | |
sizes: [['mobile'], ['tablet', 767], ['desktop', 1023]] | |
init: -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
menu = HtmlMenu.new request.path | |
menu.add 'Home', '/' | |
menu.add 'People', '/people', lambda { |path| path.index('peor') } | |
menu.add 'Jobs', '/jbos' | |
menu.to_a -> [["Home", "/", false], ["People", "/people", true], ["Jobs", "/jbos", false]] | |
menu.to_h -> [{:name=>"Home", :path=>"/", :active=>true}, {:name=>"People", :path=>"/people", :active=>false}, {:name=>"Jobs", :path=>"/jbos", :active=>false}] |