Skip to content

Instantly share code, notes, and snippets.

@cooljl31
cooljl31 / classnamePrefixPlugin.ts
Created February 26, 2024 18:36 — forked from Anush008/gist:ffebc6ceb5439dc1ca2996ff7fb88311
Vite classname prefixer plugin
export function classnamePrefixPlugin() {
const prefix = 'tw-'
return {
name: 'classname-prefix',
transform: (code: string, id: string) => {
const classNamePattern = /(className|class)\s*(:|=)\s*"([^"]*)"/g
const transformedCode = code.replace(classNamePattern, (match, p1, p2, p3) => {
const transformedClassName = p3
.split(' ')
@cooljl31
cooljl31 / certbot-systemd-ubuntu.md
Created November 2, 2023 08:49 — forked from dbirks/certbot-systemd-ubuntu.md
Certbot renew with a systemd timer on Ubuntu

Ubuntu 16.04

/etc/systemd/system/certbot.service

[Unit]
Description=Let's Encrypt renewal

[Service]
Type=oneshot
ExecStart=/usr/bin/certbot renew --quiet --agree-tos
@cooljl31
cooljl31 / converter.rb
Created July 5, 2023 08:24 — forked from ttilberg/converter.rb
Utilities to unobfuscate a certain class of js files.
require 'net/http'
require 'json'
require 'uri'
require 'yaml'
##
# Make a certain obfuscated js less obnoxious to analyze.
#
class Obfuscated
attr_accessor :script
@cooljl31
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
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
end
def down
rename_column :posts, :data, :data_jsonb
@cooljl31
cooljl31 / google_script.js
Created June 22, 2022 12:14 — forked from shibulijack-fd/google_script.js
Google script to convert spreadsheet to YML
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
cooljl31 / ansible-localhost.md
Last active May 25, 2022 08:55 — forked from ryantuck/ansible-localhost.md
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
cooljl31 / l10n_IETF_Language_tags.md
Created May 6, 2022 10:52 — forked from traysr/l10n_IETF_Language_tags.md
Commonly used IETF language tags
@cooljl31
cooljl31 / nginx-config-rails4-with-puma-ssl-version.conf
Created April 8, 2022 07:16 — forked from rkjha/nginx-config-rails4-with-puma-ssl-version.conf
Nginx config for rails 4 application using puma [ssl and non-ssl version]
upstream myapp_puma {
server unix:/tmp/myapp_puma.sock fail_timeout=0;
}
# for redirecting to https version of the site
server {
listen 80;
rewrite ^(.*) https://$host$1 permanent;
}
@cooljl31
cooljl31 / mac-setup-redis.md
Created September 1, 2021 11:59 — forked from tomysmile/mac-setup-redis.md
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@cooljl31
cooljl31 / deep-merge.js
Created August 20, 2021 12:08 — forked from ahtcx/deep-merge.js
Deep-Merge JavaScript objects with ES6
// Merge a `source` object to a `target` recursively
const merge = (target, source) => {
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
for (const key of Object.keys(source)) {
if (source[key] instanceof Object) Object.assign(source[key], merge(target[key], source[key]))
}
// Join `target` and modified `source`
Object.assign(target || {}, source)
return target