Skip to content

Instantly share code, notes, and snippets.

Andrei Neculau andreineculau

Block or report user

Report or block andreineculau

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andreineculau
andreineculau / 1.original.ts
Last active Oct 7, 2019
original, simpler, proper --- typing isn't everything
View 1.original.ts
// 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 Sep 20, 2019
fast emacs startup -- add the following to the beginning of your init.el
View 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
if defense of being old and grumpy
View 0.md
@andreineculau
andreineculau / imessage
Created Jan 2, 2019 — forked from aktau/imessage
Send iMessage from the commandline
View imessage
#!/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 Jul 21, 2018
Fix homebrew lsof.rb
View 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 Dec 22, 2017
fucking get aws-sdk-js to read your aws-cli assumed role
View get-aws-cli-sts.js
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 Sep 18, 2017
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
View pnpmfile.js
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 Sep 18, 2017
List package.json dependencies' licenses recursively - stdout has the license text, stderr has the list
View list-npm-licenses.sh
#!/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
View elementsFromPoint.js
let elementsFromPoint = function(x, y) {
let items = [];
let element;
do {
element = document.elementFromPoint(x, y);
if (!element || element === (items[0] || {}).element) {
break;
}
items.unshift({
You can’t perform that action at this time.