Skip to content

Instantly share code, notes, and snippets.

@teerapap
teerapap / exercise-web-crawler.go
Created January 2, 2023 16:46
A Tour Of Go - Web Crawler Solution
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
@teerapap
teerapap / restore-quicksaver-tab-groups.js
Last active November 29, 2017 09:14
A hacky nodejs script to restore Quicksaver's tab groups from Firefox session backup. This is very hacky and may not properly parse your session json but it did for mine.
/*
* restore-quicksaver-tab-groups.js
* Copyright (C) 2017 Teerapap Changwichukarn <teerapap.c@gmail.com>
*
* Distributed under terms of the MIT license.
*/
// This script restores tab groups from Firefox session backup.
// For my case, OSX, the session backup is at ~/Library/Application\ Support/Firefox/Profiles/{random string}.default/sessionstore-backups/previous.js
@teerapap
teerapap / restore-quicksaver-tab-groups.js
Created November 29, 2017 09:13
A hacky script to restore Quicksaver's tab groups from Firefox session backup.
/*
* restore-quicksaver-tab-groups.js
* Copyright (C) 2017 Teerapap Changwichukarn <teerapap.c@gmail.com>
*
* Distributed under terms of the MIT license.
*/
// This script restores tab groups from Firefox session backup.
// For my case, OSX, the session backup is at ~/Library/Application\ Support/Firefox/Profiles/{random string}.default/sessionstore-backups/previous.js
@teerapap
teerapap / custom-view-from-xib.m
Created March 17, 2015 01:47
Make custom view from xib and show in interface builder
-(instancetype) initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self)
{
// Initialization code.
[self loadFromNib];
}
return self;
}
@teerapap
teerapap / git-move-annotated-tag.sh
Created July 14, 2014 04:23
Move annotated tag without retagging
#!/bin/sh
# ---------------------------------------------------------------------------
# git-move-annotated-tag.sh - Move annotated tag without retagging
# Author: Teerapap Changwichukarn <teerapap.c@gmail.com>
# Usage: git-move-annotated-tag.sh -h for more information
#
# Manual commands:
# > git cat-file -p ${tag_name} | sed "1 s/^object .*$/object ${full_target_hash}/g" | git hash-object -w --stdin -t tag
@teerapap
teerapap / ssh-agent-bashrc.sh
Created March 11, 2014 07:07
bashrc to initialize ssh-agent daemon(if not running) on ssh-login
####SSH-agent setting####
AGENT_INFO="$HOME/.ssh/agent.info"
function start_agent {
echo "Initializing new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${AGENT_INFO}"
chmod 600 "${AGENT_INFO}"
. "${AGENT_INFO}" > /dev/null
}
@teerapap
teerapap / gnome-solarized-dark.sh
Created July 11, 2013 16:46
Shell script to set Solarized(Dark) theme for gnome-terminal in GNOME (>=v3.8, using dconf)
#!/usr/bin/env bash
#
# Setting Solarized(Dark) theme for gnome-terminal in GNOME (>=v3.8, using dconf)
#
# Thanks to
# http://unix.stackexchange.com/questions/66579/how-do-i-get-the-solarized-colour-scheme-working-with-gnome-terminal-tmux-and-v
# https://github.com/sigurdga/gnome-terminal-colors-solarized
#