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
#!/bin/bash | |
# | |
# This version uses September 2017 august stretch image, please use this image | |
# | |
if [ "$EUID" -ne 0 ] | |
then echo "Must be root" | |
exit | |
fi |
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
require 'io/console' | |
puts"\e[?25l\e[?1000h";at_exit{puts"\e[?25h\e[?1000l"} # no cursor, yes mouse | |
x = y = dy = ax = ay = 0; dy = dx = 0.5 | |
height, width = $>.winsize | |
def hot_cold(name, val) | |
index = (3*Math.tanh(val)).to_i+2 | |
"\e[38;5;16m" << [{r:5},{r:5,g:2},{r:4,g:4},{g:3,b:4},{b:5}] | |
.map{ |r:0,g:0,b:0| "\e[48;5;#{r*36+g*6+b+16}m" } | |
.map.with_index{|c,i| c+(i==index ? name : "-") } | |
.join << |
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
# http://blog.mixcel.io/10-ways-to-get-mixpanel-right-the-first-time-yHNlbz-wbcZz7E7PWMXvRg | |
class Analytic | |
module Mixpanelable | |
extend ActiveSupport::Concern | |
private | |
def mp_track(event_name, options = {}) | |
mp_track_for_user(current_user, event_name, options) | |
end |
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
window=0x00..... | |
opacity=30 # Something between 0 and 100 | |
xprop -id $window \ | |
-f _NET_WM_WINDOW_OPACITY 32c \ | |
-set _NET_WM_WINDOW_OPACITY $(($opacity*0xffffffff/100)) |
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 A | |
@foo = :foo | |
@@bar = :bar | |
attr_reader :foo | |
def foo | |
@foo = :bla | |
end |
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
require 'date' | |
date = DateTime.now.strftime("%Y%m%d%H%M") | |
$homedir = Dir.home | |
$dotfiles = [ '.bash_profile', '.bashrc', '.gitconfig', '.kshrc', '.profile', '.tmux.conf', '.vimrc' ] | |
desc "backup dotfiles" | |
task :backup do |t| | |
backupdir = File.join($homedir,"/",t.name) | |
backupfile = "dotfiles-home.#{date}.tar" |
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
require 'io/console' | |
class Cursor | |
class << self | |
def pos | |
res = '' | |
$stdin.raw do |stdin| | |
$stdout << "\e[6n" | |
$stdout.flush | |
while (c = stdin.getc) != 'R' |
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
module ModelForm | |
extend ActiveSupport::Concern | |
included do | |
class_attribute :model_class | |
self.model_class = self.superclass | |
end | |
module ClassMethods | |
def model_name |
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
module ApplicationHelper | |
def cache_key_for(model) | |
prefix = model.to_s.downcase.pluralize | |
count = model.count | |
max_updated_at = model.maximum(:updated_at).try(:utc).try(:to_s, :number) | |
"#{prefix}/all-#{count}-#{max_updated_at}" | |
end | |
end |
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
#!/usr/bin/env ruby | |
require 'shellwords' | |
def main | |
loop do | |
$stdout.print ENV['PROMPT'] | |
line = $stdin.gets | |
if line | |
line.strip! |