Skip to content

Instantly share code, notes, and snippets.

View Shawyeok's full-sized avatar

萧易客 Shawyeok

  • Beijing, China
  • 06:56 (UTC +08:00)
View GitHub Profile
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@Shawyeok
Shawyeok / expose.sh
Created March 22, 2017 16:54
Expose docker container port to specific IP addresses only
# For example, I have a redis container, I want it only serve for specific IP addresses: 172.31.101.37, 172.31.101.38
$ docker run -d -p 6379:6379 redis:2.8
# After start redis container, the iptables looks like this:
$ iptables -t filter -nL
Chain DOCKER (1 references)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 172.17.0.2 tcp dpt:6379
# Get the IP address of redis container
@CMCDragonkai
CMCDragonkai / history_data_structures.md
Last active March 31, 2024 00:39
History Data Structures

History Data Structures

For stateful applications, there are 5 different ways of managing the history of state:

  • No History - Living in the moment. - Examples: Any stateful application that doesn't discards all previous states upon mutation.
  • Ad Hoc Snapshotting - Allows restoration to manually saved snapshots. - Examples: Memento Pattern.
  • Singleton - Only remembers the previous snapshot, where undoing the undo is just another undo. - Examples: Xerox PARC Bravo.
  • 1 Stack - Allows linear undo. - Examples: AtariWriter.
  • 2 Stack - Allows linear undo and redo. - Examples: Browser History, Microsoft Word, Adobe Photoshop.
@VincentSit
VincentSit / update_gfwlist.sh
Last active March 24, 2024 14:39
Automatically update the PAC for ShadowsocksX. Only tested on OS X. (Deprecated)
#!/bin/bash
# update_gfwlist.sh
# Author : VincentSit
# Copyright (c) http://xuexuefeng.com
#
# Example usage
#
# ./whatever-you-name-this.sh
#
# Task Scheduling (Optional)
@n8henrie
n8henrie / txt_to_reminders.applescript
Last active March 11, 2024 17:04
Demonstration of using AppleScript with Reminders.app
--taken from http://benguild.com/2012/04/11/how-to-import-tasks-to-do-items-into-ios-reminders/#comment-1346894559
--set theFileContents to (read file "Users:n8henrie:Desktop:Reminders.txt") -- Change this to the path to your downloaded text file with your tasks in it! (Note the : instead of a / between folders) Or, just name them Reminders.txt and put them in your downloads folder
--set theLines to paragraphs of theFileContents
set theLines to {"task name 1", "task name 2"}
repeat with eachLine in theLines
tell application "Reminders"
set mylist to list "Your List Name"
tell mylist
make new reminder at end with properties {name:eachLine, due date:date "7/10/2014 3:00 PM"}