Skip to content

Instantly share code, notes, and snippets.

@christophermanning
christophermanning / README.md
Last active August 29, 2015 14:02
Rails ActiveRecord 4.1.2.rc2 Namespaced HABTM Regression
~  ruby habtm.rb
Active Record 4.1.1
-- create_table(:articles, {:force=>true})
   -> 0.3158s
-- create_table(:publisher_magazines, {:force=>true})
   -> 0.0005s
-- create_table(:articles_publisher_magazines, {:force=>true})
   -> 0.0005s
#<ActiveRecord::Associations::CollectionProxy [#<Article id: 1>]>
@christophermanning
christophermanning / PHP 5.3 strlen.patch
Last active September 27, 2015 07:37
PHP 5.3 strlen
@@ -303,13 +300,14 @@
Get string length */
ZEND_NAMED_FUNCTION(zend_if_strlen)
{
- zval **str;
+ char *s1;
+ int s1_len;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
@christophermanning
christophermanning / README.md
Last active September 29, 2015 18:57
Extract JSON from ChicagoLobbyists

Rudimentary method of extracting JSON data from the ChicagoLobbyists sinatra app for a force directed graph

@christophermanning
christophermanning / README.md
Created October 1, 2012 03:20 — forked from mbostock/.block
General Update Pattern, III

By adding transitions, we can more easily follow the elements as they are entered, updated and exited. Separate transitions are defined for each of the three states.

Note that no transition is applied to the merged enter + update selection; this is because it would supersede the transition already scheduled on entering and updating elements. It's possible to schedule concurrent elements by using transition.transition or by setting transition.id, but it's simpler here to only transition the x-position on update; for entering elements, the x-position is assigned statically.

Want to read more? Try these tutorials:

@christophermanning
christophermanning / README.md
Created December 10, 2012 07:10
Technology Delaunay Triangulation
@christophermanning
christophermanning / README.md
Created December 11, 2012 04:11
Sierpinski Chaos Game
@christophermanning
christophermanning / README.md
Last active October 14, 2015 01:17
Force-Directed Sierpinski Triangle

Created by Christopher Manning

Summary

This generates a Sierpinski Triangle graph using a force-directed layout.

Controls

  • Use the mousewheel to increase or decrease the iterations.
@christophermanning
christophermanning / README.md
Last active December 9, 2015 19:18
Simplex Noise Dots

Created by Christopher Manning

Controls

  • Drag left and right to adjust the width of the noise
  • Drag up and down to adjust the height of the noise
  • Use the mousewheel to increase or decrease the amplitude.

References