Skip to content

Instantly share code, notes, and snippets.

View profh's full-sized avatar

Larry Heimann (Prof. H) profh

  • Carnegie Mellon University
  • Pittsburgh, PA
  • X @profh
View GitHub Profile
@profh
profh / pats_311.sql
Created June 18, 2013 14:35
PG dump from pats_311
This file has been truncated, but you can view the full file.
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
@profh
profh / decode_session_cookie.rb
Last active June 23, 2021 13:25
A simple script to decode Rails 4 session cookies
@profh
profh / PATS_MongoDB_v3.js
Created November 12, 2014 17:51
PATS_MongoDB_setup
//OWNERS COLLECTION – PATS_mongo
// To be safe, drop any prior collections
db.owners.drop();
db.pets.drop();
// set up some owners
var doc1 = {
"name": {"first": "Ed", "last": "Gruberman"},
"street": "1600 Bigelow Blvd",
@profh
profh / Contents.swift
Last active November 2, 2015 19:29
67442_Midterm_Playground (Contents)
//: Possible solutions to parts 1 & 2 of the 67-442 midterm (2015)
import UIKit
// PART 1: Closures
var characterFirstAppearance = ["obi-wan": "ANH",
"yoda": "ESB",
"luke": "ANH",
"windu": "TPM",
@profh
profh / wall_template.rb
Created March 17, 2016 01:47
Coding template for the 99 Bottles of Beer exercise in class
# Classic OOP exercise, done in Ruby
class Wall
# Set up the wall with a set of bottles. The default
# number of bottles is 99
def initialize( )
end
@profh
profh / transaction_examples.sql
Last active March 21, 2016 01:34
67-272 Examples of Database Transactions
-- Using Prof. H's superhero_transact database
-- the pg_dump file for this database at: https://gist.github.com/profh/a243685482ac0d8f3244
SELECT * FROM heroes;
BEGIN;
UPDATE heroes SET name = 'The Tickster' WHERE hero_id = 14;
SELECT * FROM heroes;
UPDATE heroes SET age = 42;
-- foo! I did't mean to change age of everyone to 42...
@profh
profh / superhero_transact.sql
Created March 21, 2016 01:33
pg_dump for superhero_transact database
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
@profh
profh / book_manager_example.ex
Created June 8, 2016 15:33
Using iex with BookManager app
### Stepping through class example on BookManager
# Import Ecto.Query first, or none of this works in iex:
import Ecto.Query
# A simple example
query = from BookManager.Book
BookManager.Repo.all(query)
# Creating aliases because BookManager is just to long to keep rewriting:
@profh
profh / symbols.rb
Created February 8, 2018 02:16
Understanding Ruby Symbols
# Simple method format purposes
def brk
puts "============================"
end
# Finding all symbols and symbol methods that Ruby already knows:
symbols = Symbol.all_symbols.sort{|x,y| x.to_s <=> y.to_s }
symbols.each { |x| print x.to_s + "\t" }
brk
<!DOCTYPE html>
<html>
<head>
<title>Vue.js Demos</title>
<script type="text/javascript" src="https://unpkg.com/vue@2.5.9/dist/vue.js"></script>