Skip to content

Instantly share code, notes, and snippets.

@lolzballs
lolzballs / HelloWorld.java
Created March 22, 2015 00:21
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@itsthatguy
itsthatguy / foo.coffee
Last active August 29, 2015 14:16
Coffeescript Classes: object.prototype.function and object.function demonstrated
# Run the following command in shell:
# curl -s https://gist.githubusercontent.com/itsthatguy/48d9b47dba05b300c65b/raw/80b1111bb5273697d1db4f5662eb763aa4a80cdc/foo.coffee | coffee --stdio
class Foo
name: 'abott'
@myFunction: ->
console.log "\n# start"
console.log "\nFoo"
console.log "this.name:", this.name
myOtherFunction: ->
console.log "\nfoo (instance of Foo)"
@solnic
solnic / require_measure.rb
Last active August 29, 2015 14:14
A hack to measure how long it takes to require bundled gems in a rails app
REQUIRE_DATA = {}
BUNDLED_GEMS = `bundle show | grep "*" | awk '{print $2}'`.split("\n").sort
require 'bigdecimal'
def require(name)
start = Time.now
ret = super
stop = Time.now
total = BigDecimal(stop-start, 6)
REQUIRE_DATA[name] = total if BUNDLED_GEMS.include?(name)
@claptimes5
claptimes5 / best_in_place.noty.js
Last active December 21, 2017 14:57
Best in place with Noty
// Noty - http://ned.im/noty/#/about
// Best in place - https://github.com/bernat/best_in_place
$(document).on('best_in_place:error', function (event, request, error) {
'use strict';
// Display all error messages from server side validation
$.each(jQuery.parseJSON(request.responseText), function (index, value) {
if (typeof value === "object") {
value = index + " " + value.toString();
}

TIL attr_* methods are optomized.

class Whatever
  def foo
    @foo
  end

  attr_reader :bar
end
class CreateUserForm
include ActiveModel::Model
attr_accessor :email
attr_accessor :name
def initialize
@user = User.new
end
module Publisher
extend self
# delegate to ActiveSupport::Notifications.instrument
def broadcast_event(event_name, payload={})
if block_given?
ActiveSupport::Notifications.instrument(event_name, payload) do
yield
end
else
@somebox
somebox / presenters.md
Last active March 26, 2022 02:12
Thoughts About Rails Presenters

Thoughts about Rails Presenters

This is a collection of links, examples and rants about Presenters/Decorators in Rails.


The "Decorator" pattern slowly started gaining popularity in Rails several years ago. It is not part of core Rails, and there's many different interpretations about how it should work in practice.

Jay Fields wrote about it in 2007 (before he switched back to Java and then Clojure): http://blog.jayfields.com/2007/03/rails-presenter-pattern.html

@jashkenas
jashkenas / semantic-pedantic.md
Last active January 14, 2026 08:17
Why Semantic Versioning Isn't

Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil

@staltz
staltz / introrx.md
Last active March 24, 2026 13:52
The introduction to Reactive Programming you've been missing