Skip to content

Instantly share code, notes, and snippets.

@baileyparker
baileyparker / BankAcct.js
Created October 4, 2015 22:46
OO Javascript Example
var BankAcct = (function() {
// The BankAcct function will execute when it is new'ed,
// so this.name and this.balance will be set
function BankAcct(name) {
this.name = name;
this.balance = 100; // starting money
}
// These functions will be available on any new BankAcct() objects
BankAcct.prototype.changeName = function(newName) {
@baileyparker
baileyparker / README.md
Last active February 10, 2016 03:39
OCaml doctest-ish script

Doctest-ish for Ocaml

Useful for asserting test cases for EN.600.426 without all that copy 'n paste and visual comparing.

The code is admittedly sloppy and makes some fragile assumptions. It errors very easily and can't assert exceptions. It expects doctests of the form:

(*
# foo param another_one and_another_one;;
- : bytes list = ["major"; "key"]

*)

import Ember from 'ember';
export default Ember.Component.extend({
actions: {
scroll: function(e) {
this.set('text', this.get('text') + ' scroll!');
},
scroll: function(e) {
this.set('text2', this.get('text2') + ' scroll!');
},
@baileyparker
baileyparker / components.test-textarea.js
Last active July 20, 2017 03:48
Two Way Bound Textarea
import Ember from 'ember';
export default Ember.Component.extend({
value: '',
actions: {
input: function(e) {
let value = e.target.value,
filteredValue = value.toUpperCase().replace(/[\r\n\v]/g, '');
console.log('before', value, 'after', filteredValue, 'end');
import Ember from 'ember';
export default Ember.Component.extend({
value: '',
actions: {
onKeydown(e) {
if (e.keyCode === 13) {
// Upon pressing enter, field should clear
console.log('got enter, clearing...');
@baileyparker
baileyparker / persistent_decorator.py
Last active January 25, 2018 18:47
MetaBrainz chatbox voting plugin cleanup for codereview.stackexchange.com
from functools import wraps
from inspect import ismethod
class PersistentDecorator(object):
def __init__(self, decorated_object, save):
self._decorated_object = decorated_object
self._save = save
def __getattribute__(self, attr):
@baileyparker
baileyparker / keybase.md
Created February 3, 2018 14:34
keybase.md

Keybase proof

I hereby claim:

  • I am baileyparker on github.
  • I am baileyparker (https://keybase.io/baileyparker) on keybase.
  • I have a public key whose fingerprint is 5094 E96D 559C 16C0 DE72 24D8 B732 B033 3C75 32C0

To claim this, I am signing this object:

@baileyparker
baileyparker / LICENSE.md
Last active July 24, 2020 09:32
Calculator parser implemented in Python

MIT License

Copyright (c) 2018 Bailey Parker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@baileyparker
baileyparker / fix-bup-slahes.sh
Created August 3, 2018 20:24
Script that removes slashes from bup backup names
#!/bin/bash
set -e
if [ "$#" -eq "1" ]; then
git_dir="$1"
else
if [ "$#" -eq "0" ]; then
git_dir="~/.bup"
else
@baileyparker
baileyparker / .gitignore
Last active August 17, 2018 06:24
Tests and benchmarks for widest 0-bit gap and de Bruijn vs ffs (https://codereview.stackexchange.com/q/201846/8639)
bin/
catch.hpp
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o