Skip to content

Instantly share code, notes, and snippets.

View mnewt's full-sized avatar

Matthew Newton mnewt

View GitHub Profile
@steveklabnik
steveklabnik / log.txt
Created August 19, 2012 09:59
A fun shell script from #euruku
$ history | awk {'print $2, $3, $4'} | sort | uniq -c | sort -k1 -rn | head -n 30
610 git status
568 git commit -m
491 git add .
252 git push origin
176 bundle
138 rails s
128 ls
120 git commit --amend
114 git reset --hard
@areina
areina / emacs-email-setup.md
Created October 12, 2012 15:00
Manage your email in emacs with mu4e

Manage your gmail account in emacs with mu4e

There're a lot of combinations to manage your email with emacs, but this works for me. I've a backup and I can manage my daily email.

The stack:

  • emacs
  • offlineimap
  • mu
  • mu4e
(defun source (filename)
"Update environment variables from a shell source file."
(interactive "fSource file: ")
(message "Sourcing environment from `%s'..." filename)
(with-temp-buffer
(shell-command (format "diff -u <(true; export) <(source %s; export)" filename) '(4))
(let ((envvar-re "declare -x \\([^=]+\\)=\\(.*\\)$"))
@john2x
john2x / 00_destructuring.md
Last active April 23, 2024 13:18
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@crucialfelix
crucialfelix / styles.less
Created October 27, 2014 09:33
Highlight active pane, active tab in Atom.io
// active pane
.pane {
.gutter,
ul.tab-bar {
opacity: 0.4;
}
}
.pane.active {
.gutter {
opacity: 1;
@mattfahrner
mattfahrner / python-paged-ldap-snippet-2.4.py
Last active January 16, 2024 12:39
This snippet allows you to do a Python LDAP search with paged controls. The latest version now supports Python "ldap" 2.4. Many thanks to Ilya Rumyantsev for doing the 2.4 legwork.
#! /usr/bin/python
import sys
import ldap
from ldap.controls import SimplePagedResultsControl
from distutils.version import LooseVersion
# Check if we're using the Python "ldap" 2.4 or greater API
LDAP24API = LooseVersion(ldap.__version__) >= LooseVersion('2.4')
@TwoLeaves
TwoLeaves / init.lua
Last active March 7, 2022 18:00
Hammerspoon config
--------------------------------------------------------------------------------
-- Unsupported Spaces extension. Uses private APIs but works okay.
-- (http://github.com/asmagill/hammerspoon_asm.undocumented)
spaces = require("hs._asm.undocumented.spaces")
-- Get output of a bash command
function os.capture(cmd)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
@boris-arzur
boris-arzur / IDLE with asyncio + imaplib + mbsyncrc
Last active July 5, 2023 14:44
I use a mail stack based on mbsync & notmuch. I want to run mbsync on new mails. IDLE allows watching efficiently one folder in my mailbox. Async makes is easy to watch a few connections.
#!python3
import imaplib
import os
import asyncio
loop = asyncio.get_event_loop()
conf = [x.strip().split() for x in open('mbsyncrc')]
@steinwaywhw
steinwaywhw / One Liner to Download the Latest Release from Github Repo.md
Last active May 5, 2024 20:02
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@ammunoz
ammunoz / win10ns.ps1.md
Last active January 30, 2020 18:35
Windows 10 Mouse - Natural Scrolling

Windows 10 Mouse - Natural Scrolling

How to use

  1. Open Start menu.
  2. Search for "Windows PowerShell".
  3. Right-click and select "Run as Administrator".
  4. Paste the following:
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }