Skip to content

Instantly share code, notes, and snippets.

View sfcgeorge's full-sized avatar
🦔

Simon George sfcgeorge

🦔
View GitHub Profile
@gruber
gruber / Split Tabs to New Window.scpt
Last active April 16, 2024 20:52
An AppleScript for Safari to move all tabs in the frontmost window, from the current tab to the rightmost (last) tab, to a new window.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
(*
Original script: John Gruber (https://daringfireball.net/linked/2023/12/05/an-applescript-for-safari-split-tabs-to-new-window)
Much more elegant version: Leon Cowle (https://github.com/leoncowle)
Even more elegant version: https://stackoverflow.com/questions/54066100/applescript-to-split-safari-tabs-into-new-window/54089865#54089865
Worth a warning: "moving" tabs with this script doesn't actually move them like
drag-and-drop does. The tabs "moved" by this script will reload in the new window,
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active April 19, 2024 04:06
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@mattlockyer
mattlockyer / ga_cfw.js
Last active September 30, 2020 20:31
Google Analytics for Cloudflare Workers
/********************************
* GA data
********************************/
let data = {
v: 1,
}
/********************************
* Initializes GA data
* @param {string} tid your tracking id for GA
* @param {object} req the request object from event.request
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 28, 2024 01:45
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@kule
kule / mini_rspec.rb
Created September 11, 2018 09:37
Simplified example of how rspec works
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'colorize'
end
class MatcherInterface
def initialize(some_object)
@some_object = some_object
@stereokai
stereokai / index.css
Created June 18, 2017 11:03
Trigonometry in CSS
//----------------------------------*\
// TRIGONOMETRY FUNCTIONS
//----------------------------------*/
// # Trigonometry in CSS
//
// - Through Taylor/Maclaurin polynomial representation: http://people.math.sc.edu/girardi/m142/handouts/10sTaylorPolySeries.pdf
// - Useful if you don't want to use JS.
// - With CSS Variables.
// - `calc()` can't do power (x ^ y) so I used multiplication instead.
@hako
hako / sirius-diy-tutorial.md
Last active December 15, 2021 14:29
Installing Sirius on Mac / Linux / Raspberry Pi

Installing Sirius on Mac / Linux / Raspberry Pi

Tested working on:

  • Raspberry Pi 1 Model B+ (Using Docker hypriot/rpi-python) (debian/wheezy)
  • Raspberry Pi 2 Model B (with virtualenv)
  • Ubuntu Linux x64 (with virtualenv)
  • Ubuntu Linux x64 (Using Docker)
  • OS X Yosemite (with virtualenv)
require "./compiler/crystal/**"
while line = gets
compiler = Crystal::Compiler.new
program = Crystal::Program.new
program.target_machine = compiler.target_machine
prelude = program.normalize(Crystal::Require.new("prelude"))
@WattsInABox
WattsInABox / .gitignore
Last active March 28, 2024 04:31
Generate Static HTML Website Using Ruby on Rails
# Ignore static version of the site (used to upload error pages to S3 for Heroku errors)
/out
@ssimeonov
ssimeonov / array_validator.rb
Last active March 22, 2022 14:48
Enumerable and array validators for ActiveModel::Validations in Rails. Especially useful with document-oriented databases such as MongoDB (accessed via an ODM framework such as Mongoid).
# Syntax sugar
class ArrayValidator < EnumValidator
end