From c45ce8f48be9d2cd2d89c36ffb517b0ebafea6f5 Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Thu, 24 Jul 2014 13:00:30 -0400 Subject: [PATCH] Fix post styling --- _posts/2013-04-18-how-download-rtmp-video.md | 44 +++- _posts/2013-06-04-w3m-reddit.md | 54 ++-- ...0-quick-command-line-search-search-pane.md | 108 ++++---- _posts/2013-08-24-on-chromebooks.md | 237 +++++++++++++++--- css/main.css | 2 + 5 files changed, 322 insertions(+), 123 deletions(-) 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. +Samsung Chromebook open on a
+porch -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. + +
Samsung Chromebook
+keyboard up close Samsung Chromebook
+trackpad up close

+ +While that all of that is nice, the Chromebook still only has 16GB internal +storage, no DVD drive, no ethernet port, and hardly any processing power. And I +still need to be able to code and write on my laptop and access specific +programs that only run on Linux or Windows machines. ChromeOS has a lot of +things built in to get around these limitations, but some things require a bit +of tweaking. If anyone has read my past posts, they know that I am obsessed +with configuring things. Here is what I came up with for everything I would +ever need to do on my Chromebook: + +###Writing### + +I spent a lot of time downloading +[various](https://chrome.google.com/webstore/detail/write-space/aimodnlfiikjjnmdchihablmkdeobhad) +[writing](https://chrome.google.com/webstore/detail/writer/pnengefjfhgcceajaepbjhanoojifmog) +[applications](https://chrome.google.com/webstore/detail/writebox/bbehjmjchoiaglkeboicbgkpfafcmhij) +from the Chrome Web Store, but nothing seemed to work as well and seemless as +the stock Google Drive documents application. You can’t beat automatic saving +to the cloud with the ability to collaborate simultaneously with other people. + +In order to make the experience more immersive put Chrome into fullscreen and +hide the controls by clicking the “View” menu and then selecting “Full Screen”. +I’m currently in the Beta channel of ChromeOS, so you may need to switch to +that channel and enable “Immersive Mode” in `chrome://flags` to get it looking +like I have in the screenshot ([more +info](http://gigaom.com/2013/08/22/chrome-os-users-gain-immersive-mode-and-more-in-stable-channel-update/)) + +Demonstrating Google Docs in
+fullscreen immersive mode + +Another little-known feature of Google Docs is creating a new document based +off of a template. I made a couple templates that expand the page out to almost +100% and resemble the colors of the OSX IA Writer app: one in [Gentium +Basic](https://drive.google.com/previewtemplate?id=1N7kZhXsYJoVJpt4rE5q7Xhp92M4DPB_-u2dOSkEAeRY&mode=public) +and one in [Open +Sans](https://drive.google.com/previewtemplate?id=1aX8UcUXpbiZD1HuTIofb8ookw6TYykWi50k47BTX6yk&mode=public). +To create a new document based off of a template: have a document already open, +go to the “File” menu, “New…”, and select “From Template…”. It’s kind of a +hassle though, so I often just stick to the default style. It’s a sign that I +am procrastinating if I’m trying to look for the “perfect template” to write in +anyways. + +###Programming### + +I’ve gotten so used to [vim](http://www.vim.org/) in a Linux +terminal that I don’t think I could ever use any other editor. There are a few +local offline code editors for Chrome like +[Text](https://chrome.google.com/webstore/detail/text/mmfbcljfglbokpmkimbfghdkjmjhdgbg) +and +[ShiftEdit](https://chrome.google.com/webstore/detail/shiftedit/lcgmndephhjcabhhjfcmncnhbmgbkpij) +which are nice if I’m working on a Chrome extension and want to keep the files +locally so I can test them on my Chromebook. However, I still do most of my +coding remotely on a Linux machine. + +ChromeOS provides a way, out of the box, to ssh into any computer through it’s +terminal called “crosh”. Access crosh by typing Ctrl+Alt+T. But, I actually +prefer +[SecureShell](https://chrome.google.com/webstore/detail/secure-shell/pnhechapfaindjhompbnflcldabbghjo) +as an ssh client since it has more customization and can be opened up in a +separate window. + +Don’t have a Linux computer to ssh into? [Digital +Ocean](https://www.digitalocean.com/) has servers starting at $5/month. +Cheapest and easiest offer I’ve seen yet (no that's not a referral link, I’m +being genuine about that). + +For using Eclipse or any of those other Windows/Linux specific GUI programs +there’s [Chrome Remote +Desktop](https://chrome.google.com/webstore/detail/chrome-remote-desktop/gbchcmhmhahfdphkhkmpfmihenigjmpp) +which is installed by default on Chromebooks. I haven’t had the need to try it +out yet, but it’s nice to have around for when I do. + +The best thing about coding on a Linux box through a Chromebook is that I still +have all of the great chrome apps and extensions right at my fingertips. +Especially when some apps can be opened up in small panels in the corner of the +screen temporarily. + +###Panels### + +Chrome recently released a new concept for opening new windows +called “Panels”, and once I discovered them I couldn’t get enough of them. The +new feature allows apps and extensions to open up small chrome windows in the +bottom right corner of the screen and then draw the user’s attention when they +have a new notification. + +They are absolutely perfect for long-running applications that need to stick +around but not be in your way, like chat programs and music programs. When I’m +fullscreen in some other chrome window, I can quickly click the panel’s icon +and the window will pop open above all of the other windows. I can then +interact with it and minimize it back into the dock out of my way. + +Demonstrating chrome panels with
+Panel View for Play Music open + +In order to enable them I had to be on the Beta channel of the ChromeOS and +enable “Panels” in `chrome://flags` ([more +info](http://www.chromium.org/developers/design-documents/extensions/proposed-changes/apis-under-development/panels)). + +Since panels is such a recent feature, it’s hard to find apps that are +utilizing panels. Here are some that I have found useful and are working for +me: + +* [Panel View for Play +Music](https://chrome.google.com/webstore/detail/panel-view-for-play-music/dimpomefjdddhjmkjgjdokhidjkcmhhn) +* +[Hangouts](https://chrome.google.com/webstore/detail/hangouts/nckgahadagoaajjgafhacjanaoiihapd) +* [Panel View for Google +Keep](https://chrome.google.com/webstore/detail/panel-view-for-keep/jccocffecajimkdjgfpjhlpiimcnadhb) +* [Google Tasks +Panel](https://chrome.google.com/webstore/detail/improved-google-tasks-pan/kgnappcencbgllhghhhgjnfjanfijdpn/) + +I’m still lacking Facebook Messenger and Google Voice panel view apps, so I +might try my hand at creating one myself soon. + +###Web Browsing### + +And, of course, being a laptop dedicated to chrome, it +obviously has a great web browsing experience. + +Pin certain websites or apps to the dash at the bottom of the screen for easy +access to favorite content. Once pinned, open them by pressing Alt+NUM, where +NUM is the icon’s position on the dash from the left. + +The search key on the keyboard opens a panel from the bottom of the screen to +enter in a search. The results give preference towards apps in the Chrome Web +Store as well, so it’s sometimes more useful than the Omnibar Chrome users are +used to. + +Tangentially, I have found [Gmail +Offline](https://chrome.google.com/webstore/detail/gmail-offline/ejidjjhkpiempkbhmpbfngldlkglhimk) +very useful for email. It has an uncluttered UI inspired by the Gmail mobile +app, and runs very smoothly. + +Let me know if you have anything else to add, or even if you would like to +argue against why Chromebooks are the best laptops :). diff --git a/css/main.css b/css/main.css index 8c96802..3ff9c90 100755 --- a/css/main.css +++ b/css/main.css @@ -233,10 +233,12 @@ div.pagination { border: 1px solid #ddd; background-color: #eef; padding: 0 .2em; + font-size: small; } .post pre code { border: none; + padding: 0; } /* terminal */