Skip to content

Instantly share code, notes, and snippets.

View willbchang's full-sized avatar
📝
Learning & Creating

Will B Chang willbchang

📝
Learning & Creating
  • Shanghai, China
  • 08:27 (UTC +08:00)
View GitHub Profile
@dustingetz
dustingetz / serve.py
Last active August 14, 2019 18:14 — forked from rca/serve.py
serve static assets for frontend development, with http headers to disable caching
#!/usr/bin/env python
import SimpleHTTPServer
class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_my_headers()
SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)
def send_my_headers(self):
self.send_header("Cache-Control", "no-cache, no-store, must-revalidate")
@seripap
seripap / README.md
Last active January 27, 2020 09:20
Chrome Headless PDF with Page Numbers

Getting page numbers using Chrome Headless

This is a small hack that adds a page numbers at the bottom of the page. Using Puppeteer and a fixed height, the page will render at an A4 size via web and have a fixed footer.

await page.goto('https://bl.ocks.org/seripap/raw/81241195e182b62adc3c87c27258f85f/', {waitUntil: 'networkidle'});
await page.pdf({
  path: 'hacks.pdf',
  format: 'A4'
});
@haircut
haircut / System - Software Updates.mobileconfig
Created October 10, 2017 01:02
Manage macOS Software Update settings via configuration profile (Jamf Pro)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<dict>
<key>com.apple.SoftwareUpdate</key>
@yaakov-h
yaakov-h / ReadingListReader.swift
Last active January 10, 2021 08:17
Read your Safari Reading List and dump to plain text
import Foundation
func fatalerror(_ text : String) {
fputs(text, __stderrp)
exit(-1)
}
struct ReadingListItem {
init(title: String?, previewText: String?, url: URL, dateAdded: Date) {
self.title = title
@gfontenot
gfontenot / alfred-vim.applescript
Created September 6, 2012 19:21
Alfred plugin for editing the selected item in Vim (using iTerm 2)
on alfred_script(q)
set {the_path, file_name} to parse_path(first item of q)
tell application "iTerm"
set _terminal to make new terminal
tell _terminal
launch session "Vim"
tell the last session
write text "cd \"" & the_path & "\""
# Replace e with your vim command
@lewisrodgers
lewisrodgers / chrome-web-store-api-deploy-utility.sh
Last active August 14, 2021 00:20
Bash script designed to update and publish a chrome extension that already exists in the Chrome Web Store.
#!/bin/bash
# This script is designed to update and publish a chrome extension
# that already exists in the Chrome Web Store. It also depends on
# OAuth 2.0 credentials and a refresh token.
# Required arguments
# ==================
# There are 2 actions you can perform:
# 1. Update - upload a chrome extension to the Chrome Web Store
@rwest
rwest / README
Created January 9, 2012 16:42 — forked from symposion/README
Convert OS X Keychain exported entries into logins for 1Password import
These two files should help you to import passwords from mac OS X keychains to 1password.
Assumptions:
1) You have some experience with scripting/are a power-user. These scripts worked for me
but they haven't been extensively tested and if they don't work, you're on your own!
Please read this whole document before starting this process. If any of it seems
incomprehensible/frightening/over your head please do not use these scripts. You will
probably do something Very Bad and I wouldn't want that.
2) You have ruby 1.9.2 installed on your machine. This comes as standard with Lion, previous
versions of OS X may have earlier versions of ruby, which *may* work, but then again, they
(require 'svg)
(defun replace-text (start end)
(interactive "r")
(let* ((str (buffer-substring start end))
(scale (cadr (assoc :height (assoc 'default face-remapping-alist))))
(width (float (car (window-text-pixel-size nil start end))))
(height (float (cdr (window-text-pixel-size nil start end))))
(family (face-attribute 'default :family))
(ascent (* (aref (font-info family) 8) (if scale scale 1)))
(img (format "<?xml version='1.0' encoding='UTF-8'?>
@penn201500
penn201500 / switch.el
Last active December 13, 2021 13:04 — forked from celadevra/switch.el
Sane switching of input methods when using evil-mode in Emacs on OSX;change some conf for qwerty keyboard, and default-im keyboard changed to be self-conf.
;; switch to english input method when switching to normal mode
;; and switch back when entering insert/replace modes
;; need external script support, currently mac-only
(defvar default-im "org.unknown.keylayout.layoutformc" "Default ascii-only input method")
(defvar prev-im (substring (shell-command-to-string "/usr/local/bin/im-select") 0 -1)
"IM that I use when starting Emacs and exiting insert mode")
(defun im-use-english ()
"Switch to english input method on a Mac. im-select is a tool
provided at https://github.com/daipeihust/im-select"