Skip to content

Instantly share code, notes, and snippets.

View andreineculau's full-sized avatar
:bowtie:

Andrei Neculau andreineculau

:bowtie:
View GitHub Profile
@andreineculau
andreineculau / 1.original.ts
Last active October 7, 2019 20:39
original, simpler, proper --- typing isn't everything
// https://github.com/m59peacemaker/browser-insular-observer
//
// Usage:
// let observe = InsularObserver(MutationObserver);
// observe(document.documentElement, options, function(documentElementEntry) {...});
//
import keyMaster = require('key-master')
@andreineculau
andreineculau / init.el
Last active September 20, 2019 15:46
fast emacs startup -- add the following to the beginning of your init.el
;; fast startup time
(setq gc-cons-threshold most-positive-fixnum)
(defvar original-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(add-hook 'emacs-startup-hook
#'(lambda () (setq gc-cons-threshold 800000
file-name-handler-alist original-file-name-handler-alist)))
;; (add-hook 'emacs-startup-hook
(add-hook 'after-init-hook
(lambda ()
@andreineculau
andreineculau / 0.md
Last active May 3, 2019 18:47
if defense of being old and grumpy
@andreineculau
andreineculau / imessage
Created January 2, 2019 12:49 — forked from aktau/imessage
Send iMessage from the commandline
#!/bin/sh
if [ "$#" -eq 1 ]; then stdinmsg=$(cat); fi
exec <"$0" || exit; read v; read v; read v; exec /usr/bin/osascript - "$@" "$stdinmsg"; exit
-- another way of waiting until an app is running
on waitUntilRunning(appname, delaytime)
repeat until my appIsRunning(appname)
tell application "Messages" to close window 1
delay delaytime
end repeat
@andreineculau
andreineculau / lsof.rb
Last active July 21, 2018 18:53
Fix homebrew lsof.rb
class LsofDownloadStrategy < CurlDownloadStrategy
def stage
super
safe_system "/usr/bin/tar", "xf", "#{name}_#{version}_src.tar"
cd "#{name}_#{version}_src"
end
end
class Lsof < Formula
desc "Utility to list open files"
@andreineculau
andreineculau / get-aws-cli-sts.js
Created December 22, 2017 10:55
fucking get aws-sdk-js to read your aws-cli assumed role
import aws from 'aws-sdk';
import fs from 'fs';
import ini from 'ini';
import path from 'path';
// compatibility with aws-cli
let cliCacheFolder = path.join(process.env.HOME, '.aws', 'cli', 'cache');
let awsProfile = process.env.AWS_PROFILE || process.env.AWS_DEFAULT_PROFILE;
if (awsProfile) {
try {
@andreineculau
andreineculau / pnpmfile.js
Created September 18, 2017 14:15
pnpmfile.js to lock js-beautify to 1.6.4 across all dependencies as a workaround to https://github.com/beautify-web/js-beautify/issues/1247
let semver = require('/usr/local/lib/node_modules/npm/node_modules/semver');
let lockJsBeautifier = function(name, version, {deps, _depsName, pkg}) {
if (name !== 'js-beautify') {
return;
}
if (!semver.satisfies('1.7.0', version)) {
return;
}
@andreineculau
andreineculau / list-npm-licenses.sh
Last active September 18, 2017 09:56
List package.json dependencies' licenses recursively - stdout has the license text, stderr has the list
#!/usr/bin/env bash
# Usage path/to/list-npm-licenses.sh node_modules
function jqq() {
jq -r "$@" 2>/dev/null
}
function grepq() {
grep -q -w "$@" 2>/dev/null
let elementsFromPoint = function(x, y) {
let items = [];
let element;
do {
element = document.elementFromPoint(x, y);
if (!element || element === (items[0] || {}).element) {
break;
}
items.unshift({