Skip to content

Instantly share code, notes, and snippets.

View Arkham's full-sized avatar
🏠
Working from home

Ju Liu Arkham

🏠
Working from home
View GitHub Profile
@Arkham
Arkham / autosave_association.rb
Created August 4, 2014 22:38
activerecord/lib/active_record/autosave_association.rb
module ActiveRecord
# = Active Record Autosave Association
#
# +AutosaveAssociation+ is a module that takes care of automatically saving
# associated records when their parent is saved. In addition to saving, it
# also destroys any associated records that were marked for destruction.
# (See +mark_for_destruction+ and <tt>marked_for_destruction?</tt>).
#
# Saving of the parent, its associations, and the destruction of marked
# associations, all happen inside a transaction. This should never leave the
@Arkham
Arkham / test_autosave_inverse_of.rb
Created August 4, 2014 22:39
Test autosave inverse_of system stack error
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'active_record'
require 'minitest/autorun'
require 'logger'
require 'pry'
# Ensure backward compatibility with Minitest 4
@Arkham
Arkham / gemfile
Created August 4, 2014 22:40
Test activerecord gemfile
source 'http://rubygems.org'
gem 'arel', github: 'rails/arel'
gem 'rack', github: 'rack/rack'
gem 'i18n', github: 'svenfuchs/i18n'
gem 'rails', path: 'vendor/rails'
gem 'sqlite3'
gem 'pry'
@Arkham
Arkham / gist:8f82282cf45dbe2ade2a
Created August 11, 2014 17:09
Fix delayed job invoices
# Select all invoices with last_error
blob = Invoice.where("last_error ILIKE ?", "Invalid field%").includes(advisor: :bank_account).map do |invoice|
[ invoice.id, invoice.bank_account.account_number_crypted, invoice.bank_account.aba_crypted ]
end.to_json
# On blueberry
require_relative 'app'
require 'json'
@Arkham
Arkham / meta.rb
Created September 7, 2014 00:24
Respond To Missing
class Person
def initialize(name)
@name = name
end
def small_talk(other)
greet(other)
topics = methods.grep /^chat_about_/
topics.shuffle!
@Arkham
Arkham / design_everyday_things.md
Last active May 26, 2020 19:51
The Design of Everyday Things

The Design of Everyday Things

viii

Most accidents are attributed to human error, but in almost all cases human error was the direct result of poor design

x

When you have trouble with things — whether it’s figuring out whether to push or pull a door — it’s not your fault. Don’t blame yourself: blame the designer. When we see an object we’ve never used before, how do we know how to use it? The appearance of the device should provide the critical clues required for its proper operation — knowledge has to be both in the head and in the world.

xi

Conceptual Model. The human mind is a wonderful organ of understanding. A good conceptual model can make the difference between successful and erroneous operation of many devices in our life. Design is an act of communication between the designer and the user, except that all the communication has to come about the the appearance of the device itself.

@Arkham
Arkham / introrx.md
Last active August 29, 2015 14:25 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@Arkham
Arkham / application.controller.js
Created January 4, 2016 13:43
Computed Property Test
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@Arkham
Arkham / application.controller.js
Created January 4, 2016 15:04
Data component test
import Ember from 'ember';
Ember.TextField.reopen({
init: function() {
this._super();
var self = this;
Object.keys(this).forEach(function(key) {
if (key.substr(0, 5) === 'data-') {
self.get('attributeBindings').pushObject(key);
@Arkham
Arkham / octave.md
Created January 9, 2016 17:09 — forked from miguelsaddress/octave.md
An Octave introduction cheat sheet.

Octave CheatSheet

GNU Octave is a high-level interpreted language, primarily intended for numerical computations.
(via GNU Octave)

Basics

  • not equal ~=
  • logical AND &amp;&amp;