Skip to content

Instantly share code, notes, and snippets.

View Gastove's full-sized avatar

Ross Donaldson Gastove

View GitHub Profile
;; I am trying to parse a nested Java object (a Google Protobuffer), which comes in as raw bytes. To parse the bytes,
;; I have to know the class of the object. Fortunately, for the innermost object, the class is specified as a field in
;; an outer object. The parsing function is specified as a static method on the class, with expected use like:
;; (com.url.place.Type$SubType/parseFrom (.getByteArrayFromInnerObj inner-obj))
;; What I'm trying to do is something like this:
(def decl-obj-map
{:type-subtype Type$SubType})
#!/usr/local/bin/python
#
# Lifted from: https://gist.github.com/ihodes/11505022
# example .ensime generation
# Maven to Ensime config. convertor:
#
# Prints .ensime configuration for Maven project.
#
# USAGE:
# mvn-ensime PROJECT_NAME PROJECT_PACKAGE ROOT_DIR TARGET_DIR SOURCE_DIRS*
@Gastove
Gastove / calavera.jade
Created August 10, 2013 20:07
A Scalate jade template for skeleton.css (www.getskeleton.com). (Probably approximately close to HAML/SCAML, but I haven't tested that as such.)
-# Setting Jade Variables
-@ val title: String = "Default Title WOOOO!"
-@ val body: String = "Default Body WOOOOO!"
!!!
/ [if lt IE 7]
html{:class => "ie ie6", :lang => "en"}
/ [if IE 7]
html{:class => "ie ie7", :lang => "en"}
/ [if IE 8]
@Gastove
Gastove / AndroidPasswordGenerator.scala
Created September 3, 2013 20:24
A friend and I are trying to figure out the optimal way to generate the full set of all possible Android shape passwords. This is my attempt -- permutations, recursions; fairly functional.
import scala.math.abs
object AndroidPasswordGenerator{
def main(args: Array[String]) {
val grid = NodeGrid.generateGrid
val paths = findPath(grid, new EmptyPath)
paths.foreach{println}
}
# Created 2016-03-04 Fri 19:57
#+TITLE: R
#+AUTHOR: Ross Donaldson
* Object Oriented, Functional, and Imperative Programming
Right OK: what are these three things? What do they do and how are they
different?
* Object-orientation
OOP is, as one might expect, oriented around /objects/. An "object" is a piece of
# Created 2016-03-04 Fri 20:20
#+TITLE: R
#+AUTHOR: Ross Donaldson
* Object Oriented, Functional, and Imperative Programming
Right OK: what are these three things? What do they do and how are they
different?

All the src blocks in the file are supposed to inherit the global options specified above ^. Note that if you change a header arg in the property block above, you need to put the cursor on that property line and hit C-c C-c to “refresh configuration”.

For instance, my current working directory is not my home dir, but when I do this, I get the contents of my home dir because of the global :dir flag:

# Created 2016-04-17 Sun 21:14
#+TITLE: SQL
#+AUTHOR: Ross Donaldson
1. Which food is the most liked?
#+BEGIN_SRC sql
SELECT food.name
, COUNT(*) AS love_count
FROM food
LEFT JOIN preferences AS prefs
ON food.id = prefs.food_id

SQL

  1. Which food is the most liked?
SELECT food.name
       , COUNT(*) AS love_count
FROM food
LEFT JOIN  preferences AS prefs
ON food.id = prefs.food_id

Modules

In python, a "module" is a set of related code. We work with modules every time we use import:

import datetime #  <- `datetime` is totally a module