Skip to content

Instantly share code, notes, and snippets.

View Steelsouls's full-sized avatar
🎯
Focusing

Brandon Rubin Steelsouls

🎯
Focusing
View GitHub Profile
@Steelsouls
Steelsouls / terminal_width.py
Last active August 29, 2015 13:57
Function to return width of terminal running the script. Perfect for CLI apps in determining available space for formatting output data. If run as a script simply prints the number.
#!/usr/bin/env python
import subprocess
command = ['tput', 'cols']
def get_terminal_width():
try:
width = int(subprocess.check_output(command))
@Steelsouls
Steelsouls / script_starter.py
Created January 30, 2014 01:08
Python: Template Command-Line Script
#!/usr/bin/env python
def main():
# Make list of command line arguments, omitting the script itself.
args = sys.argv[1:]
if not args:
print "usage: "
sys.exit(1)

true and false vs. "truthy" and "falsey" (or "falsy")

by Jesse Farmer

Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true and false. In Python, for example, they're written as True and False.

But oftentimes we want to use a non-boolean value (integers, strings, arrays, etc.) in a boolean context (if statement, &&, ||, etc.). So someone designing a language has to decide what values count as "true" and what count as "false." A non-boolean value that counts as true is called "truthy," and a non-boolean value that counts as false is called "falsey."

@Steelsouls
Steelsouls / etc: Juicy Color Hex Codes
Created May 30, 2013 19:06
Color codes for my favorite scheme - Juicy from Dayle Rees Schemes Sublime Text Package
---
- Background:
- 222222
Foreground:
- e3e2e0
Teal:
- 3bc7b8
Yellow:
- f9d423
Red:
@Steelsouls
Steelsouls / linux: Unity Launcher Template
Last active November 12, 2021 17:29
Unity Launcher Template (save-to: /usr/share/applications/app-name.desktop)
[Desktop Entry]
Version=1.0
Name=
GenericName=
Exec=
Terminal=false
Icon=
Type=Application
Categories=