Skip to content

Instantly share code, notes, and snippets.

View huned's full-sized avatar
💭
I may be slow to respond.

Huned Botee huned

💭
I may be slow to respond.
View GitHub Profile
@huned
huned / biggest_image.js
Created May 7, 2013 19:25
get the biggest image on a page with a reasonable aspect ratio with javascript
var biggestImage = function() {
biggest = null;
images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
var image = images[i];
var area = image.width * image.height;
var ratio = image.width / image.height;
if(!biggest || (area > 1 && area > (biggest.width * biggest.height) && ((ratio > 1 && ratio < 2) || (1/ratio > 1 && 1/ratio < 2))))
{
biggest = image;
## import sample BOM (use db/BOMs/2/*.csv for a big BOM)
$ time bin/rails runner "BomNode.import_csv 'db/BOMs/2/parts.csv'"
NOTICE: index "bom_nodes_index" does not exist, skipping
real 5m44.958s
user 5m13.760s
sys 0m2.562s
$ time bin/rails runner "BomEdge.import_csv 'db/BOMs/2/bom.csv'"
ssh-dss AAAAB3NzaC1kc3MAAACBAIE9R4sFArK2lrn0l0MLRFxn0ExUMIH/4VPg2gQxE9a1KwTr9nbQpL6H+mxxZLNm9+iKZeKrx+PEqNH6SmhYx0LUQ7FqaYhy89Leoy5uUW87CSd9x7KuxBChK9vvqyf8X7b2mGzWgs5XRzSiLHngn8XGHxVgXQoS1K/w7M+c4I2nAAAAFQDEhsSJQOzio1v8Jiy5ypALwxnaswAAAIB7STNNhWdkb7SeHs0zEEkwgs0nExzBFAZ3WAmZZnb8m9HWTLbwZpGGPRfcWi0cthHIwfzATvzUwEZuzjmeqhS9J7UxSaPOpzg4mTSQFvj6ZHzTg+ZwhNIRAOOaXV2lopq9KChV+ZSjtmZQDs6Js0oJEAuw5DCktKTnkZ1Kf8hsfQAAAIBattEuuohpFnTY5VM8B7mMVib1y1jQ0yPa+sORBFqzdGeJxoPZJvGXhO5L90KW20VtLGRbrrkdrZ75/7Cy1mISe6+Of7WBaZniL+kxUN4+hwuw/2aWjgOUstEhFOf3rilinMc/wBtCjpe5GLLEbDTGLAlZbS0/GwS+hh1GLKfdmg== huned@omg
diff --git a/views/layout.hbs b/views/layout.hbs
index 8b75b6c..17cd328 100644
--- a/views/layout.hbs
+++ b/views/layout.hbs
@@ -19,9 +19,9 @@
<title>Delicious</title>
<link rel="shortcut icon" href="/img/favicon.ico" />
- <link rel="stylesheet" type="text/css" href="/css/app.css">
+ <link rel="stylesheet" type="text/css" href="/css/app.css?1359583814667">
commit 180369cbdf4dca0bd9c584bb6ed5c8fe112c2908
Author: Huned Botee <huned@734m.com>
Date: Thu Oct 4 13:48:10 2012 -0700
fix usage of Links#initialize in UsersController
diff --git a/src/avos/static/beta/app/controllers/users_controller.coffee b/src/avos/static/beta/app/controllers/users_controller.coffee
index 769e10c..b9eb9b6 100644
--- a/src/avos/static/beta/app/controllers/users_controller.coffee
+++ b/src/avos/static/beta/app/controllers/users_controller.coffee
//
// WADateHelper.m
//
//
// Created by Huned Botee on 9/24/12.
//
//
#import "WADateHelper.h"
tor 208 huned 4u IPv4 0xe9e3afd602f1bb01 0t0 TCP localhost:9050 (LISTEN)
redis-ser 209 huned 4u IPv4 0xe9e3afd602f1ac91 0t0 TCP localhost:6379 (LISTEN)
postgres 210 huned 5u IPv6 0xe9e3afd605d87ea9 0t0 TCP localhost:postgresql (LISTEN)
postgres 210 huned 6u IPv4 0xe9e3afd602f1a559 0t0 TCP localhost:postgresql (LISTEN)
postgres 210 huned 7u IPv6 0xe9e3afd605d87ac9 0t0 TCP localhost:postgresql (LISTEN)
mongod 212 huned 6u IPv4 0xe9e3afd60722f971 0t0 TCP localhost:28017 (LISTEN)
mongod 212 huned 7u IPv4 0xe9e3afd60722f239 0t0 TCP localhost:27017 (LISTEN)
memcached 213 huned 18u IPv6 0xe9e3afd605d88669 0t0 TCP localhost:11211 (LISTEN)
memcached 213 huned 19u IPv4 0xe9e3afd602f1b3c9 0t0 TCP localhost:11211 (LISTEN)
memcached 213 huned 20u IPv6 0xe9e3afd605d88289 0t0 TCP localhost:11211 (LISTEN)
@huned
huned / downsample.js.coffee
Created September 13, 2012 17:30
A naive downsampling implementation because I simply have too much data.
# A naive downsample implementation.
#
# arguments:
#
# * `data`: the array of data you want to sample
# * `sampleLength`: the number of samples you want
#
# returns a two element array, where the 1st
# element, k, is the sampling period (ie, sample
# every kth element) and the 2nd element is an
>> Timecop.freeze Time.parse('January 1, 2012')
=> 2012-01-01 00:00:00 -0800
>> Time.parse('January 1, 2011').to_s(:activity)
=> "January 2011"
>> Time.parse('February 1, 2011').to_s(:activity)
=> "February 2011"
>> Time.parse('March 1, 2011').to_s(:activity)
=> "March"
>> Time.parse('January 1, 2012').to_s(:activity)
=> "Today"
>> Time.parse('August 1 2012').to_s :activity
=> "Wednesday"
>> Time.parse('July 1 2012').to_s :activity
=> "Last Month"
>> Time.parse('June 1 2012').to_s :activity
=> "June"
>> Time.parse('December 1 2011').to_s :activity
=> "December"
>> Time.parse('October 1 2011').to_s :activity
=> "October 2011"