Skip to content

Instantly share code, notes, and snippets.

View shrmnk's full-sized avatar
working from home

Sherman K shrmnk

working from home
View GitHub Profile
jbielick /
Last active October 11, 2023 09:02
an Apache Airflow DAG to sync a git repository to the google cloud storage bucket for your Composer environment
from datetime import datetime, timedelta
from airflow.models import Variable
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
private_key = Variable.get("git_deploy_private_key_secret")
repo_url = Variable.get("git_remote_url")
default_args = {
Filirom1 / custom-logger.rb
Created January 12, 2017 14:41
How to customize a logger in ruby
require 'logger'
module Dim
class Logger < ::Logger
def initialize(*)
@formatter =
the-bass / application.html.erb
Last active April 15, 2020 15:01
Using Google Analytics with Rails 5 and Turbolinks 5. This code is taken from the conversation between @preetpalS and @packagethief on
<%# Put this code snippet between the <head></head>-tags in your application layout and %>
<%# replace 'UA-XXXXXXXX-X' with your own unique Google Analytics Tracking ID %>
<%# ... %>
<%# ... %>
<% if Rails.env.production? %>
<script type="text/javascript">
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
ajfisher / firmatatest.js
Last active December 22, 2019 08:15
Serial comms over hardware UART for Johnny-Five between Arduino and a Raspberry Pi
var firmata = require('firmata');
var repl = require('repl');
var board = new firmata.Board('/dev/ttyAMA0',function(err){
//arduino is ready to communicate
if (err) {
console.log("err:" + err);
console.log("Firmata Firing LEDs");
grenade /
Last active July 11, 2024 10:06
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
# generate new personal ed25519 ssh keys
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <>"
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_robtn -C "rob thijssen <>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
ssh-keygen -t ed25519 -f manta_host_ca -C
choonkeat / singapore_license_plate_validator.rb
Created July 30, 2012 15:45
rails active_model validator for singapore nric & car plate; courtesy
class SingaporeLicensePlateValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || "is not valid") unless valid_format?(value)
def valid_format?(license_plate)
prefix, numbers, suffix = license_plate.to_s.upcase.gsub(/\W+/, '').scan(/^\s*([A-Z]{1,3})(\d{1,4})(.+)$/).flatten
license_plate = ('%3s' % prefix.to_s) + ('%4d' % numbers.to_i) + suffix.to_s
zero = ('A'.ord-1).chr
numbers = []
license_plate.each_char {|char| numbers.push((num = char.ord - zero.ord) > 0 ? num : char)}