Skip to content

Instantly share code, notes, and snippets.

@rsky
Created November 11, 2011 16:59
Show Gist options
  • Save rsky/1358536 to your computer and use it in GitHub Desktop.
Save rsky/1358536 to your computer and use it in GitHub Desktop.
Make Gyazo configurable
--- Gyazo.app/Contents/Resources/script
+++ Zyazo.app/Contents/Resources/script
@@ -2,6 +2,15 @@
require 'net/http'
+def gyazo_read_defaults(name, alternative, namespace = 'com.gyazo.Gyazo')
+ value = `defaults read '#{namespace}' '#{name}' 2>/dev/null`
+ if $? == 0
+ value.chomp
+ else
+ alternative
+ end
+end
+
# get id
user = IO.popen("whoami", "r+").gets.chomp
program = ARGV[0].to_s
@@ -38,9 +47,19 @@
# upload
boundary = '----BOUNDARYBOUNDARY----'
-HOST = 'gyazo.com'
-CGI = '/upload.cgi'
-UA = 'Gyazo/1.0'
+HOST = gyazo_read_defaults('HOST', 'gyazo.com')
+CGI = gyazo_read_defaults('CGI', '/upload.cgi')
+UA = gyazo_read_defaults('UA', 'Gyazo/1.0')
data = <<EOF
--#{boundary}\r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment