Skip to content

Instantly share code, notes, and snippets.

View gregoriokusowski's full-sized avatar

Gregório Chalinski Kusowski gregoriokusowski

View GitHub Profile
# install this as pre-requisite
brew install bluetoothconnector
brew install switchaudio-osx
# In automator, create a new "Quick Action" Shell Script with no input and in any application:
# mac and name for the airpods can be found executing: BluetoothConnector
set -e
mac=0c-3b-50-96-75-34
@idelem
idelem / titleUrlMarkdownClip.js
Last active March 12, 2024 02:01 — forked from bradleybossard/titleUrlMarkdownClip.js
Bookmarklet to copy current page title and url in Markdown format to clipboard, like [title](url) - Usual for posting links to resources in README.md files
javascript:(function() {
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
/*IE specific code path to prevent textarea being shown while dialog is visible.*/
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
@robertoestivill
robertoestivill / setup
Last active May 8, 2020 10:26
RAM disk + rsync
###############
# Step 0:
# Disclaimer
#
# RAM DISK ARE VOLATILE. YOU WILL LOOSE DATA IF POWER IS INTERRUPTED.
#
###############
# Step 1:
@yogthos
yogthos / clojure-beginner.md
Last active April 29, 2024 10:56
Clojure beginner resources

Introductory resources

@jaawerth
jaawerth / init.fnl
Last active December 4, 2023 09:37
hammerspoon (Macos automation) using fennel
; gist doesn't know what fennel is so let's say clj
; vi: ft=clojure
(set hs.logger.defaultLogLevel "info")
(local {:application app :hotkey hotkey} hs)
; use the SpoonInstall Spoon easy installing+loading of Spoons
(hs.loadSpoon :SpoonInstall)
(local install (. spoon :SpoonInstall))
; for window sizing, use the WIndowHalfsAndThirds Spoon until I can write something custom
# Regex for Kotlin
--langdef=kotlin
--langmap=kotlin:+.kt
--langmap=kotlin:+.kts
--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy|inner|open)[[:space:]]*)*(private[^ ]*|protected)?[[:space:]]*class[[:space:]]+([[:alnum:]_:]+)/\4/c,classes/
--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*(private[^ ]*|protected)?[[:space:]]*object[[:space:]]+([[:alnum:]_:]+)/\4/o,objects/
--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy|open)[[:space:]]*)*(private[^ ]*|protected)?[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*data class[[:space:]]+([[:alnum:]_:]+)/\6/d,data classes/
--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy)[[:space:]]*)*(private[^ ]*|protected)?[[:space:]]*interface[[:space:]]+([[:alnum:]_:]+)/\4/i,interfaces/
--regex-kotlin=/^[[:space:]]*type[[:space:]]+([[:alnum:]_:]+)/\1/T,types/
--regex-kotlin=/^[[:space:]]*((abstract|final|sealed|implicit|lazy|override|open|private[^ ]*(\[[a-z]*\])*|protected)[[
@jimfoltz
jimfoltz / tw5-server.rb
Last active February 26, 2024 02:18
A local server for TiddlyWiki5 that allows saving wiki.
require 'webrick'
require 'fileutils'
if ARGV.length != 0
root = ARGV.first.gsub('\\', '/')
else
root = '.'
end
BACKUP_DIR = 'bak'
@mtnygard
mtnygard / deps.edn
Last active April 9, 2024 11:51 — forked from athos/deps.edn
Friendly REPL. Run with `clojure -Sdeps '{:deps {hello-clojure {:git/url "https://gist.github.com/mtnygard/9b2dd3c88b3309d82210b84f33ee954d" :sha "774314af2d28261af4a52ac270136d5ba21ff046"}}}' -m frenpl`
{:paths ["." "src" "test"]
:deps {expound {:mvn/version "0.8.4"}
clansi {:mvn/version "1.0.0"}
cider/cider-nrepl {:mvn/version "0.24.0"}
refactor-nrepl {:mvn/version "2.5.0"}
com.bhauman/rebel-readline {:mvn/version "0.1.4"}}}

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

@robertoestivill
robertoestivill / branchy.sh
Created July 17, 2017 11:15
Iterate over local git branches and prompt the user for deletion confirmation.
#!/bin/bash
CURRENT=$(git branch | grep "*" | cut -c3-)
printf "Your current branch is '$CURRENT'. Will be ignored.\n\n"
BRANCHES=$(git branch | cut -c3-)
BRANCHES=${BRANCHES[@]/$CURRENT}
for BRANCH in ${BRANCHES}
do