diff --git a/_posts/2013-04-18-how-download-rtmp-video.md b/_posts/2013-04-18-how-download-rtmp-video.md index 5394422..7cb4141 100644 --- a/_posts/2013-04-18-how-download-rtmp-video.md +++ b/_posts/2013-04-18-how-download-rtmp-video.md @@ -26,29 +26,41 @@ Since this is questionably legal, make sure you understand any Terms of Services you accepted or laws in your locality regarding this before you follow the steps below ;). -###Have Linux### Most of these instructions will assume you have Ubuntu, but +###Have Linux### + +Most of these instructions will assume you have Ubuntu, but most distributions will work. While RTMPDump works on a variety of operating systems, I've only researched how to do this on Linux. Feel free to comment if you know how to do this in Windows or OSX. -###Install RTMPDump### This open source goodness can be found at +###Install RTMPDump### + +This open source goodness can be found at [http://rtmpdump.mplayerhq.hu/](http://rtmpdump.mplayerhq.hu/) or you can just intall it using your Linux distro's package manager. For Ubuntu, that would be typing the following into your terminal: - sudo apt-get install rtmpdump +```bash +sudo apt-get install rtmpdump +``` -###Redirect ALL the RTMP!### Now we need to configure your firewall to redirect +###Redirect ALL the RTMP!### + +Now we need to configure your firewall to redirect all RTMP traffic to a local port on your computer (Note: this will screw up any RTMP streaming video you try to watch on your computer, so make sure you run the undo command in one of the later steps to return things to normal). Type the following into your terminal, there should be no output from the command: - sudo iptables -t nat -A OUTPUT -p tcp --dport 1935 -j REDIRECT +```bash +sudo iptables -t nat -A OUTPUT -p tcp --dport 1935 -j REDIRECT +``` -###Run rtmpsrv### When you install `rtmpdump`, a program called `rtmpsrv` +###Run rtmpsrv### + +When you install `rtmpdump`, a program called `rtmpsrv` should have been bundled with it and installed as well. We will want to run this now by entering the following command in a terminal: @@ -60,7 +72,9 @@ This should output something that looks like this: Streaming on rtmp://0.0.0.0:1935 -###Feed rtmpsrv the Precious Video### Now go to your browser and open/refresh +###Feed rtmpsrv the Precious Video### + +Now go to your browser and open/refresh the page with the desired video. Try playing the video. If nothing happens and it just continues to give you a black screen, then you're on the right track: rtmpsrv has intercepted the video. @@ -72,18 +86,26 @@ will need it later. You can CTRL+C out of rtmpsrv now that we have what we need. -###Undo the Redirection### You must undo the iptables redirection command we +###Undo the Redirection### + +You must undo the iptables redirection command we performed earlier before you can do anything else, so run this in your terminal: - sudo iptables -t nat -D OUTPUT -p tcp --dport 1935 -j REDIRECT +```bash +sudo iptables -t nat -D OUTPUT -p tcp --dport 1935 -j REDIRECT +``` -###Finally, Download the Precious Video### Now paste that command you copied +###Finally, Download the Precious Video### + +Now paste that command you copied from the rtmpsrv output in the step before last into your terminal prompt and hit enter. You should now see a torrent of `INFO` printout along with a percentage as the video is being downloaded. -###Feast Eyes on Precious Video### Once downloaded, the video file, which has a +###Feast Eyes on Precious Video### + +Once downloaded, the video file, which has a `flv` extension and was named by the `-o` parameter in the command you copied and pasted, should be in your current directory (`ls | grep flv` can find it as well). Any video player should be able to play it, but vlc is a nice video diff --git a/_posts/2013-06-04-w3m-reddit.md b/_posts/2013-06-04-w3m-reddit.md index 8b75705..d6e39bf 100644 --- a/_posts/2013-06-04-w3m-reddit.md +++ b/_posts/2013-06-04-w3m-reddit.md @@ -28,31 +28,33 @@ script wrapper around w3m that takes urls and replaces `"http://reddit.com"` and w3m (as well as fixing a double forward slash error in the comment uri cortex outputs that desktop reddit accepts but mobile reddit 404s on). The script: - #!/bin/bash +```bash +#!/bin/bash - args=() - until [ -z "$1" ]; do - case "$1" in - -t|--tmux) t=1; shift ;; - --) shift ; break ;; - -*) echo "invalid option $1" 1>&2 ; shift ;; # or, error and exit 1 just like getopt does - *) args+=("$1") ; shift ;; - esac - done +args=() +until [ -z "$1" ]; do + case "$1" in + -t|--tmux) t=1; shift ;; + --) shift ; break ;; + -*) echo "invalid option $1" 1>&2 ; shift ;; # or, error and exit 1 just like getopt does + *) args+=("$1") ; shift ;; + esac +done - args+=("$@") - for arg in "${args[@]}" ; do - # Switch to mobile reddit - url=${arg/http:\/\/reddit.com/http:\/\/m.reddit.com} - url=${url/http:\/\/www.reddit.com/http:\/\/m.reddit.com} - # Fix double backslash error in comment uri for mobile reddit - url=${url/\/\/comments/\/comments} - if [[ $t == "1" ]]; then - tmux new-window 'w3m "'${url}'"' - else - w3m "${url}" - fi - done +args+=("$@") +for arg in "${args[@]}" ; do + # Switch to mobile reddit + url=${arg/http:\/\/reddit.com/http:\/\/m.reddit.com} + url=${url/http:\/\/www.reddit.com/http:\/\/m.reddit.com} + # Fix double backslash error in comment uri for mobile reddit + url=${url/\/\/comments/\/comments} + if [[ $t == "1" ]]; then + tmux new-window 'w3m "'${url}'"' + else + w3m "${url}" + fi +done +``` Since I regurally use [Tmux](http://tmux.sourceforge.net/) (with [Byobu](http://byobu.co/)), I also added an optional `-t`/`--tmux` switch that @@ -61,8 +63,10 @@ will open w3m in a temporary new tmux window that will close when w3m is closed. I saved the script as `w3m-reddit` and made it an executable command. In Ubuntu that's done with the following commands: - $ sudo mv w3m-reddit /usr/bin/ - $ sudo chmod +x /usr/bin/w3m-reddit +```bash +$ sudo mv w3m-reddit /usr/bin/ +$ sudo chmod +x /usr/bin/w3m-reddit +``` Now cortex needs to be configured to use `w3m-reddit`, and that's done by setting `browser-command` in the cortex config at `~/.cortex/config` to diff --git a/_posts/2013-07-10-quick-command-line-search-search-pane.md b/_posts/2013-07-10-quick-command-line-search-search-pane.md index 9b1e48d..bc5bd9b 100644 --- a/_posts/2013-07-10-quick-command-line-search-search-pane.md +++ b/_posts/2013-07-10-quick-command-line-search-search-pane.md @@ -52,72 +52,80 @@ This is how I got it setup (on any Ubuntu machine with sudo privileges): Save the following python file in `/usr/bin/` as `search-pane` (no extension): - #!/usr/bin/python - from subprocess import call, check_output - from threading import Thread - import os - import sys - import readline +```python +#!/usr/bin/python +from subprocess import call, check_output +from threading import Thread +import os +import sys +import readline - home = os.path.expanduser("~") - histfile = os.path.join(home, ".search-pane/history") +home = os.path.expanduser("~") +histfile = os.path.join(home, ".search-pane/history") - # load history - readline.read_history_file(histfile) +# load history +readline.read_history_file(histfile) - os.system('cls' if os.name=='nt' else 'clear') # clear the terminal +os.system('cls' if os.name=='nt' else 'clear') # clear the terminal - url = '' - query = '' - if len(sys.argv) > 1: - url = "http://google.com/search?q=" + '+'.join(sys.argv[1:]) # google url - query = ' '.join(sys.argv[1:]) - readline.add_history(query) # add query to history buffer - else: - try: - query = raw_input('Search: ') # get user's search - url = "http://google.com/search?q=" + '+'.join(query.split()) # google - except KeyboardInterrupt: - sys.exit(0) - - readline.write_history_file(histfile) # write search to history file - - def write_other_hosts(): - # write to history files on other registered hosts - with open(os.devnull, 'w') as FNULL: - with open(os.path.join(home, ".search-pane/other-hosts"), "r") as f: - for line in f: - line = line.strip().split() - host = line[0] - path = line[1] - # make sure we don't write to local file again - client_names = check_output(['hostname', '-A']).split() - if (host.split('@')[-1] not in client_names): - call(['ssh', host, 'echo', '"' + query + '"', '>>', path], - stderr=FNULL) - - # Spin off another thread for sshing so user doesn't have to wait for - # connection to complete before viewing w3m. +url = '' +query = '' +if len(sys.argv) > 1: + url = "http://google.com/search?q=" + '+'.join(sys.argv[1:]) # google url + query = ' '.join(sys.argv[1:]) + readline.add_history(query) # add query to history buffer +else: try: - Thread(target=write_other_hosts).start() - except Exception, errtxt: - print errtxt + query = raw_input('Search: ') # get user's search + url = "http://google.com/search?q=" + '+'.join(query.split()) # google + except KeyboardInterrupt: + sys.exit(0) - call(['w3m', url]) # pass url off to w3m +readline.write_history_file(histfile) # write search to history file + +def write_other_hosts(): + # write to history files on other registered hosts + with open(os.devnull, 'w') as FNULL: + with open(os.path.join(home, ".search-pane/other-hosts"), "r") as f: + for line in f: + line = line.strip().split() + host = line[0] + path = line[1] + # make sure we don't write to local file again + client_names = check_output(['hostname', '-A']).split() + if (host.split('@')[-1] not in client_names): + call(['ssh', host, 'echo', '"' + query + '"', '>>', path], + stderr=FNULL) + +# Spin off another thread for sshing so user doesn't have to wait for +# connection to complete before viewing w3m. +try: + Thread(target=write_other_hosts).start() +except Exception, errtxt: + print errtxt + +call(['w3m', url]) # pass url off to w3m +``` Make the directory and file for search history: - mkdir ~/.search-pane - touch ~/.search-pane/history +```bash +mkdir ~/.search-pane +touch ~/.search-pane/history +``` Allow anyone to execute the python script (make it into a program): - chmod a+x /usr/bin/search-pane +```bash +chmod a+x /usr/bin/search-pane +``` To get quick access to the program from the command-line edit `~/.bashrc` to add: - alias s='search-pane' +```bash +alias s='search-pane' +``` To add byobu key bindings edit `~/.byobu/keybindings.tmux` (or `/usr/share/byobu/keybindings/f-keys.tmux`): diff --git a/_posts/2013-08-24-on-chromebooks.md b/_posts/2013-08-24-on-chromebooks.md index 9ebe087..f1130d4 100644 --- a/_posts/2013-08-24-on-chromebooks.md +++ b/_posts/2013-08-24-on-chromebooks.md @@ -3,45 +3,208 @@ title: On Chromebooks layout: post --- -I like to think that if only I find The Perfect Text Editor I will somehow -write better and more often. Obviously this is only a tactic I use to delay -actually writing anything, but I did come across something that might actually -help. [Draft](https://draftin.com) is a writing app being developed by one guy, -[Nate Kontny](https://twitter.com/natekontny), that has a ton of nifty -features, one of its best being a version control system that allows you to -send a draft to other people and accept or reject any changes they suggest. It -also has a minamilistic iA Writer type interface, which focuses on the actual -writing and nothing more. +Like a lot of people, I didn’t see a clear use-case for Chromebooks. They’re +just glorified browsers, right? What if I wanted to do anything outside of the +browser? Why would you spend [$1299 or $1449 for a +computer](https://www.google.com/intl/en/chrome/devices/chromebooks.html#pixel) +that can only run a browser? -One of my most favorite features that I have just discovered, though, is that -it allows publishing any Draft document to any arbitrary -[WebHook](http://en.wikipedia.org/wiki/Webhook). Which basically means I can -click a button in the interface and that will send a POST request to a URL I -specify with all of the data for my Draft document in JSON format. I can just -write a bit of code to parse that data and then I instantly have a better -editor for my blog. +While I know a lot of people who buy expensive MacBooks only to just use a web +browser and iTunes, I’m a bit more of a power user and I need things like +[Eclipse](http://www.eclipse.org/) (popular programming IDE) and +[Inkscape](http://inkscape.org/) (open source vector graphics editor). I +figured that if I’d ever get a Chromebook, I would quickly ditch its crippled +ChromeOS for [Ubuntu](http://www.ubuntu.com/) instead, so I could use my +favorite operating system on the quality Chromebook hardware. It turns out, a +lot of people do this. So many that there are a couple of Ubuntu forks that +have been developed that allow you to run both ChromeOS and Ubuntu on the same +Chromebook: [ChrUbuntu](http://chromeos-cr48.blogspot.fr/) and +[Crouton](https://github.com/dnschneid/crouton). -It was really easy to do too. For this Django website, all it took [was adding -a view that parsed a JSON object and made a blog entry out of -it](https://github.com/thallada/personalsite/commit/c4694a6669dbc7b79a5bff3fb818a682ecacffbb). -You can read the -[documentation](https://draftin.com/documents/69898?token=5fjKKlZ0-AeBzqj_RAftAGdzRzl9VBfBHj5wpSWm_gU) -for more info on how to make a WebHook for Draft. +However, when I recently acquired a [Samsung +Chromebook](https://www.google.com/intl/en-US/chrome/devices/samsung-chromebook.html#ss-cb): +Google’s ARM processor Chromebook, I discovered what makes Chromebooks, and +even ChromeOS, so amazing. **I realized there is no need for anything more than +Chrome**. Even for a power user like me. -Nate has also made a lot of other neat features, like a [Chrome extension that -turns any textarea on the web into a Draft -document](https://chrome.google.com/webstore/detail/draft/amlbbbgcijmiooecobhkjblcdkjldmdk). -Read about some of the other features in the [Lifehacker -article](http://lifehacker.com/5993339/draft-is-a-writing-app-with-serious-version-and-draft-control). -The app is still in development and new features are being added constantly. + -I think the take-away here is that the Big Guys, with apps like Google Drive or -Evernote, don't always have the best solutions. I tried hacking Google Drive -into a more immersive writing experience with templates and so on, but nothing -came close to the experience of Draft, which was exactly what I wanted to begin -with. It's a wonder that more people don't know about Draft, but I guess that's -part of the magic. There's a real person, an innovative and driven hacker, -behind the product who might actually listen to what I have to say. +Before long, I had completely abandoned my old heavy [2011 Dell +Inspiron](http://www.cnet.com/laptops/dell-inspiron-n5110-15/4505-3121_7-35127205.html) +in favor of my Samsung Chromebook. While the Dell laptop clearly has more +computing power, I preferred the Chromebook for a few reasons: -Now excuse me while I go waste more time scouring the web for more obscure but -brilliant apps. +* **Lightweight**: it’s only 2.4 pounds. That feels like nothing compared to +the 5.5 pound monstrosity that used to weigh down my backpack. +* **Battery life**: officially it’s 6.5 hours, but I’ve seen up to 9 hours +before. It’s very freeing to not need to plug in my laptop everywhere I go. +* **Size**: the screen is just 11.6” and it’s 0.7” thin. I honestly didn’t +think I’d prefer a smaller laptop, but the experience has been a lot better in +general. +* **Screen Resolution**: even though the screen is smaller, it’s still 1366x768 +-- the same as my Dell laptop. Resolution is very important to me: higher +resolution means I can fit more information on the screen, and my young eyes +can handle the smaller text. Going back to my Dell feels like looking through a +magnifying glass now. +* **Trackpad**: I use an [Apple Magic +Trackpad](http://www.apple.com/magictrackpad/?) at work, which is heralded as +the best trackpad out there, and in my opinion the Samsung Chromebook has a +trackpad that’s just as nice. Don’t even get me started with how horrible the +Dell trackpad is; I had to disable it and use keyboard shortcuts for everything +instead. +* **Keyboard**: the Chromebook has a keyboard that closely resembles an Apple +keyboard, and it’s hard to describe exactly why, but the feedback just makes it +feel *nicer* to type on than the one on my Dell laptop. Also, the search key +that replaces the Caps Lock key is really useful. +* **Price**: all of this great hardware for just $249 seems unreal. I’m sure +this is what converts many people, and it’s good to know I can do everything I +need to on a laptop that’s under $300. +* **Perks**: as an aside, Google also gives you 100GB free Google Drive space +for 2 years and 12 free Gogo passes with the Chromebook, which definitely comes +in handy. + +