Skip to content

Instantly share code, notes, and snippets.

View NullVoxPopuli's full-sized avatar

NullVoxPopuli

View GitHub Profile
@NullVoxPopuli
NullVoxPopuli / class_and_instance_eval.rb
Last active August 29, 2015 14:19
Testing how class_eval and instance_eval affect instances and classes
# colored console output
require 'colorize'
class MyClass
end
def attempt(message)
begin
puts message + ": " + yield.green
rescue => e
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www=
.w3.org/TR/REC-html40/loose.dtd">
<html xmlns=3D"http://www.w3.org/1999/xhtml">
<head>
<header style=3D"background:#333;color:white;padding:40px">
<div class=3D"shell" style=3D"margin:0 auto;max-width:800px">
<h1>
Confirm Your Email
module ActiveModel
class Serializer
module Utils
class UtilsTest < MiniTest::Test
def test_include_options_to_hash_from_symbol
expected = { author: {} }
input = :author
actual = ActiveModel::Serializer::Utils.include_options_to_hash(input)
require 'active_model'
require 'active_model_serializers'
class BaseModel
# provides self.model_name
include ActiveModel::Model
attr_accessor :id, :updated_at
def cache_key
@NullVoxPopuli
NullVoxPopuli / random-sort.rb
Last active November 24, 2015 18:45
Random sorting algorithm benchmarks
num_sorted = 0
num_total = 1000000
num_elements = 10
max_random_integer = num_elements
sorted = []
num_total.times do |i|
array = Array.new(num_elements){ rand(max_random_integer) }
if array == array.sort
num_sorted += 1
@NullVoxPopuli
NullVoxPopuli / .tmux.conf
Last active December 11, 2015 20:05
Because learning a new set of commands is non-trivial to keep in long term memory (esp it Chrome closes and you don't remember where you found that one cheat sheet)
# First remove *all* keybindings
unbind-key -a
# Now reinsert all the regular tmux keys
# bind-key C-b send-prefix
bind-key C-o rotate-window
bind-key C-z suspend-client
bind-key Space next-layout
bind-key ! break-pane
@NullVoxPopuli
NullVoxPopuli / components.my-component.js
Last active November 7, 2018 14:44 — forked from chrism/controllers.application.js
Testing Query Parameter Binding
import Ember from 'ember';
export default Ember.Component.extend({
resetToken: null
});
@NullVoxPopuli
NullVoxPopuli / adapters.application.js
Last active March 24, 2016 19:15
Ember-Data Demo
import Ember from 'ember';
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
namespace: 'api',
host: 'https://aeonvera-staging.work/'
});
@NullVoxPopuli
NullVoxPopuli / application.route.js
Created March 25, 2016 11:27 — forked from rwjblue/application.route.js
Example of Attribute Binding
import Ember from 'ember';
import log from '../utils/log';
import Post from '../models/post';
export default Ember.Route.extend({
model() {
return new Post({
title: 'So Classy!',
author: 'Robert'
});
@NullVoxPopuli
NullVoxPopuli / components.message-user.js
Last active March 25, 2016 15:12 — forked from workmanw/components.message-user.js
Component + Service Example
import Ember from 'ember';
export default Ember.Component.extend({
user: null,
messenger: Ember.inject.service(),
message: '',
displayName: Ember.computed(
'user.title', 'user.firstName', 'user.lastName', function() {