Skip to content

Instantly share code, notes, and snippets.

Avatar
🆒
Animal rock band 🎺🐬 🎤🦕 🦉🎸 🎷🐉

Pablo Meier pablo-meier

🆒
Animal rock band 🎺🐬 🎤🦕 🦉🎸 🎷🐉
View GitHub Profile
@pablo-meier
pablo-meier / powerset.js
Created Aug 5, 2017
JS powerset, got bored
View powerset.js
function powerset(input) {
let accum = [];
// This loop which index in the array you begin pulling from
for (let start = 0; start < input.length; ++start) {
// This loop determines *how many* elements to add to your accumulator
for (let baseLength = 1; start + baseLength <= input.length; ++baseLength) {
const base = input.slice(start, start + baseLength);
accum.push(base);
}
@pablo-meier
pablo-meier / md-cleaner.rkt
Created Aug 31, 2013
Considering a move to Frog (https://github.com/greghendershott/frog), and my old Octopress blog has markdown from Jekyll's Blogger migration tool and whatever Jekyll uses. This cleans up the metadata to Frog style.
View md-cleaner.rkt
#lang racket
;; Reads the first few lines of a Markdown file. If it begins with Jekyll metadata
;; (i.e. ---\nTitle:...\n---) then we parse it, re-write it to Frog metadata, then
;; re-write the file.
;; Stores date/title. We ignore all other tags (categories, comments, etc.)
(struct metadata (title bad-date good-date))
View push_wrapper.rb
#!/usr/bin/ruby
FILENAME = "this_many_pushes.txt"
PUSH_IT_DIR = "/Users/pmeier/Desktop/projects/push_it"
command = "git push "
ARGV.each { |x| command += x + " " }
puts command
success = system(command)
View poker.prolog
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Top Level
main(Num_Wins) :-
open(hands, read, Fb),
read(Fb, ListOfHands),
play(ListOfHands, Num_Wins).
play([],0).
play([[Hand1,Hand2]|Rst], Num_Wins) :-
View layton.prolog
%% A question is a [[question number,answer], correctness].
%% Example:
%% [[1,a], correct]
%% A test is a list of questions.
%% We create a rule that every correct answer is 10 points.
points([_, correct], 10). points([_, incorrect], 0).
%% Create rules flip solutions and whether or not they are incorrect.
You can’t perform that action at this time.