Skip to content

Instantly share code, notes, and snippets.

@danbernier
danbernier / gist:1231073
Created September 21, 2011 02:38
Markdown insists my String is an Array
# @paragraphs is an Array of Strings - various puts'es confirm this.
@paragraphs.each do |paragraph|
renderer = HH::LessonParaRenderer.new(container)
markdown = Redcarpet::Markdown.new(renderer)
p paragraph # Just checking - it's a String!
# raises: <TypeError: wrong argument type Array (expected String)>
markdown.render(paragraph)
end
@danbernier
danbernier / gist:1579738
Created January 8, 2012 21:20
Ruby lets you add instance variables at runtime
ruby-1.9.2-p290 :001 > class Foo
ruby-1.9.2-p290 :002?> def bonk
ruby-1.9.2-p290 :003?> @bonk = nil
ruby-1.9.2-p290 :004?> end
ruby-1.9.2-p290 :005?> end
=> nil
ruby-1.9.2-p290 :006 > f = Foo.new
=> #<Foo:0x007ff15c1e65b8>
ruby-1.9.2-p290 :007 > f.bonk
=> nil
@danbernier
danbernier / framework.js
Created November 4, 2015 19:27
A Tiny Framework for Automated Tests in Google Apps Script
function allTests(thisFnWrapsAllYourTests) {
var successes = 0;
var failures = [];
var scopes = [];
var msgInScope = function(msg) {
return scopes.concat([msg]).join(": ");
}
var doTheseListsMatch = function(expected, actual) {
import peasy.*;
PeasyCam camera;
PVector[] spherePos;
void setup() {
size(800, 600, P3D);
camera = new PeasyCam(this, 0,0,0, 200);
setUpSpheres();
}
@Marsgames
Marsgames / 01_DrawableDictionaries.MD
Last active May 10, 2024 00:02
Unity scripts to show dictionaries in the inspector

Dictionaries shown in inspector

Render


  • Put DictionaryDrawer.cs into your Assets/Editor folder

  • Put SerializableDictionary.cs into your Scripts folder

  • Create a custom dictionary

[Serializable] public class CustomDictionary : SerializableDictionary { } 

Ten to Zen

  1. Let go of comparing.
  2. Let go of competing.
  3. Let go of judgments.
  4. Let go of anger.
  5. Let go of regrets.
  6. Let go of worrying.
  7. Let go of blame.
  8. Let go of guilt.
From e11b753cdbe8a1e911750679bec065c0efac6c7f Mon Sep 17 00:00:00 2001
From: Devin Weaver <suki@tritarget.org>
Date: Tue, 13 Oct 2015 12:51:48 -0400
Subject: [PATCH] Add documentation for README_mac.txt
This is long over due. I realize that the Mac versions of things have
moved to MacVim and most people install via Homebrew without giving
second thought to the actual Vim source. However, I tend to jump to
README_mac.txt when I clone the Vim source. Every time I do a small
little kitten in Suburbia Ville cries uncontrollably. I can't be the
#!/usr/bin/env node
var Writable = require('stream').Writable;
var Util = require('util');
function FloorCounter() {
Writable.call(this);
this.floor = 0;
this.position = 0;
this.enteredBasementAt = null;
// $ node so_example.js 2000000000 > /dev/null
// FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
// Aborted (core dumped)
var util = require('util');
var stream = require('stream');
var crypto = require('crypto');
util.inherits(PasscodeGenerator, stream.Readable);
util.inherits(Hasher, stream.Transform);
function findLongestWord(str) {
return Math.max(...str.split(' ').map(val => val.length));
}
findLongestWord('The quick brown fox jumped over the lazy dog');