Skip to content

Instantly share code, notes, and snippets.

View johnpena's full-sized avatar

John Peña johnpena

View GitHub Profile
@johnpena
johnpena / yesOrNo.py
Last active January 20, 2021 14:15 — forked from garrettdreyfus/yesOrNo.py
Dead simple python function for getting a yes or no answer.
def yes_or_no(question):
reply = str(raw_input(question+' (y/n): ')).lower().strip()
if reply[0] == 'y':
return True
if reply[0] == 'n':
return False
else:
return yes_or_no("Please enter y or n: ")
@johnpena
johnpena / sy.md
Last active April 16, 2020 22:13 — forked from cornchz/sy.md
Notes from the Mystery Machine Bus - Steve Yegge

Notes from the Mystery Machine Bus

I've spent the past eight years (starting back in June 2004) writing elaborate rants about a bunch of vaguely related software engineering issues.

I was doing all that ranting because I've been genuinely perplexed by a set of "bizarre" world-views held dear by -- as far as I can tell -- about half of all programmers I encounter, whether online or in person.

Last week, after nearly a decade of hurling myself against this problem, I've finally figured it out. I know exactly what's been bothering me.

In today's essay I'm going to present you with a new conceptual framework for thinking about software engineering. This set of ideas I present will be completely obvious to you. You will probably slap yourself for not having thought of it yourself. Or you might slap the person next to you. In fact you probably have thought of it yourself, because it is so blindingly obvious.

@johnpena
johnpena / gist:7aa2e7968ba21a768cdc516e320544a3
Last active September 22, 2024 23:52 — forked from taylor/gist:3804760
Return of the Mystery Machine Bus! In 3D! by Steve Yegge

Steve Yegge -- Aug 15, 2012 - Public

Return of the Mystery Machine Bus! In 3D!

The inputs are in! Everyone's had a chance to mull over my liberal/conservative distinction in the big world of programming styles and approaches to software engineering. Lots of great feedback.

Thank you to everyone who took the time to think about this conceptual model and share your thoughts.

Here are a few things that jumped out at me, reading the feedback.

@johnpena
johnpena / bouncer.go
Created January 1, 2020 20:45
Very basic example of a non-queueing worker pool + bouncer in go
package main
import (
"fmt"
"time"
)
func main() {
concurrency := 10
bouncer := make(chan bool, concurrency)
import sys
import requests
import json
import random
from http.server import HTTPServer, BaseHTTPRequestHandler
class MessageHandler(BaseHTTPRequestHandler):
def __init__(self):
BaseHTTPRequestHandler.__init__()
self.current_timestamp = random.randint(1000, 5000)
@johnpena
johnpena / .gitconfig
Created October 24, 2016 18:28
.gitconfig stuff
# Stick this in ~/.gitconfig
[alias]
# Shortcuts:
st = status -sb
br = branch
co = checkout
sha = rev-parse HEAD
# List all tracked files:

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@johnpena
johnpena / decorators_with_arguments.py
Created November 17, 2015 00:51
My preferred way of making a decorator with arguments
class great_stuff(object):
def __init__(self, a, b, c):
"""
__init__ is *not* passed the function to be decorated if arguments
are passed to the decorator.
"""
self.a = a
self.b = b
self.c = c
@johnpena
johnpena / gist:2b3b4f90bbca0253f604
Created May 8, 2015 17:09
Solutions to this blog post
"""https://blog.svpino.com/2015/05/08/solution-to-problem-5-and-some-other-thoughts-about-this-type-of-questions"""
from itertools import permutations, product
def problem1():
def forloop(numbers):
s = 0
for number in numbers:
s += number
return s
@johnpena
johnpena / gist:b7ab67303b06fb1fdadc
Last active August 29, 2015 14:07
__subclasses__ changes when new classes come into scope via an import
# crap/a.py
class A(object):
pass
print A.__subclasses__() # this will be an empty list, []
# crap/b.py
from a import A