Skip to content

Instantly share code, notes, and snippets.

View scogle's full-sized avatar
⛰️

Scott Ogle scogle

⛰️
View GitHub Profile

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:

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
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)
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:
Scott Ogle
Mount Remington
We climb the stairs like Miyazaki kites
I am immune to harm and goddamn, it’s a miracle
Wearing gasoline cologne,
Minor chords rattle between our ears,
Deep and dark and blue
I can taste the
try:
if line[20]:
geo = geocode(line[20])
f.write( '\tbldg:siteAddress "%s"^^xsd:string ;\n' % line[20] )
f.write( '\tbldg:siteLocationLat "%s"^^xsd:decimal ;\n' % geo['lat'] )
f.write( '\tbldg:siteLocationLong "%s"^^xsd:decimal ;\n' % geo['lng'] )
f.write( '\twgs84_pos:lat "%s"^^xsd:decimal ;\n' % geo['lat'] )
f.write( '\twgs84_pos:long "%s"^^xsd:decimal ;\n' % geo['lng'] )
except:
pass
@scogle
scogle / ultrawrap-error
Created May 27, 2015 23:01
Getting this error when running ultrawrap-compile
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)
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 August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
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