Skip to content

Instantly share code, notes, and snippets.

@alotaiba
alotaiba / natvpn.sh
Created June 18, 2011 18:01
This script is to turn on/off NATting through to a VPN server on Mac.
#!/bin/bash
# This script to turn on/off NATting through to a VPN server.
# Example would be turning the mac into a wireless router, and routing all the incoming
# traffic to the VPN server.
# Thanks to http://rodrigo.sharpcube.com/2010/06/20/using-and-sharing-a-vpn-connection-on-your-mac/
case "$1" in
on)
echo "Turning NAT VPN on."
natd -interface tun0
@I82Much
I82Much / unzipkmz.sh
Created May 6, 2011 22:01
This script unzips a kmz file by renaming it to .rar and then calling unzip on it.
#!/bin/sh
# Author: Nick Dunn
#
# This script takes as input the path to a .kmz file and outputs a directory
# full of the contents of that .kmz file, named the same as the .kmz file without
# the kmz suffix. Thus
# ./openkmz.sh /path/to/mykmz.kmz
# would result in a new directory being created at /path/to/mykmz filled with the contents
# of mykmz.kmz.
@twslankard
twslankard / mountpoint.c
Created January 14, 2011 22:25
Using stat to determine programmatically whether a file is a mount point.
#include <assert.h>
#include <sys/stat.h>
#include <stdint.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[]) {
#!/bin/bash
# SPDX-License-Identifier: MIT
## Copyright (C) 2009 Przemyslaw Pawelczyk <przemoc@gmail.com>
##
## This script is licensed under the terms of the MIT license.
## https://opensource.org/licenses/MIT
#
# Lockable script boilerplate
@mxcl
mxcl / rsync+watcher.rb
Created July 18, 2009 09:32
rsync whenever the directory the script is in changes using the OS X FSEvents API
#!/usr/bin/ruby
require 'osx/foundation'
OSX.require_framework '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework'
include OSX
$d=File.basename Dir.pwd
Dir.chdir '..'
fsevents_cb = proc do |stream, ctx, numEvents, paths, marks, eventIDs|
system "rsync --delete -rt --rsh=ssh '#{$d}' 'methylblue.com:public_html/'"