Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
~/.bin/isightcapture -t jpg ~/tmpTweetAWakeup.jpg | ||
sleep 10 | ||
URL=`python ~/Documents/random-coding/TweetAWakeup/upload.py ~/tmpTweetAWakeup.jpg` | ||
twurl tweet -d "status=${URL} #TweetAWakeup" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var http = require('http'); | ||
var multipart = require('multipart'); | ||
var sys = require('sys'); | ||
|
||
function upload_file(req, res) { | ||
req.setBodyEncoding('binary'); | ||
|
||
var stream = new multipart.Stream(req); | ||
stream.addListener('part', function(part) { | ||
part.addListener('body', function(chunk) { | ||
var progress = (stream.bytesReceived / stream.bytesTotal * 100).toFixed(2); | ||
var mb = (stream.bytesTotal / 1024 / 1024).toFixed(1); | ||
|
||
sys.print("Uploading "+mb+"mb ("+progress+"%)\015"); | ||
|
||
// chunk could be appended to a file if the uploaded file needs to be saved | ||
}); | ||
}); | ||
stream.addListener('complete', function() { | ||
res.sendHeader(200, {'Content-Type': 'text/plain'}); | ||
res.sendBody('Thanks for playing!'); | ||
res.finish(); | ||
sys.puts("\n=> Done"); | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
import urllib2, base64, urllib, json, sys | ||
from datetime import datetime | ||
|
||
if __name__ == '__main__': | ||
print json.loads(urllib2.urlopen('http://api.imgur.com/2/upload.json', | ||
data=urllib.urlencode({ | ||
'key': '927ff7a7e84621a6371c2f0aaf8dc770', | ||
'image': base64.encodestring( | ||
open(sys.argv[1]).read()), | ||
'type': 'base64', | ||
'name': 'TweetAWakeup: '+str(datetime.now()), | ||
'title': 'TweetAWakeup: '+str(datetime.now()) | ||
})).read())['upload']['links']['imgur_page'] |