Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

From around my laptop

  • Loading branch information...
commit 6f63c90f2e0d43410dc4048704077c688a4d99b4 1 parent ce02fd2
@benjaminoakes authored
View
15 Code-Hugger.md
@@ -0,0 +1,15 @@
+The Code Hugger Mantra
+======================
+
+Inspired by environmentalists, aka the tree huggers!
+
+The Code Hugger Mantra
+
+ * Reduce: Write concise code. Less is more.
+ * Reuse: Reuse code. Don't copy-paste, don't reinvent. Do use third-party libraries.
+ * Refactor: Your code is a "living document", treat it as such. Neglect shows over time.
+
+This mantra was inspired by the environmentalists (aka "Tree Huggers") movement's Waste Management Hierarchy: "Reduce, reuse, recycle." Remembering The Three R's is a simple way to reinforce strategic goals when you are taking tactical actions.
+
+From: http://lanai.dietpizza.ch/geekomatic/2009/11/05/1257402000000.html
+
View
1  Commands-to-Remember.md
@@ -0,0 +1 @@
+pushd and popd
View
19 Home.md
@@ -3,14 +3,27 @@
* [[DNS]]
* [[Server Uses]]
-## Ruby
+## Programming
+
+* [[Code Hugger]]
+* [[Iterations]]
+
+### Shells
+
+* [[Commands to Remember]]
+
+### Ruby
* [[rvmrc]]
-## Git
+### Git
* [[git flow]]
+### Vim
+
+* [[retab]]
+
## Services
* [[Status Sites]]
@@ -23,4 +36,4 @@
## Misc
-* [[Ideas]]
+* [[Ideas]]
View
81 Iterations.md
@@ -0,0 +1,81 @@
+Problem: we have a list of numbers we want to triple (multiply by 3)
+
+Math:
+
+f(x) = 3x
+
+C:
+
+int i;
+for (i = 0; i < sizeof(a) / sizeof(a[0]); i++) {
+ printf("%d\n", a[i]);
+}
+
+Java:
+
+// traditional
+for (int i = 0; i < array.length; i++) {
+ triple(array[i]);
+}
+
+// iterator
+Iterator<Item> i = collection.iterator();
+while (i.hasNext()) {
+ triple(collection.get(i));
+}
+
+// iterator shorthand
+for (Item item : array) {
+ triple(item);
+}
+
+Perl:
+
+foreach (@array) {
+ triple($_);
+}
+
+PHP:
+
+foreach ($array as $item) {
+ triple($item);
+}
+
+Python:
+
+for item in array:
+ triple(item)
+
+JavaScript:
+
+for (i in array) {
+ triple(array[i]);
+}
+
+// or if your browser/framework has defined it:
+array.each(triple);
+// or
+array.map(triple);
+// among other things...
+
+SML/NJ:
+
+(* There aren't loops in SML/NJ, just recursion. *)
+fun triple [] = []
+ | triple (h :: t) = h * 3 :: triple (t);
+
+Ruby:
+
+for item in array
+ triple(item)
+end
+
+array.each do |item|
+ triple(item)
+end
+
+array.each { |i| triple(i) }
+array.each(&method(:triple))
+
+array.each { |i| i * 3 }
+
View
1  retab.md
@@ -0,0 +1 @@
+Two of Vim’s features really stand out for me: reformatting text and retabbing a document. I love being able to convert a file’s tabs to spaces just by typing :retab. It is much more efficient than having to go through two levels of menus in TextMate. And being able to reformat Python doc strings is very useful. It removes an annoyance that can make updating documentation a real chore.
Please sign in to comment.
Something went wrong with that request. Please try again.