Skip to content

Instantly share code, notes, and snippets.

Avatar
⛰️

Scott Ogle scogle

⛰️
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am scogle on github.
  • I am scogle (https://keybase.io/scogle) on keybase.
  • I have a public key ASAfTq4ALa6ESoiOZDCzeK-nlJkr2ja3Q1REx8AY8puEJQo

To claim this, I am signing this object:

View csv.py
import csv
with open('myfile.csv', 'r') as csv_file:
csv_reader = csv.readlines(csv_file)
"""
can now iterate through the file, like:
for line in csv_reader:
# do something
View LRUCache.py
class Node():
def __init__(self, key, value, next=None, prev=None):
self.key = key
self.value = value
self.next = next
self.prev = prev
def __str__(self):
return '<{}:{}>'.format(self.key, self.value)
View flattener.py
import unittest
def flatten(arr):
""" Write some code, that will flatten an array of arbitrarily nested arrays
of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
"""
flattened_arr = []
def recur(el):
if type(el) == list:
for e in el:
@scogle
scogle / ultrawrap-error
Created May 27, 2015
Getting this error when running ultrawrap-compile
View ultrawrap-error
java.lang.RuntimeException: java.io.FileNotFoundException: 'W3CDirectMappingRules.drl' cannot be opened because it does not exist
at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:559)
at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at edu.utexas.cs.ultrawrap.compile.rules.DirectMappingEngine.readKnowledgeBase(DirectMappingEngine.java:140)
at edu.utexas.cs.ultrawrap.compile.rules.DirectMappingEngine.run(DirectMappingEngine.java:54)
at edu.utexas.cs.ultrawrap.compile.UltrawrapCompile.runDirectMapping(UltrawrapCompile.java:143)
at edu.utexas.cs.ultrawrap.compile.UltrawrapCompile.createPutativeOntology(UltrawrapCompile.java:113)
at edu.utexas.cs.ultrawrap.compile.CompileMain.main(CompileMain.java:290)
Caused by: java.io.FileNotFoundException: 'W3CDirectMappingRules.drl' cannot be opened because it does not exist
at org.drools.io.impl.ClassPathResource.getInputStream(ClassPathResource.java:104)
View SieveOfEratosthenes
def sieve(limit):
# Start by generating a list of bools with all even indexes flagged as not prime
# This substitutes the index in a list for actual numbers with a boolean
# flag indicating primality instead of actually maintaining the int in memory
# (since bools are much cheaper)
start = [False if i % 2 == 0 else True for i in range(limit)]
# Make sure to set 0 and 1 as not prime
start[0] = start[1] = False
for (i, isprime) in enumerate(start):
# If it's prime, yield it and set its multiples to false, else move on
@scogle
scogle / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View brag.txt
Smells like Self Help
Scott Ogle
Brag, by Peggy Klaus, carries the distinct scent of self help, that laudable genre that has endorsed everything from outsourcing your own job to India, as in Tim Ferris’s Four Hour Work Week, to making realizing your dreams through nothing more than wanting them really, really bad, as in Rhonda Byrne’s The Secret (I am terrified of the judgment I might have drawn on myself if anyone ever sees that I searched for that).
Yes, I am making a straw man argument, but I don’t think it’s entirely without merit. I’m unconvinced by her examples that seem to demonstrate unpleasable management more than stellar interviewing skills. In one anecdote the interviewer asks the candidate to suggest some potential funding sources. When she comes up with several sources from which the organization actually does get funding, they scoff at her inability to be one step ahead of them.
I can’t quite make sense of this situation, at least not what it’s doing in a book like this. One scenario is
@scogle
scogle / gist.txt
Created Oct 31, 2014
example gist
View gist.txt
some example gist
@scogle
scogle / icicle.js
Created Oct 17, 2014
Creating visualizations is trivial
View icicle.js
new d3z.Icicle({
root: root,
width: 2400,
container: "#body"
});