Skip to content

Instantly share code, notes, and snippets.

View tekkub's full-sized avatar

Tekkub tekkub

View GitHub Profile
@daniloc
daniloc / DecimalTextField.swift
Last active April 10, 2023 17:01
SwiftUI TextField for decimal input
struct DecimalTextField: View {
@Binding var decimalValue: Decimal
@State var clearValue: Decimal = 1
var clearValueString: String {
return String("\(clearValue)")
}
@State private var lastValidInput: String?
@cobyism
cobyism / osx-install-media.md
Last active March 11, 2023 00:42
Command to create installable OS X USB drive.

Creating a bootable macOS USB installer

  • First, plug in an 8GB (or bigger) USB drive, and use Disk Utility to erase it
  • If you use the default settings, you should wind up with a blank drive at /Volumes/Untitled.

With that volume in place, and with the macOS installer sitting in /Applications/Install\ macOS\ [VERSION].app, run the following command in your terminal to create a bootable install media (for Sierra):

sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction
@robinsloan
robinsloan / langoliers.rb
Last active April 7, 2024 13:22
The Langoliers, a tweet deletion script
require "rubygems"
require "twitter"
require "json"
# things you must configure
TWITTER_USER = "your_username"
MAX_AGE_IN_DAYS = 1 # anything older than this is deleted
# get these from dev.twitter.com
CONSUMER_KEY = "your_consumer_key"
@tekkub
tekkub / array_to_hash.rb
Created December 9, 2011 23:50
Convert a ruby array into a hash
# Convert an array into a hash
#
# Example:
# -> [["bear", "rawr"], ["tanuki", "nuts"]].to_hash
# => {"tanuki"=>"nuts", "bear"=>"rawr"}
class Array
def to_hash
Hash[*self.flatten]
end
@lenary
lenary / gitconfig.ini
Created February 18, 2011 01:21
a special excerpt of my gitconfig
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
@tekkub
tekkub / gist:718449
Created November 28, 2010 00:50
TimeMachine chome history ignorance
for year in 2010 2011 2012
do
for month in 01 02 03 04 05 06 07 08 09 10 11 12
do
sudo defaults write /Library/Preferences/com.apple.TimeMachine SkipPaths -array-add "~tekkub/Library/Application Support/Google/Chrome/Default/History Index $year-$month-journal"
sudo defaults write /Library/Preferences/com.apple.TimeMachine SkipPaths -array-add "~tekkub/Library/Application Support/Google/Chrome/Default/History Index $year-$month"
done
done
@tekkub
tekkub / mkv2m4v.sh
Created October 11, 2010 03:37 — forked from innerfence/mkv2m4v.sh
mkv to m4v remuxer
#!/bin/bash
#
# mkv2m4v inputfile.mkv
#
# Given an MKV container with H.264 video and AC3 audio, converts
# quickly to an iPad-compatible MP4 container without re-encoding the
# video (so it must already be in an iPad-compatible resolution); the
# audio is downmixed to stereo with Dynamic Range Compression.
#
@tekkub
tekkub / gist:458212
Created June 30, 2010 03:37
RunNever.wtf
on adding folder items to this_folder after receiving added_items
repeat with i from 1 to number of items in added_items
set this_item to item i of added_items
set the item_info to the info for this_item
if (the name of the item_info is "RunOnce.wtf") then
tell application "Finder"
delete this_item
end tell
end if
@tekkub
tekkub / disk_throughput.rb
Created June 3, 2010 08:14
Drive read throughput tester
#!/usr/bin/env ruby
f = ARGV.first
size = File.size f
puts "Reading #{size/1024/1024} MiB"
t = Time.now
File.read f
total_time = Time.now - t
puts "%.1f sec - %.2f MiB/sec" % [total_time, size/1024/1024/total_time]
@tekkub
tekkub / subtree_merge.sh
Created August 4, 2009 00:30
Subtree merge
#! /bin/bash
# Based off of http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
if [[ ! "$2" || ("$3" && ! "$4" ) ]]
then
filename=`echo "$0"| sed "s/.*\///"`
echo "Usage: $filename remote_name repo_url branch_name path_to_merge_to"
echo " * Create a new subtree merge"
echo " $filename remote_name branch_name"
echo " * Pull from remote_name/branch_name into subtree"