Created
November 11, 2011 16:59
-
-
Save rsky/1358536 to your computer and use it in GitHub Desktop.
Make Gyazo configurable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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