Skip to content

Instantly share code, notes, and snippets.

cooljl31 /
Created November 2, 2023 08:49 — forked from dbirks/
Certbot renew with a systemd timer on Ubuntu

Ubuntu 16.04


Description=Let's Encrypt renewal

ExecStart=/usr/bin/certbot renew --quiet --agree-tos
cooljl31 / converter.rb
Created July 5, 2023 08:24 — forked from ttilberg/converter.rb
Utilities to unobfuscate a certain class of js files.
View converter.rb
require 'net/http'
require 'json'
require 'uri'
require 'yaml'
# Make a certain obfuscated js less obnoxious to analyze.
class Obfuscated
attr_accessor :script
View SimpleForm custom ArrayInput
#Simple form Input class for arrays
class ArrayInput < SimpleForm::Inputs::Base
def input(_wrapper_options)
#override the attribute name for arrays to allow rails to handle array forms
input_html_options.merge!({:name => "#{self.object_name}[#{attribute_name}][]"})
@builder.text_field(attribute_name, input_html_options)
cooljl31 / debugging.rb
Created December 20, 2022 12:41
Create screenshot using Capybara and Selenium from debugging
View debugging.rb
page.driver.browser.manage.window.resize_to(1600, 1800)
page.save_and_open_screenshot('screen.png', full: true)
cooljl31 / benchmark.rb
Created December 20, 2022 09:56
Benchmark example
View benchmark.rb
Benchmark.ips do |x|
x.config(time: 30, warmup: 2)'gsub') { string.gsub(/ /, '') }'gsub, no regex') { string.gsub(' ', '') }'tr') {' ','') }'delete') { string.delete(' ') }!
View fast-glob
import glob from 'fast-glob'
import nodeURL from 'url'
import process from 'process'
/** Returns pathnames matching the given pattern. */
const sync = (source: string) => glob.sync(source, options()) as string[]
/** Returns pathnames matching the given pattern. */
const async = (source: string) => glob(source, options()) as Promise<string[]>
cooljl31 / migrate_hstore_to_json.rb
Created October 11, 2022 12:29 — forked from estum/migrate_hstore_to_json.rb
Ruby on Rails & Postgres: Reversible migrate hstore column to jsonb with contents
View migrate_hstore_to_json.rb
class MigrateHstoreToJson < ActiveRecord::Migration
def up
rename_column :posts, :data, :data_hstore
add_column :posts, :data, :jsonb, default: {}, null: false, index: { using: 'gin' }
execute 'UPDATE "posts" SET "data" = json_object(hstore_to_matrix("data_hstore"))::jsonb'
remove_column :posts, :data_hstore
def down
rename_column :posts, :data, :data_jsonb
cooljl31 / google_script.js
Created June 22, 2022 12:14 — forked from shibulijack-fd/google_script.js
Google script to convert spreadsheet to YML
View google_script.js
function getYAML() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var dest = DocumentApp.openById(PropertiesService.getScriptProperties().getProperty("output_document_id"));
var key = Browser.inputBox("Please enter the key of the Google Spreadsheet containing the content to be generated as a YAML file.");
var source = SpreadsheetApp.openById(key);
var output = "---\nen:\n";
var sheets = source.getSheets();
for (var i = 0; i < sheets.length; i++) {
cooljl31 /
Last active May 25, 2022 08:55 — forked from ryantuck/
super fast way to start testing ansible stuff locally without VMs

set up ansible to work on localhost

i've found this useful for debugging ansible modules and syntax without having to use VMs or test in dev environments.

install ansible

pip install ansible

make some relevant config files

cooljl31 /
Created May 6, 2022 10:52 — forked from traysr/
Commonly used IETF language tags