Skip to content

Instantly share code, notes, and snippets.

View masukomi's full-sized avatar

masukomi (a.k.a. Kay Rhodes) masukomi

View GitHub Profile
@masukomi
masukomi / example_activejob.rb
Created January 11, 2023 15:12 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
@masukomi
masukomi / ssl_puma.sh
Last active November 12, 2021 22:08 — forked from defong/ssl_puma.sh
[RoR] localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@masukomi
masukomi / doom.md
Created September 21, 2020 16:07 — forked from anhedonix/doom.md
Doom Emacs Cheatsheet

Doom Emacs Default keybindings cheetsheet

SPC

  • SPC find file
  • , switch bufferA
  • . browse files
  • : MX
  • ; EX
  • &lt; switch buffer
@masukomi
masukomi / fizzbuzz.py
Last active May 23, 2022 23:55 — forked from Gorcenski/fizzbuzz.py
The most obnoxious solution to FizzBuzz I can imagine.
# Emily Gorcensky's "obnoxious" fizz-buzz (less-compact version) annotated for non-python geeks.
# Explanation via Twitter: https://twitter.com/EmilyGorcenski/status/1228407309656903680?s=20
# If you want to dive into the meanings of how it works: it models fizzbuzz by
# computing the isomorphism of the finite cyclic groups of the values of the
# fizzes and buzzes and whatnot.
#
# These abelian groups are mapped to the unit circle in the complex plane and
# Represented as roots of unity. Such a interpetation has a polynomial
# representation. Therefore, the cartesian product in the isomorphism is
# represented as polynomial multiplication. The coefficients of a Polynomial
@masukomi
masukomi / parraleln.cr
Created May 3, 2018 19:25 — forked from oprypin/parraleln.cr
Crystal parallel jobs from an array
def paralleln(items : Indexable(T), &block : T -> R) forall T, R
results = Array(R).new(items.size) { r = uninitialized R }
done = Channel(Exception?).new
items.each_with_index do |item, i|
spawn do
begin
results[i] = block.call(item)
rescue e
done.send e
@masukomi
masukomi / application.js
Last active August 29, 2015 14:26 — forked from aackerman/application.js
Preventing multiple electron application instances
var net = require('net');
var fs = require('fs');
var os = require('os');
var path = require('path');
// Create server to listen for additional application launches
function listenForNewProcesses(socketPath) {
// create a server for listening on the socket path
var server = net.createServer(function(connection) {
connection.on('data', function(data) {
;;;; pretty-literals.lisp - pretty hash table & vector literal syntax
;;;; inspired by and uses code from http://frank.kank.net/essays/hash.html
(in-package #:pretty-literals)
;; vector literal syntax using brackets
(set-macro-character #\[
(lambda (str char)
(declare (ignore char))
(let ((*readtable* (copy-readtable *readtable* nil))
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
parser-tools/yacc)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {