Skip to content

Instantly share code, notes, and snippets.

View linstantnoodles's full-sized avatar
🎯
Focusing

Alan L. linstantnoodles

🎯
Focusing
View GitHub Profile
@linstantnoodles
linstantnoodles / ebert_amazon.py
Last active July 5, 2020 19:31
Get amazon prime information on Roger Ebert Great Movies
import requests
import csv
import os
import json
import re
from bs4 import BeautifulSoup
import mechanize
from random import choice
user_agents = ['Mozilla/5.0 (X11; U; Linux; i686; en-US; rv:1.6) Gecko Debian/1.6-7','Konqueror/3.0-rc4; (Konqueror/3.0-rc4; i686 Linux;;datecode)','Opera/9.52 (X11; Linux i686; U; en)']
random_user_agent = choice(user_agents)
(define (crackle-pop)
(define (divisible a b)
(= (mod a b) 0))
(define (crackle-popper a b)
(if (<= a b) (crackle-popper (+ a 1) b
(cond
((and (divisible a 3) (divisible a 5)) (display "CracklePop") (newline))
((divisible a 3) (display "Crackle") (newline))
((divisible a 5) (display "Pop") (newline))
))))
(function (window, undefined) {
var directiveFactories = {};
/**
* @description Register directive factory functions
*
* @param {String} name Name of the directive
* @param {Function} factory The factory function
*/
function ArrayAdditionI(arr) {
var valMap = {}; // Cache sums
arr.sort(function(a,b) { return a - b;});
var largestNum = arr.pop();
for (var i = 0; i < arr.length; i++) {
var combos = Object.keys(valMap);
for (var j = 0; j < combos.length; j++) {
var newCombo = arr[i] + (+combos[j]);
if (newCombo === largestNum) return "true";
@linstantnoodles
linstantnoodles / gist:5193227
Created March 19, 2013 02:21
hanoi recursive
function move(n, f, d, t) {
if (n > 0) {
move(n - 1, f, t, d);
d.push(f.pop());
move(n - 1, t, d, f);
}
}
public static int findElement(int[] a, int l, int r, int x){
int m = (l+r)/2;
int t = -1;
if(x == a[m]) return m;
if(l < r){
if(a[l] == a[m]){
if(x == a[l])
t = l;
public static final int STR_SIZE(int n) {
float bytesPerChar = Charset.defaultCharset().newEncoder().maxBytesPerChar();
return ((n+1) * (int)bytesPerChar); //1 xtra null char
}
public synchronized String getString(int offset) {
contents.position(offset);
String new_str = "";
while(true){
char a = contents.getChar();
if(a == '\0') break;
new_str += a;
}
return new_str;
}
@linstantnoodles
linstantnoodles / namer.ml
Last active April 24, 2017 12:15
ocaml type checker
(* Name: Alan Lin
Assignment: Problem Set 6 -> Namer
*)
module Namer =
struct
type typ = IntType | BoolType
type value = BoolValue of int | IntValue of int
type ast = Const of int * typ
| App of string * ast list
let rec sublists a = match a with
[] -> [[]]
|first::rest -> let b = sublists rest in
let c = List.map (fun g -> first::g) b in
c @ b;;
(*
val sublists : 'a list -> 'a list list = <fun>
# let a = [1;2;3];;
val a : int list = [1; 2; 3]