Skip to content

Instantly share code, notes, and snippets.

View sohocoke's full-sized avatar

sohocoke

View GitHub Profile
# Get Sublime Text to use your rvm ruby without hardcoding a `$USER`.
#
# Include the configurations below the commend in the appropriate file listed below:
#
# - OS X ST2: ~/Library/Application Support/Sublime Text 2/Packages/Ruby/Ruby.sublime-build
# - OS X ST3: ~/Library/Application Support/Sublime Text 3/Packages/User/Ruby.sublime-build
# - Linux ST2: ~/.config/sublime-text-2/Packages/Ruby/Ruby.sublime-build
# - Linux ST3: ~/.config/sublime-text-3/Packages/User/Ruby.sublime-build
{
@willurd
willurd / web-servers.md
Last active November 10, 2025 16:13
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@puffnfresh
puffnfresh / CGSSpaces.h
Last active February 20, 2023 17:57
Header for undocumented Spaces APIs
#include <Carbon/Carbon.h>
typedef void *CGSConnectionID;
extern CGSConnectionID _CGSDefaultConnection(void);
#define CGSDefaultConnection _CGSDefaultConnection()
typedef uint64_t CGSSpace;
typedef enum _CGSSpaceType {
kCGSSpaceUser,
kCGSSpaceFullscreen,
@Angles
Angles / some iOS browser URI launching JS snippets.js
Last active August 2, 2024 07:38
"Open In" Bookmarklets for iOS
/* WITH MODS TO ORIG -- iOS Browser Bookmarklets to launch other apps and stuff */
/* ver 2014-04-14a */
/* backing up my "Open In" bookmarks */
// note iOS6 requires some changes to these
// BEGIN TESTING STUFF -- IN PROFRESS LIKELY NOT WORKING
// SOME WORK, MOST tests are not WORK --
// PINNER APP TEST STUFF (as a private one)
// the page title as the title and your selected text as the description.
@henrik
henrik / ocr.markdown
Created March 3, 2012 17:07
OCR on OS X with tesseract

Install ImageMagick for image conversion:

brew install imagemagick

Install tesseract for OCR:

brew install tesseract --all-languages

Or install without --all-languages and install them manually as needed.

@rudyjahchan
rudyjahchan / AClassACategoryImplementation.h
Created January 23, 2012 02:42
Monkey-Patching iOS with Objective-C Categories Part I: Simple Extensions and Overrides
#import <Foundation/Foundation.h>
@interface AClass (ACategory)
@end
@hellopatrick
hellopatrick / attr_indexed.rb
Created November 17, 2011 19:18
Indexed KVO-Compliance & MacRuby
class Object
def self.attr_indexed var, custom_methods = {}
key = var.to_s
capitalized_key = key.capitalize[0] + key[1..-1]
methods = {
:size => lambda { instance_variable_get("@#{var}").size },
:at => lambda { |idx| instance_variable_get("@#{var}")[idx] },
:insert => lambda { |obj, idx| instance_variable_get("@#{var}").insert(idx, obj) },
:delete_at => lambda { |idx| instance_variable_get("@#{var}").delete_at(idx) }
@mikeash
mikeash / gist:1290455
Created October 16, 2011 03:05
hash-based lookup table for classes that don't support native ZWR
void *_MAZeroingWeakRefClassPresentToken = &_MAZeroingWeakRefClassPresentToken;
void *_MAZeroingWeakRefClassNativeWeakReferenceNotAllowedTable[256] = {
[0x3] = (void *[256]) { // 1
[0x5b] = (void *[256]) { // 2
[0x81] = (void *[256]) { // 3
[0x42] = (void *[256]) { // 4
[0xa2] = (void *[256]) { // 5
[0xe] = (void *[256]) { // 6
[0x20] = (void *[256]) { // 7
[0xd7] = (void *[256]) { // 8
@makevoid
makevoid / README.md
Created August 27, 2011 02:23 — forked from reborg/open_local_html_hotcocoa_webview.rb
Hotcocoa basic WebView hello world (to embed a webpp in a native one basically)

Run

if you don't have macruby and hotcocoa already:

rvm use macruby
gem i hotcocoa

ok then you can run:

hotcocoa webviewbasic

@nolanw
nolanw / fscript.rb
Last active September 26, 2015 22:38
Inject F-Script into any app on OS X 10.7 or 10.8. (Yet another F-Script Anywhere replacement.)
#!/usr/bin/env ruby
FSCRIPT_PATH = "/Library/Frameworks/FScript.framework"
if ARGV.empty?
puts "Usage: #{$0} process_name"
exit
end
GDB = IO.popen("gdb", 'w')