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
# Ways to execute a shell script in Ruby | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Returns the result of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 | |
value = `echo 'hi'` # or uglier but valid => Kernel.`("echo 'hi'") |
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
#!/usr/bin/env python | |
## DESCRIPTION | |
## The script provides an iterator over the search results returned by google, after giving a query. | |
## | |
## EXAMPLES | |
## TODO: Show some examples of how to use this script. | |
## | |
## EXIT STATUS | |
## No exit statuses provided. The class simply returns an iterator over the results. Only error raised is the StopIteration. |
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
# Aloha number - number with all digits '4' or '7' | |
# Q - Given a number, find the aloha number just greater or equal to given number. | |
def alt(s): | |
# print "Number: ", s | |
if s == '4': | |
return '7' | |
elif s == '7': | |
return '44' | |
# s = str(n) | |
i = s.find('8') if s.find('8') != -1 else s.find('9') |
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
#!/usr/bin/env python3 | |
import PIL.Image as Image | |
import sys | |
extension = ".png" | |
def saveImage(image, imageName): | |
image.save(imageName + extension) |
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
import UIKit | |
extension UIViewController { | |
func performSegueOnMainQueue(identifier: String, sender: AnyObject?) { | |
NSOperationQueue.mainQueue().addOperationWithBlock() { | |
self.performSegueWithIdentifier(identifier, sender: sender) | |
} | |
} |
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
# Byte-compiled / optimized / DLL files | |
__pycache__/ | |
*.py[cod] | |
*$py.class | |
# Distribution / packaging | |
.Python | |
env/ | |
build/ | |
develop-eggs/ |
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
for i in os.listdir('.'): | |
if i.startswith('.') == False: #Hidden files | |
os.rename(i, i[3:]) |
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
def digits(x): | |
return set([int(j) for j in str(x)]) | |
x = 1000 | |
while True: | |
#write code | |
y = int(1.668*x) | |
for i in range(x, y): | |
print i |
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
#!/usr/bin/env bash | |
if [ $# -lt 2 ] | |
then | |
echo "ERROR: Less arguments." | |
echo "Usage: git-subtree-add <git-url> <ref(commit)>" | |
else | |
REPO_NAME=`echo $1 | sed 's%^.*/\([^/]*\)\.git$%\1%g'` | |
echo "Adding subtree for " | |
echo $REPO_NAME |
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
#! /usr/bin/python | |
import sys | |
def colorForHex(x): | |
if len(x) != 6: | |
return "Poorly formatted HEX", x | |
try: | |
r = int(x[:2], 16) | |
g = int(x[2:4], 16) |