Skip to content

Instantly share code, notes, and snippets.

gistup
@bgschiller
bgschiller / .gitignore
Last active April 27, 2020 17:42
FormalSignature problem
test
variadic
main
@bgschiller
bgschiller / csharp_pain.txt
Created November 10, 2018 03:14
A line-by-line description of the pain I ran into while trying to deploy a csharp app using codeship
run db locally -> sql server doesn't run on ubuntu 12.04
run sql server locally via docker -> codeship basic doesn't permit docker
learn enough docker to use codeship pro? maybe, but explore other routes first.
run db on RDS.
connect to db -> in sql server, port is specified via comma, not colon.
connect to db -> ubuntu doesn't have odbc driver for sql server
download and install FreeTDS drivers.
connect to db -> user not authenticated
connect to db locally works.
connect to db from build server doesn't work.
@bgschiller
bgschiller / spread-operator.html
Created August 24, 2018 03:26
Spread and this exercises
<style>
.small {
font-size: 8px;
margin-bottom: 40px;
}
</style>
<body>
<h1>Spread operator</h1>
<p class="small">(not just for PB&amp;J)</p>

What's an interface?

When we talk about interfaces or protocols, there are a couple different ideas that often get lumped together. It might help to explain why some languages use "protocol" and some use "interface"—they have slightly different connotations.

Both concepts, at their best, are a way of saying "all I need is a type that supports..." along with a list of what it needs. This is what people mean when they say "Depend on abstractions instead of on concrete classes".

The main difference between Interfaces and Protocols is that Interfaces have to be explicitly implemented, or they don't compile. Protocol usually implies that, as long as the type signatures match, we're happy.

Interfaces

@bgschiller
bgschiller / README.md
Created April 20, 2018 17:38
Workaround for "cypress ci hangs on codeship" bug

Workaround for "Cypress build hangs on codeship"

cypress-io/cypress#328

The plan: Wrap cypress in a script that watches its output, kills the process when cypress is done.

We'll need to capture the line Failures: 0 or Failures: 5 in order for the wrapper script to produce an appropriate exit code. That is, it should sys.exit(0) if all tests passed, and sys.exit(1) if any failed.

Here we run into a bit of a problem: The ANSI escape codes that Cypress uses to color it's output include numbers to specify the color. For example, green text is prepended with \e[30m. Even though these color codes aren't visible in the terminal, pexpect can see them, and thinks that they are the number of failed tests. So we need to strip out all color codes prior to pexpect seeing the output. That's the perl one-liner in the script.

@bgschiller
bgschiller / hangman.py
Created February 27, 2018 03:56
hangman game made on 2018-02-26 at DPL
from __future__ import print_function
try:
input = raw_input
except NameError:
pass
def replace_at(the_word, pos, letter):
"""
produce a new string, just like <the_word>,
except the letter at <pos> has been
@bgschiller
bgschiller / incremental-bg.html
Last active September 22, 2017 17:01
replace background image when fully loaded.
<style>
body {
width: 100%;
background-repeat: no-repeat;
background-position: 50% 21%;
background-size: cover;
background-image:
/* This larger image will show up on top of the black and white, once it's loaded. */
url(https://s.cdpn.io/23379/photo-sedona_1024x640@2x.jpg),
/* Use this low-res, black and white image at first */
import image
import sys
import random
def randGauss():
"""
it would be better to use random.normalvariate(), but it looks like the
textbook version of python doesn't include that function :(
"""
return (
def pos_or_neg(value):
if value > 0:
print("positive")
elif value < 0:
print("negative")
print("expecting positive... ", end='')
pos_or_neg(3)
print("expecting negative... ", end='')
pos_or_neg(-8)