Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
#------------------------------------------------------------------------------
# Aggregate Print useful information from /proc/[pid]/smaps
#
# pss - Roughly the amount of memory that is "really" being used by the pid
# swap - Amount of swap this process is currently using
#
# Reference:
# http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt#361
@shu0115
shu0115 / file0.txt
Created February 27, 2013 11:02
Rails4.0.0.beta1 + ActionController::Live + JavaScript EventSource ref: http://qiita.com/items/9369360774edfcc3c13c
require 'reloader/sse'
class ProgressController < ApplicationController
include ActionController::Live
def index
# SSE expects the `text/event-stream` content type
response.headers['Content-Type'] = 'text/event-stream'
sse = Reloader::SSE.new(response.stream)
@elutz
elutz / controller.js
Created November 27, 2012 08:56
File Upload with AngularJS & File-Upload jQuery Plugin
function AttachmentCtrl($scope, $location, $timeout, Docs) {
$(function() {
$('#detail-form-doc').fileupload({
dataType: 'json',
url: '/angular-ib/app/fileupload?id=' + $location.search().id,
add: function(e, data) {
$scope.$apply(function(scope) {
// Turn the FileList object into an Array
for (var i = 0; i < data.files.length; i++) {
$scope.project.files.push(data.files[i]);
  1. Install XCode

  2. Install Command Line Tools from XCode Preferences

  3. Install Homebrew

  4. Install rvm or rbenv

  5. Install Matterhorn dependencies within Homebrew

@pmanijak
pmanijak / index.html
Created September 2, 2012 06:42
Service example with AngularJS for sharing scope data between controllers
<!doctype html>
<html ng-app="project">
<head>
<title>Angular: Service example</title>
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<script>
var projectModule = angular.module('project',[]);
projectModule.factory('theService', function() {
return {
@dre1080
dre1080 / varbinary_migration_columns_initializer.rb
Created August 24, 2012 14:18
Setup varbinary columns or any other unsupported data type in rails migrations
# Provide varbinary columns in a Migration.
# Probably a better way to do this?
#
# Usage:
# => t.varbinary :column, :limit => 20, ....[options]
#
ActiveRecord::ConnectionAdapters::SchemaStatements.module_eval do
def type_to_sql_with_varbinary(type, limit = nil, precision = nil, scale = nil)
return type_to_sql_without_varbinary(type, limit, precision, scale) unless :varbinary == type.to_sym
@ryanlecompte
ryanlecompte / gist:3281509
Created August 7, 2012 04:16
ActiveRecord memory leak with multiple threads?
# It appears that when I perform a query with AR via multiple threads,
# the instantiated objects do not get released when a GC is performed.
threads = Array.new(5) { Thread.new { Foo.where(:status => 2).all.first(100).each { |f| f.owner.first_name } } }
threads.each(&:join)
threads = nil
GC.start
ObjectSpace.each_object(Foo).count # => instances still exist
upstream myapp {
server unix:///myapp/tmp/puma.sock;
}
server {
listen 80;
server_name myapp.com;
# ~2 seconds is often enough for most folks to parse HTML/CSS and
# retrieve needed images/icons/frames, connections are cheap in
@bemasher
bemasher / intput.txt
Created July 10, 2012 12:51
Named Binary Tag parser written in Golang using reflection to populate native types.
// This is the structure of the binary nbt file
TAG_Compound('Level') {
TAG_Compound('nested compound test') {
TAG_Compound('egg') {
TAG_String('name'): 'Eggbert'
TAG_Float('value'): 0.5
}
TAG_Compound('ham') {
TAG_String('name'): 'Hampus'
TAG_Float('value'): 0.75
@amejiarosario
amejiarosario / rails_migration_cheatsheet.md
Created June 18, 2012 21:40
Rails Migration - Cheatsheet