Skip to content

Instantly share code, notes, and snippets.

@dinh
dinh / encoded_fonts.edn
Created December 26, 2023 12:36 — forked from kouphax/encoded_fonts.edn
font awesome fonts -> base64 encoded data uri -> edn/sql
{"fa-adjust" "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEUAAABQCAYAAABPlrgBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAACARJREFUeJztnHtsFNcZxc+5u9jmoTogWnv9XptCY6hoVbW0TRUqpJBETaOoCCSUKm1pI0X8EUUkFSnYjBYb8kBIRWmFAlKiRKQgQlpRSkTVKqRUbXFU2obwKGB2edi7mFKTFgzG3p3TP8CEhx93dnd215V/f3lmvu+7Z4/Xd+beO9fAGGOMMcYYvsJcNRRzaktKXM4WArMFTQdQS6IMQimo8QIMxX5Blwl2A+oEGIXBESL1t/LI6dMElAutvpkigOec+ply8RiI+ZDmgCzKoF6CwnsidhfT7J4aaf9vNvXeStZNOf18zeRxRYHvS1hCcla26wMAhF5AO2m4qTwS3Zvtb1DWTDm/oiaUDASWA3wSxIRs1R0R4SDlrikPnNrBCNxslMzYlMSzZRPdCRN/QmIZgPFZ0JQewj8ILgu1nNybaamMTEk44Ufk8ucgajIVkjWkrTR8JhSJnk+3RFqmdDmNk1Lq3QBgSboN+4mgf0n4YVVLbFc6+Z5N6Wiqm2GM2QlgRjoN5hJJ6ypMzQpG/pD0kufJlE6nbj5cvk3yU97k5Q9Je4p6ixZ9et2xS7Y51qYkVoUXusBbBMelJy+f6IDbV/xg1Yv//LdNtJUpiaa6RS7NVhImI2mAKHwoqM0QH4mMATgvpC7TDWwG8Y1M6o/Q+EG3v2iejTEjmhJvrn9Y0K9JBtPWI70v8k0yuKsycvzCoO2sqt8D4MF027DSAbSBV+dVRhJXhosb9oMmmhpmunC3p2OIBBfUFjLwUuXq9iNe8/2AwBxp/JtysGi4B70hP2z38vrSq8bdSXCS18YlvR8Qny5viX3kNddvCCyIu+HngdjaoWIG7SMEsLdIGwk2eGzzKoCnKlpi88pbowVnyCewpbO5/r6hrg5q
@dinh
dinh / dashboard-ui.markdown
Last active December 17, 2023 13:42 — forked from A973C/dashboard-ui.markdown
Dashboard UI
@dinh
dinh / bash_script_usage_v2.template.sh
Created December 11, 2023 22:02 — forked from mattdanielbrown/bash_script_usage_v2.template.sh
Bash Script USAGE (function, message, text content) TEMPLATE ( and/or example ... ) [ >> VERSION 2.1 ]
#===============================================================================
# NAME : bash_script_usage_v2.template.sh
# VERSION : 2.1.0
# CREATED : Dec 12 23:41:26 CST 2022
# AUTHOR : Matt Daniel Brown <dev@mattbrown.email>
# WEB : gist.github.com/mattdanielbrown/f00f119358b57a20ca9db67718dfbaf3
#-------------------------------------------------------------------------------
# USAGE : Copy the `usage()` function below and paste into your bash script
# ... and then, replace the details as is appropriate for your script.
#===============================================================================
@dinh
dinh / script.user.js
Created November 30, 2023 19:58 — forked from jr-codes/script.user.js
Userscript Boilerplate
// ==UserScript==
// @name Userscript Name
// @namespace http://example.com/
// @description Userscript Description
// @match http://example.com/* (or @include * to include all pages)
// @version 1.0
// ==/UserScript==
// Emulate Greasemonkey's unsafeWindow in Chrome
window.unsafeWindow = window.unsafeWindow || (function() {
@dinh
dinh / custom-web-search-llm.js
Created May 22, 2023 20:22 — forked from npilk/custom-web-search-llm.js
Cloudflare Worker script to automatically route queries to search engines or an LLM based on their content.
// Cloudflare Worker script to automatically redirect search queries based on trigger words
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
// status code for redirect response; need something that won't cache
var statuscode = 303
// defining base URLs for search engines
@dinh
dinh / useful-one-liners.sh
Created May 20, 2023 18:38 — forked from modem7/useful-one-liners.sh
Useful one liners
# Run the last command as root
sudo !!
# Serve current directory tree at http://$HOSTNAME:8000/
python -m SimpleHTTPServer
# Save a file you edited in vim without the needed permissions
:w !sudo tee %
# change to the previous working directory
cd -
# Runs previous command but replacing
^foo^bar
@dinh
dinh / 00-OozieWorkflowJavaMapReduceAction
Created February 23, 2023 20:19 — forked from airawat/00-OozieWorkflowJavaMapReduceAction
Oozie workflow application with a Java Mapreduce action that parses syslog generated log files and generates a report Gist includes sample data, all workflow components, java mapreduce program code, commands - hdfs and Oozie
This gist includes components of a oozie workflow - scripts/code, sample data
and commands; Oozie actions covered: java mapreduce action; Oozie controls
covered: start, kill, end; The java program uses regex to parse the logs, and
also extracts the path of the mapper input directory path and includes in the
key emitted.
Note: The reducer can be specified as a combiner as well.
Usecase
-------
@dinh
dinh / name-shortening functions.js
Created February 18, 2023 12:40 — forked from nilsandrey/name-shortening functions.js
Name-shortening functions from Hacker News own JS for web site
// From yesenadam at https://news.ycombinator.com/item?id=23590848
function $(id) { return document.getElementById(id); }
function byClass (el, cl) { return el ? el.getElementsByClassName(cl) : [] }
function byTag (el, tg) { return el ? el.getElementsByTagName(tg) : [] }
function allof (cl) { return byClass(document, cl) }
function hasClass (el, cl) { var a = el.className.split(' '); return afind(cl, a) }
function addClass (el, cl) { if (el) { var a = el.className.split(' '); if (!afind(cl, a)) { a.unshift(cl); el.className = a.join(' ')}} }
function remClass (el, cl) { if (el) { var a = el.className.split(' '); arem(a, cl); el.className = a.join(' ') } }
function html (el) { return el ? el.innerHTML : null; }
@dinh
dinh / bookmarkleting.md
Created January 31, 2023 10:28 — forked from caseywatts/bookmarkleting.md
Making Bookmarklets

This is one chapter of my "Chrome Extension Workshops" tutorial, see the rest here: https://gist.github.com/caseywatts/8eec8ff974dee9f3b247

Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book

Making Bookmarklets

I'm feeling very clever. I've got this sweet line of javascript that replaces "cloud" with "butt". My mom would LOVE this, but she doesn't computer very well. I'm afraid to show her the Developer Console and have her type/paste this in. But she IS pretty good at bookmarks, she knows just how to click those!

A bookmark normally takes you to a new web page. A bookmarklet is a bookmark that runs javascript on the current page instead of taking you to a new page. To declare that it is a bookmarklet, the "location" it points to starts with javascript:.