Skip to content

Instantly share code, notes, and snippets.

View lukes's full-sized avatar

Luke Duncalfe lukes

View GitHub Profile
@BrianPugh
BrianPugh / State-Blocks.md
Last active April 8, 2018 08:12
State-Blocks

NEP-01: State Blocks

NANO

The implementation of state blocks (known as "universal blocks") is a protocol improvement that encodes all account data in every transaction. This allows the following:

  1. Simplifies account balance computation and block verification
  2. Enables inexpensive hardware to easily and securely sign transactions
  3. Aggressive pruning of the block-lattice

Legacy Blocks

@theorygeek
theorygeek / association_loader.rb
Last active October 31, 2023 07:15
Preloading Associations with graphql-batch
# frozen_string_literal: true
class AssociationLoader < GraphQL::Batch::Loader
attr_reader :klass, :association
def initialize(klass, association)
raise ArgumentError, "association to load must be a symbol (got #{association.inspect})" unless association.is_a?(Symbol)
raise ArgumentError, "cannot load associations for class #{klass.name}" unless klass < ActiveRecord::Base
raise TypeError, "association #{association} does not exist on #{klass.name}" unless klass.reflect_on_association(association)
@klass = klass
@NuckChorris
NuckChorris / array.js
Last active February 12, 2018 19:47 — forked from pixelhandler/transforms.js
In Ember-CLI, transforms are located in app/transforms/name.js
// app/transforms/array.js
import Ember from 'ember';
import DS from 'ember-data';
export default DS.Transform.extend({
deserialize: function(value) {
if (Ember.isArray(value)) {
return Ember.A(value);
} else {
return Ember.A();
@chiepomme
chiepomme / two.d.ts
Last active October 5, 2018 03:23
typescript declaration for two.js
declare class Two {
type: Two.Types;
width: number;
height: number;
constructor(params?: TwoConstructionParams);
appendTo(element: HTMLElement);
makeLine(x1: number, y1: number, x2: number, y2: number): Two.Shape;
makeRectangle(x: number, y: number, width: number, height: number): Two.Shape;
@jdjkelly
jdjkelly / gist:9906676
Created April 1, 2014 02:40
Ember App Kit Initializer Example for Injecting Current User into Controllers
import Session from 'appkit/models/session';
export default Ember.Application.initializer({
name: 'currentUser',
initialize: function(container, app) {
// Register a new container
container.register('session:current-user', Session);
// Load the current user
container.lookup('session:current-user').find();
@XueshiQiao
XueshiQiao / gource.sh
Last active November 10, 2019 15:56 — forked from cgoldberg/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
@ZogStriP
ZogStriP / ember.js-with-google-maps.html
Created May 31, 2013 13:32
How to use Google Maps with Ember.js
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.3/ember.js"></script>
<script src="//maps.googleapis.com/maps/api/js?sensor=false"></script>
</head>
<body>
<script>
@havenwood
havenwood / benchmark_results.rb
Last active May 26, 2021 12:49
Benchmarking serialization speed of YAML, JSON, Marshal, and MessagePack in Ruby, JRuby, and Rubinius
# ruby-2.5.0
user system total real
YAML 15.112795 0.030577 15.143372 ( 15.190573)
JSON 0.648957 0.001520 0.650477 ( 0.652856)
Marshal 0.474775 0.000922 0.475697 ( 0.477678)
MessagePack 0.326430 0.001763 0.328193 ( 0.330159)
# ruby-2.4.3
user system total real
YAML 20.400000 0.050000 20.450000 ( 20.517600)
@choplin
choplin / process_pool.rb
Created August 21, 2012 15:14
Process Pool in Ruby
require 'msgpack'
require 'thread'
class ProcessPool
def initialize(num_process, args={})
queue_size, worker_class = parse_args([
:queue_size, nil,
:worker_class, Worker,
], args)
module AfterCommitCallbacks
def self.included(base)
base.send(:extend, ObserverCallbacks) unless base.respond_to?(:define_model_callbacks_for_observers)
[:create, :update, :destroy].each do |action|
base.send(:define_model_callbacks_for_observers, :"commit_on_#{action}", :only => :after)
end
base.send(:attr_accessor, :newly_created)
base.send(:before_validation, AfterCommitCallbacks::Handlers)