Skip to content

Instantly share code, notes, and snippets.

@shedali
shedali / typeisarray
Last active March 5, 2019 23:51
evaluate-whether-value-is-array
var typeIsArray;
typeIsArray = Array.isArray || function(value) {
return {}.toString.call(value) === '[object Array]';
};
typeIsArray([1,2,3]);
@shedali
shedali / mac-quick-screenshare
Created February 10, 2014 00:29
applescript to start screen recording using quicktime
tell application "QuickTime Player" to activate
tell application "System Events"
activate
--set UI elements enabled to true
tell process "QuickTime Player"
click menu item "New Screen Recording" of menu "File" of menu bar 1
end tell
end tell
tell application "QuickTime Player"
@shedali
shedali / longest non-contiguous subsequence
Created February 20, 2014 09:58
find longest common non-contiguous subsequence
var fs = require("fs");
var a, b, split,
longest = '',
sequence = '',
output = '',
matched = 0,
matchpos = 0;
fs.readFileSync(process.argv[2]).toString().split('\n').forEach(function(line) {
@shedali
shedali / find-broken-links.sh
Last active August 29, 2015 13:58
crawl site for broken links
@shedali
shedali / remotewatch.sh
Created November 30, 2014 00:31
remote watch script using inotify to kick off jekyll build in response to dropbox file changes
#/bin/bash
regex=[0-9][0-9][0-9][0-9]-.*.\(md\|txt\);
inotifywait -m -e CREATE,DELETE,MOVE ~/Dropbox/note/ |
while read dir ev file;
do
if [[ $file =~ $regex ]] ; then echo "$file updated"; fi
done
@shedali
shedali / sort_whatsapp.sh
Last active May 1, 2016 19:59
sort whatsapp to dated subfolders
#!/bin/bash
echo running;
find . -maxdepth 3 -regex ".*\-2016[0-9][0-9][0-9][0-9].*.*" | while read filename;
do
f=$(basename "$filename")
echo $f
date=$(echo "$f" | cut -c5-12)
echo $date
if echo "${date}" | grep '[0-9]' >/dev/null; then
dirpath='/Users/shedali/Dropbox/Events/2016/'${date:0:4}-${date:4:2}-${date:6:2}
@shedali
shedali / dev_layout.lua
Last active July 18, 2016 15:40
hammerspoon dev mode
function expand_devtools()
hs.application.launchOrFocus("Google Chrome")
hs.application.launchOrFocus("Terminal")
hs.application.launchOrFocus("Sublime Text")
local laptopScreen = "iMac"
local windowLayout = {
{"Google Chrome", nil, iMac, {x=0, y=0, w=0.5, h=1},nil, nil},
{"Sublime Text", nil, iMac, {x=0.5, y=0, w=0.5, h=0.6},nil, nil},
{"Terminal", nil, iMac, {x=0.5, y=0.6, w=0.5, h=0.4},nil, nil},
-- {"App Name", "Window Name", "Screen Name", hs.layout.left50,nil, nil}
@shedali
shedali / hammerspoon.lua
Created July 23, 2016 00:18
my hammerspoon config
-- http://www.hammerspoon.org/go/
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function()
hs.reload()
hs.alert.show("Config loaded")
end
)
function expand_devtools()
hs.application.launchOrFocus("Slack")
@shedali
shedali / flagged.js
Created April 12, 2018 23:09
Get Flagged Omnifocus Tasks Applescript
# javascript for mac - get OF flagged tasks
var of = Application('OmniFocus');
var doc = of.defaultDocument;
getTasks();
function getTasks(){
var today = new Date();
var dueDate = new Date(today.setDate(today.getDate()+7));
@shedali
shedali / index.js
Last active October 10, 2019 12:53
test grab due tasks with jxa in node
const runJxa = require("run-jxa");
const _ = require('lodash');
(async () => {
const result = await runJxa(() => {
var of = Application("OmniFocus");
var doc = of.defaultDocument;
return getTasks();