This file contains hidden or 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
| import Cocoa | |
| // Load data from a URL. | |
| let url: NSURL = NSURL(string: "http://www.tokyomuslim.com") | |
| let resultsData = NSData(contentsOfURL: url, options: NSDataReadingOptions.DataReadingUncached, error: nil) | |
| let resultsString:NSString = NSString(data: resultsData, encoding: NSUTF8StringEncoding) | |
| // Load JSON data. | |
| let jsonUrl: NSURL = NSURL(string: "https://api.github.com/users/mralexgray/repos/") | |
| let jsonResultsData = NSData(contentsOfURL: jsonUrl, options: NSDataReadingOptions.DataReadingUncached, error: nil) |
This file contains hidden or 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
| #! /bin/bash | |
| # Wait for a CD to be inserted then copy the contents | |
| # | |
| echo "CD copy, press <ctrl>C to exit" | |
| echo "Looking for disk..." | |
| # | |
| # Go into a continuous loop always looking for a new CD | |
| while : | |
| do |
This file contains hidden or 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
| NameVirtualHost facebook.com:80 | |
| <VirtualHost facebook.com:80> | |
| ServerAdmin [email protected] | |
| DocumentRoot /var/www/docs/facebook.com | |
| ServerName facebook.com | |
| ErrorLog logs/facebook.com-error_log | |
| CustomLog logs/facebook.com-access_log common | |
| </VirtualHost> | |
| # /var/www/docs/facebook.com/index.php |
This file contains hidden or 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
| # This is a simple websql class I built in coffeescript. | |
| # This gives a good example of how to use "fat arrows" to maintain a different | |
| # level's "this" pointer - without fat arrows, you will not be able to save @results | |
| "use strict"; | |
| root = exports ? this | |
| class @websql | |
| constructor: -> |
This file contains hidden or 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
| A few years ago: | |
| def parseBugzillaCookies(self,s): | |
| if s is None: return {self.SESSION_ID_STRING:None} | |
| ret = {} | |
| tmp = s.split(';') | |
| for t in tmp: | |
| t = t.replace('HttpOnly, ','') | |
| coppia = t.split('=') | |
| if coppia[0].strip() in ['Bugzilla_logincookie','Bugzilla_login']: |
This file contains hidden or 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
| o = open("Kanji_Vocab_List.txt") | |
| contents = o.read().decode('utf8') | |
| o.close() | |
| c = contents.split() | |
| words = [ (c[i], c[i+1]) for i in range(len(c)) if i%2==0 ] | |
| # This is for testing actually writing the kanji. | |
| output = [] |
This file contains hidden or 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
| import os | |
| def chgrp(filepath, gid): | |
| uid = os.stat(filepath).st_uid | |
| os.chown(filepath, uid, gid) |
This file contains hidden or 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
| for file in *.m4v ; do | |
| ffmpeg -ss 00:00:15 -i $file -vframes 1 -an -f image2 $(echo $file | rev | cut -f2- -d. | rev).png | |
| done |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # This is intended as a quick and dirty image resizer. It doesn't even check to see if the filename is already in use. I | |
| # don't suggest it for production use without changes. | |
| # Stashing it here for future improvements. | |
| import Image | |
| import sys | |
| import os | |
| def resize_image_width_ratio(filename, new_filename, max_width=800): |
This file contains hidden or 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
| # This is not tested and not complete, but give an interesting example of how you can turn a Django view into something reusable. | |
| # It is based on the code here: http://code.google.com/p/django-jqchat/ | |
| # It might make sense to turn this into an abstract base class. | |
| # The purpose of this is: | |
| # 1. Improved code reuse for outputting data. | |
| # 2. Easier modification to relevant areas | |
| # 3. Because it is new and interesting to me (Kiss my future jobs goodbye for admitting that :/) | |
| # 4. Can stash it in a different file, so the view is not as cluttered-up. |