Skip to content

Instantly share code, notes, and snippets.

View drobati's full-sized avatar
💻
coding

Derek Robati drobati

💻
coding
View GitHub Profile
@taggartbg
taggartbg / Connect2021_TaggartBowen-Gaddy.js
Last active November 10, 2021 19:39
Temporal API Examples for Connect 2021 Presentation
// Create an Instant
const now = Temporal.Now.instant()
// Plain Objects
const pd = Temporal.Now.plainDateISO()
const pt = Temporal.Now.plainTimeISO()
const pdt = Temporal.Now.plainDateTimeISO()
const pdt2 = Temporal.PlainDateTime.from(pd).withPlainTime(pt)
const pym = Temporal.PlainYearMonth.from({ year: 2020, month: 10 })
@dusya
dusya / Drunk-hello.txt
Last active August 22, 2016 23:30
Hello, I'm drunk
Hello, it's me
I'm just calling cause I've had a little bit too much to drink
At the bar, then the club
They say tequila's supposed to heal ya
But I'm feelin kinda queasy
Hello, can you hear me?
I'm standing in a crowded bathroom and I really have to pee
I might not make it to the stall
With all these people all around me, I'll have a puddle at my feet
@bearfrieze
bearfrieze / comprehensions.md
Last active December 23, 2023 22:49
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

by Bjørn Friese

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

(lambda main: main(0, 'https://opensource.org/licenses/MIT', ''.join(filter(str.isalpha, __import__('random').choice(open('/usr/share/dict/words').readlines()).upper())), set(), '|======\n| |\n| {3} {0} {5}\n| {2}{1}{4}\n| {6} {7}\n| {8} {9}\n|', list('OT-\\-//\\||'), 10, main))(lambda _, license, chosen_word, guesses, scaffold, man, guesses_left, main_: main_(map(guesses.add, filter(str.isalpha, raw_input('%s(%s guesses left)\n%s\n%s:' % (','.join(sorted(guesses)), guesses_left, scaffold.format(*(man[:10-guesses_left] + [' '] * guesses_left)), ' '.join(letter if letter in guesses else '_' for letter in chosen_word))).upper())), license, chosen_word, guesses, scaffold, man, max((10 - len(guesses - set(chosen_word))), 0), main_) if not all(letter in guesses for letter in chosen_word) and guesses_left else __import__('sys').stdout.write('You ' + ['lose!\n' + scaffold.format(*man), 'win!'][bool(guesses_left)] + '\nWord was ' + chosen_word + '\n'))
@danverbraganza
danverbraganza / hangman.py
Last active April 20, 2017 18:52
Hangman implemented in 3 lines of Python! For an explanation of how this works, see http://danverbraganza.com/writings/hangman-in-3-lines-of-python
license, chosen_word, guesses, scaffold, man, guesses_left = 'https://opensource.org/licenses/MIT', ''.join(filter(str.isalpha, __import__('random').choice(open('/usr/share/dict/words').readlines()).upper())), set(), '|======\n| |\n| {3} {0} {5}\n| {2}{1}{4}\n| {6} {7}\n| {8} {9}\n|', list('OT-\\-//\\||'), 10
while not all(letter in guesses for letter in chosen_word) and guesses_left: _, guesses_left = map(guesses.add, filter(str.isalpha, raw_input('%s(%s guesses left)\n%s\n%s:' % (','.join(sorted(guesses)), guesses_left, scaffold.format(*(man[:10-guesses_left] + [' '] * guesses_left)), ' '.join(letter if letter in guesses else '_' for letter in chosen_word))).upper())), max((10 - len(guesses - set(chosen_word))), 0)
print 'You', ['lose!\n' + scaffold.format(*man), 'win!'][bool(guesses_left)], '\nWord was', chosen_word
@jefflarkin
jefflarkin / gpio.sh
Last active April 13, 2018 22:15
BASH functions for using the C.H.I.P. GPIO pins.
#!/bin/bash
#FIXME Add usage() function to improve documentation
# Enable exposure of the specified GPIO pin (0-8)
gpio_enable()
{
if [[("$1" -lt 0) || ("$1" -gt 8)]] ; then
echo "Valid pins are 0-8"
return -1;
fi
@rgaidot
rgaidot / docker-resources.md
Last active October 22, 2023 13:02
Docker Resources All In One - A collection of docker online resources
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#