Skip to content

Instantly share code, notes, and snippets.

Avatar
🌿
Rejuvenating

Brandon Rubin Steelsouls

🌿
Rejuvenating
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.
View terminal_width.py
#!/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
View script_starter.py
#!/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)
View truthy.md

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
View etc: Juicy Color Hex Codes
---
- 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)
View linux: Unity Launcher Template
[Desktop Entry]
Version=1.0
Name=
GenericName=
Exec=
Terminal=false
Icon=
Type=Application
Categories=