Skip to content

Instantly share code, notes, and snippets.

View emdeeeks's full-sized avatar

Gareth Griffiths emdeeeks

View GitHub Profile
@ayosec
ayosec / x11-change-opacity.sh
Created September 7, 2015 18:49
X11: Set Opacity
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))
@dimroc
dimroc / analytic.rb
Last active April 23, 2023 20:52
Server side mixpanel analytics implementation in ruby. There are other simple devise controllers that are overridden omitted from gist.
# 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
@JoshCheek
JoshCheek / terminal_physics_engine.rb
Last active October 26, 2021 03:06
"Physics engine" in the terminal (https://vimeo.com/146376459)
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 <<
@Lewiscowles1986
Lewiscowles1986 / rPi3-ap-setup.sh
Last active March 31, 2025 15:46
Raspberry Pi 3 access-point-setup
#!/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
VIEW_PATH = 'lib/assets'
namespace :static do
desc 'Render all resources'
task :publicate => :environment do
resources(VIEW_PATH).each do |src, dest|
html= controller.render_to_string(file:src, layout:'application')
dirname = File.dirname(dest)
unless File.directory?(dirname)
FileUtils.mkdir_p(dirname)
@strzibny
strzibny / unused_routes.rb
Created May 5, 2016 15:21
Find unused routes in Rails
#!/usr/bin/env ruby
# Extracted from traceroute gem + checking the presence of views as well
require_relative './config/environment.rb'
class Traceroute
def initialize(app)
@app = app
end
# app/models/permissions/admin_permission.rb
module Permissions
class AdminPermission < BasePermission
def initialize(user)
allow_all
end
end
end
@JoshCheek
JoshCheek / circle.rb
Created December 3, 2016 02:03
Drawing a circle
# https://twitter.com/josh_cheek/status/804868012620779521
radius = 21
0.step by: 1 do |degrees|
angle = degrees*Math::PI/180
y = (radius * (Math.sin(angle) / 2 + 1)).to_i
x = (radius * (Math.cos(angle) / 2 + 1)).to_i
print "\e[#{y};#{2*x}HXX"
sleep 0.01
end
@dux
dux / decorator_clone.rb
Last active October 20, 2023 13:51
Simple ruby decorators with example
class DecoratorClone
def initialize(model)
@model = model
end
def method_missing(m, *args)
raise NameError, "Decorator method '#{m}' not found" unless @model.respond_to?(m)
@model.send(m, *args)
end
end
#!/usr/bin/env python
#encoding: utf-8
import os
import time
print(" _ _ ___ ______ \n" +
" (_) | / _ \ | ___ \\\n" +
" _ __ ___ _| |_ _ __ ___ / /_\ \| |_/ /\n" +
"| '_ ` _ \| | __| '_ ` _ \| _ || __/ \n" +
"| | | | | | | |_| | | | | | | | || | \n" +