Version: 1.9.8
Platform: x86_64
First, install or update to the latest system software.
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
# https://medium.com/crypto-currently/lets-build-the-tiniest-blockchain-e70965a248b | |
# http://ruby-for-beginners.rubymonstas.org/writing_classes/self.html | |
# https://stackoverflow.com/questions/33768598/ruby-sha-256-hexidigest-values-are-different-from-what-python-generates | |
require 'rubygems' | |
require 'digest' | |
class Block | |
def initialize(index, timestamp, data, previous_hash) | |
@index = index |
# ~/.ssh/config | |
Host bitbucket-apple | |
Hostname bitbucket.org | |
User git | |
IdentityFile ~/.ssh/apple | |
Host bitbucket-orange | |
Hostname github.com | |
User git | |
IdentityFile ~/.ssh/orange |
# if-else | |
user = { age: 17, status: 'active' } | |
if user[:status] == 'active' | |
user[:age] >= 18 ? 'allowed' : 'not allowed' | |
else | |
user[:age] >= 18 ? 'ok' : 'no' | |
end | |
# hash | |
status = user[:status] == 'active' ? :active : :inactive |
import React, { Component } from 'react'; | |
import { FieldArray, reduxForm } from 'redux-form'; | |
import RenderItem from './render-item'; | |
class Form extends Component { | |
renderItems = ({ fields }) => { | |
{ | |
fields.map((field, i) => | |
<RenderItem | |
key={`condition-${i}`} |
class Collection < ActiveRecord::Base | |
has_many :collectings | |
accepts_nested_attributes_for :collectings, allow_destroy: true | |
end | |
class Collecting < ActiveRecord::Base | |
COLLECTABLE = [:category, :product].freeze | |
belongs_to :collection | |
belongs_to :collectable, polymorphic: true |
# I got this script from turbolinks compatibility | |
# | |
# reed.github.io/turbolinks-compatibility | |
$ -> | |
loadFacebookSDK() | |
bindFacebookEvents() unless window.fbEventsBound | |
bindFacebookEvents = -> | |
$(document) |
# Run this script with `$ ruby has_much_fun.rb` | |
require 'sqlite3' | |
require 'active_record' | |
# Use `binding.pry` anywhere in this script for easy debugging | |
require 'pry' | |
# Connect to an in-memory sqlite3 database | |
ActiveRecord::Base.establish_connection( | |
adapter: 'sqlite3', |
# controllers/admin/application_controller.rb | |
class Admin::ApplicationController < ApplicationController | |
before_action :authenticate_admin! | |
layout 'admin' | |
end |
# SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed | |
export $SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem | |
curl http://curl.haxx.se/ca/cacert.pem -o $SSL_CERT_FILE | |
curl http://curl.haxx.se/ca/cacert.pem -o /usr/local/etc/openssl/cert.pem |