Skip to content

Instantly share code, notes, and snippets.

View sirn's full-sized avatar

Sirn Thanabulpong sirn

  • Tokyo, Japan
  • 07:36 (UTC +09:00)
View GitHub Profile
@sirn
sirn / README.md
Created August 8, 2017 05:02
Firefox Compact Theme Fix
  1. Navigate to Firefox profile directory (e.g. ~/Library/Application Support/Firefox/Profiles/ced012a1.default)
  2. Copy the content of css file in this gist to chrome/userChrome.css (create if not exists).
  3. Restart Firefox.
function FindProxyForURL(url, host) {
if (url.substring(0, 5) !== "http:") { return "DIRECT"; }
if (isPlainHostName(host)) { return "DIRECT"; }
if (shExpMatch(host, "*.local")) { return "DIRECT"; }
var resolvedHost = dnsResolve(host);
if (isInNet(resolvedHost, "10.0.0.0", "255.0.0.0")) { return "DIRECT"; }
if (isInNet(resolvedHost, "172.16.0.0", "255.240.0.0")) { return "DIRECT"; }
if (isInNet(resolvedHost, "192.168.0.0", "255.255.0.0")) { return "DIRECT"; }
@sirn
sirn / README.md
Last active November 17, 2018 10:48
Fix iTunes Library.xml

Fix iTunes Library

This is a one-off script to fix broken Location entry in iTunes Library.xml.

iTunes internal database will sometimes have a broken file location when exporting. For example, for a purchased song, it might still have a reference to a temporary file at iTunes Media/Downloads rather than file inside iTunes Media/Music directory. While iTunes itself doesn't seems to use these locations for its playback, it becomes problematic when other music players try to import the iTunes library data (e.g. Swinsian).

This script will parse iTunes Library.xml to detect broken file location and try to find the file. This script was created for personal use, so it may or may not work in your environment. Use it at your own risk and remember to backup the library before trying!

You should not need to use this if you're not syncing the iTunes library with other media players on a Mac.

@sirn
sirn / debug.001_vagrant_up.log
Created November 13, 2016 15:31
vagrant debug logs
INFO global: Vagrant version: 1.8.7
INFO global: Ruby version: 2.2.5
INFO global: RubyGems version: 2.4.5.1
INFO global: VAGRANT_OLD_ENV_EDITOR="vi"
INFO global: VAGRANT_OLD_ENV_ITERM_PROFILE="Default"
INFO global: VAGRANT_OLD_ENV_ITERM_SESSION_ID="w2t0p1:4FB66052-0FB7-4F60-AF6F-8E462D4D18D1"
INFO global: VAGRANT_OLD_ENV_JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home"
INFO global: VAGRANT_OLD_ENV_LOGNAME="sirn"
INFO global: VAGRANT_OLD_ENV_DISPLAY="/private/tmp/com.apple.launchd.zN5v4Dv3eJ/org.macosforge.xquartz:0"
INFO global: VAGRANT_OLD_ENV_TMPDIR="/var/folders/6g/7z1n53nn73s_ypxy9ypyy6yw0000gn/T/"
INFO global: Vagrant version: 1.8.6
INFO global: Ruby version: 2.2.5
INFO global: RubyGems version: 2.4.5.1
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/embedded/gems/gems/vagrant-1.8.6/bin/vagrant"
INFO global: VAGRANT_OLD_ENV_Apple_PubSub_Socket_Render="/private/tmp/com.apple.launchd.C6IDtvCgPq/Render"
INFO global: VAGRANT_OLD_ENV_PWD="/Users/sirn/Desktop/foobar"
INFO global: VAGRANT_OLD_ENV_SECURITYSESSIONID="186a7"
INFO global: VAGRANT_OLD_ENV_SHLVL="2"
INFO global: VAGRANT_OLD_ENV_USER="sirn"

Keybase proof

I hereby claim:

  • I am sirn on github.
  • I am sirn (https://keybase.io/sirn) on keybase.
  • I have a public key whose fingerprint is 8EB0 4785 8549 B60F 2099 C9F5 4AFE 17C8 11D1 8D20

To claim this, I am signing this object:

@sirn
sirn / DarwinSecurityCerts.c
Last active May 31, 2016 23:00
Sample code for debugging Security.framework in Nix
#include <stdio.h>
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
int main() {
CFDataRef data = NULL;
CFArrayRef certs = NULL;
OSStatus err = SecTrustCopyAnchorCertificates(&certs);
if (err != noErr) {
@sirn
sirn / README.md
Last active May 4, 2017 08:47
ansible-nixpkg

Usage

- name: nix-channel --update
  nix: update_channels=yes 

- name: nix-env -i package
  nix: name=package state=present

- name: nix-env -i package &amp;&amp; nix-env -u package
@sirn
sirn / environment
Created June 9, 2014 16:14
Xvfb Scripts
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
DISPLAY=:99
Python 3.2.3 (default, Sep 25 2013, 18:22:43)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pkg_resources import get_provider
>>> get_provider('pyramid_debugtoolbar')
<pkg_resources.DefaultProvider object at 0x7fe9141ad710>
>>>