Skip to content

Instantly share code, notes, and snippets.

@muddydixon
muddydixon / tco.js
Created October 22, 2011 14:10
Node t.co expander
/*****
* TCO expander
* tweet中のt.coが展開できない、って言われて作ってから試して見てたら、
* tweetオブジェクトの中にtweet.entities.urlsってあって、そんなかに入ってたのでいらなかった。
* なんかの役に立つかもと思い残しておくことにした。
*****/
/*****
* USAGE:
* var tco = require('./tco.js');
@muddydixon
muddydixon / deck.core.css
Created November 15, 2011 06:04
deck hatenablog
html {
height: 100%;
}
.deck-container {
position: relative;
height: 100%;
width: 70%;
margin: 0 auto;
padding: 0 48px;
@muddydixon
muddydixon / server.js
Created May 31, 2012 05:03
node server connect >= 1.8.3
var fs = require('fs')
, path = require('path')
if(process.argv[2] === '--help' || process.argv[2] === '-h'){
console.log('USAGE: node ./server.js <public dir: default public> <port: default 3010>');
process.exit(0);
}
var public = process.argv[2]
, port = process.argv[3];
#!/usr/bin/env node
var num = process.argv[2] || 5
, maxLen = 20
, ratio = 0.5
, hasNext = false
, l = 0
, u = 0;
var stdout = process.stdout;
@muddydixon
muddydixon / mongo.js
Created July 20, 2012 01:29
MongoDB にいっぱいcollection作ってみる
> for(var i = 0; i < 50000; i++){ db['col'+i].insert({name: 1}) }
too many namespaces/collections
> db.col20000.find()
>
..
> db.col12988.find()
>
> db.col12987.find()
{ "_id" : ObjectId("500823a6c7e72154412d4788"), "name" : 1 }
var spawn = require('child_process').spawn
, run = function(cmd, argv, cb) {
var dat, err, proc;
if ((argv != null) && !argv instanceof Array) {
argv = [argv];
}
proc = spawn(cmd, argv);
proc.stdout.setEncoding('utf8');
proc.stderr.setEncoding('utf8');
dat = '';
var spawn = require('child_process').spawn
, run = function(cmd, argv, cb) {
var dat, err, proc;
if ((argv != null) && !argv instanceof Array) {
argv = [argv];
}
proc = spawn(cmd, argv);
proc.stdout.setEncoding('utf8');
proc.stderr.setEncoding('utf8');
dat = '';
@muddydixon
muddydixon / mongo-hadoop.example.java
Created August 29, 2012 02:07
mongo-hadoop multipleInput example
public class MultipleDriver extends Configured implements Tool {
/** Logger */
public static final Log log =
LogFactory.getLog(HadongoDriver.class);
public static void main (String[] args) throws Exception {
log.info("*** start mapreduce ***");
int exitCode = ToolRunner.run(new MultipleDriver(), args);
log.info("**** end mapreduce ****");
System.exit(exitCode);
@muddydixon
muddydixon / httpd-passenger.conf
Created October 13, 2012 23:31
(一般ユーザで)rvmを使って色々インストールした状態で、(_wwwユーザで)apache2 => passengerを使うとき
SetEnv GEM_HOME /Users/muddydixon/.rvm/gems/ruby-1.9.3-p286@global
SetEnv GEM_PATH /Users/muddydixon/.rvm/gems/ruby-1.9.3-p286@global
LoadModule passenger_module /Users/muddydixon/.rvm/gems/ruby-1.9.3-p286@global/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /Users/muddydixon/.rvm/gems/ruby-1.9.3-p286@global/gems/passenger-3.0.17
PassengerRuby /Users/muddydixon/.rvm/rubies/ruby-1.9.3-p286/bin/ruby
RailsBaseURI /redmine
@muddydixon
muddydixon / d3.v2.min.js
Created November 15, 2012 16:02
hatena blog presentation
(function(){function e(e,t){try{for(var n in t)Object.defineProperty(e.prototype,n,{value:t[n],enumerable:!1})}catch(r){e.prototype=t}}function t(e){var t=-1,n=e.length,r=[];while(++t<n)r.push(e[t]);return r}function n(e){return Array.prototype.slice.call(e)}function r(){}function i(e){return e}function s(){return this}function o(){return!0}function u(e){return typeof e=="function"?e:function(){return e}}function a(e,t,n){return function(){var r=n.apply(t,arguments);return arguments.length?e:r}}function f(e){return e!=null&&!isNaN(e)}function l(e){return e.length}function c(e){return e==null}function h(e){return e.trim().replace(/\s+/g," ")}function p(e){var t=1;while(e*t%1)t*=10;return t}function d(){}function v(e){function t(){var t=n,r=-1,i=t.length,s;while(++r<i)(s=t[r].on)&&s.apply(this,arguments);return e}var n=[],i=new r;return t.on=function(t,r){var s=i.get(t),o;return arguments.length<2?s&&s.on:(s&&(s.on=null,n=n.slice(0,o=n.indexOf(s)).concat(n.slice(o+1)),i.remove(t)),r&&n.push(i.set(t,{on:r})),e)}