Skip to content

Instantly share code, notes, and snippets.

View danker's full-sized avatar

Eric Danker danker

  • Breo Media LLC
  • St. Louis
View GitHub Profile
// Required jars (I know, I know...I should investigate Grape)
// nekohtml.jar
// xercesimpl.jar
// Define the pages which contain links to products - our "seeds" in crawl parlance.
def seeds = ["http://www.foodnetwork.com/shows/guys-diners-drive-ins-and-dives/index.html"]
// Load the NekoHTML parser with Xerces - this lets us parse the HTML.
slurper = new XmlSlurper(new org.cyberneko.html.parsers.SAXParser())
100.times {
displayNum = ++it
def matched = false
if ((displayNum % 3) == 0) {
print "FIZZ"
matched = true
}
(1..100).each { num ->
out = ((num % 3) == 0) ? 'Fizz' : ''
if ((num % 5) == 0) out += 'Buzz'
if (out.length() == 0) out = num
println out
}
#include <stdio.h>
/*
* If you pay $4.00 for a latte that costs
* $3.10, how much change do you get?
*/
int main() {
long change = 400 - 310;
printf("change = $%ld.%02ld\n", change/100, change%100);
return 0;
@danker
danker / commonPrefix.groovy
Created November 23, 2010 04:23
Find common prefix given a list of words
//PROBLEM: Find the common prefix for all input words (i.e. "aa" for the list given below)
def words = ['aaaaaee', 'aaabck', 'aajj', 'aaaabbbcccc']
def letterIdx = 0
def shouldContinue = true
def commonPrefix = new StringBuffer()
while (shouldContinue) {
@danker
danker / twilio_sms.groovy
Created June 28, 2015 00:11
Groovy script to send an SMS via Twilio API
import org.apache.http.auth.AuthScope
import org.apache.http.auth.UsernamePasswordCredentials
import org.apache.http.client.CredentialsProvider
import org.apache.http.client.HttpClient
import org.apache.http.client.entity.UrlEncodedFormEntity
import org.apache.http.client.methods.CloseableHttpResponse
import org.apache.http.client.methods.HttpPost
import org.apache.http.impl.client.BasicCredentialsProvider
import org.apache.http.impl.client.HttpClientBuilder
import org.apache.http.message.BasicNameValuePair
@danker
danker / naLCSRankings.py
Created July 11, 2015 18:17
Scrape the LoL eSports site to get current NA LCS Rankings. (A simple script to test web-scraping in Python)
import requests
from bs4 import BeautifulSoup
import time
url_to_scrape = 'http://na.lolesports.com/na-lcs/2015/summer/standings'
r = requests.get(url_to_scrape)
# parse the text of the URL
soup = BeautifulSoup(r.text, "html.parser")
@danker
danker / conwayGoL.go
Created July 12, 2015 20:01
Conway's Game of Life in Go.
package main
import (
"fmt"
"math/rand"
"time"
"github.com/nsf/termbox-go"
)
@danker
danker / lol-recent-games.groovy
Created August 2, 2015 03:59
Groovy script that will pull stats on recent games for the specified SummonerID.
import groovyx.net.http.RESTClient
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1' )
def API_KEY = "INSERT-API-KEY-HERE"
def SUMMONER_ID = "28450305"
// FULL DOCUMENTATION AT: https://developer.riotgames.com/api/methods
def client = new RESTClient('https://na.api.pvp.net')
def RECENT_GAMES_PATH = "/api/lol/na/v1.3/game/by-summoner/" + SUMMONER_ID + "/recent"
@danker
danker / The Technical Interview Cheat Sheet.md
Last active August 27, 2015 02:04 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.