Skip to content

Instantly share code, notes, and snippets.

@23maverick23
23maverick23 / schedule_job.sh
Created May 15, 2015 22:26
Bash: Schedule jobs on Mac using launchd
# Activate rvm
$ rvm use default
# Install lunchy if not already installed
$ gem install lunchy
# Make a plist file
$ touch ~/Library/LaunchAgents/org.yourusername.email-mom.plist
# Open your plist file and copy the text from below
@23maverick23
23maverick23 / apps.lua
Created October 1, 2018 14:57
OSX: Hammerspoon scripts
apps = {}
apps.launchers = {
{
name="Home - Coding",
description="Launch apps for coding.",
apps={
"Sublime Text",
"iTerm",
"Dash"
@23maverick23
23maverick23 / svg_text_select.css
Created January 3, 2015 13:41
CSS: Disable text selection in SVG elements
svg text {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
svg text::selection {
background: none;
}
@23maverick23
23maverick23 / kill_running_process.sh
Created January 18, 2014 14:50
Bash: Kill running process
# where 4000 is the port number
$ lsof -wni tcp:4000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ruby 7362 rymo 14u IPv4 0xc512a9985f0651ed 0t0 TCP *:terabase (LISTEN)
# where 7362 is the PID of the process running on port 4000
$ kill -9 7362
@23maverick23
23maverick23 / regexp_listcomp_shortcut.py
Created February 11, 2017 15:58
Python: Regexp in list comprehension (shortcut syntax)
# Taken from Stack Overflow answer http://stackoverflow.com/a/2436623/4093021
import re
# items = ['[1] rymoio [rymoio 7s] foo bar', '[2] baz [rymoio 2d] hello world']
# assign matches to callable group parameters
regex = r"(?P<who>.*\[.*\]\s)(?P<what>.*)"
# bound method outside of the listcomp optimization
@23maverick23
23maverick23 / stripSpacesXMLTags.py
Last active January 1, 2023 14:03
Python: Strip spaces between tags
#!/usr/bin/env python
print re.sub('\s+(?=<)', '', xml_string)
# This regex will turn a prettyprinted XML string into a spaceless
# string which is sometimes easier to deal with.
# Example response from xml.etree.ElementTree.fromstring(xml)
# <response>
# <Auth status="0"/>
@23maverick23
23maverick23 / obsidian_dataview_queryable.md
Created October 18, 2022 17:13
Dataview: Show queryable fields for current page

$=dv.span(dv.current())

@23maverick23
23maverick23 / heroku_commands.sh
Last active July 12, 2022 15:39
Bash: Heroku bash commands
# Heroku Django Commands #
# ---------------------- #
# Push local git changes to heroku
git push heroku master
# Login to heroku via toolbelt
heroku login
# View heroku processes
@23maverick23
23maverick23 / parseMarkdownLinks.js
Created March 17, 2022 15:00
Handy little regular expression to parse links from markdown files.
@23maverick23
23maverick23 / date_to_text.sql
Last active February 2, 2022 20:39
NS: Convert Date Month to Sortable With Text (SuiteAnalytics Workbook)
-- Format a date field in SuiteAnalytics Workbook so that it sorts by month but displays month name
TO_CHAR({date_field}, 'MM') || '-' || TO_CHAR({date_field}, 'MON')