Skip to content

Instantly share code, notes, and snippets.

View fernandes's full-sized avatar
🤓
Programming

Celso Fernandes fernandes

🤓
Programming
View GitHub Profile
@fernandes
fernandes / poodr.rb
Created April 23, 2016 15:48
My Annotations of POODR (Practical Object-Oriented Design in Ruby) Book by Sandi Metz
# Chapter 2: Designing Classes with Single Responsability
Single Responsability
* Ask Each Method: 'Class whats your :method?'
* Hide Instance Variables
* Hide Data Structures
* Extract Extra Responsability From Methods
Dependencies
* Must known no Constant
* Must _not_ call methods on other objects (constants)
@fernandes
fernandes / multiple_crystal.md
Last active November 3, 2021 18:41
Install Multiple Crystal Lang Versions on OSX (Homebrew)

Install Multiple Crystal Lang Versions on OSX (Homebrew)

brew unlink crystal-lang
brew install <url to formula> # check more on appendix below

If you'd like to check for installed crystal versions, just run:

@fernandes
fernandes / ctags.cr
Last active March 24, 2017 21:46
Generates ctags for a Crystal source - Crystal 0.17.4 [9d258f6] (2016-06-05)
# Generates ctags for a Crystal source
# Based on asterite script https://github.com/crystal-lang/crystal/issues/577#issuecomment-97054600
# This works on Crystal 0.17.4 [9d258f6] (2016-06-05)
#
require "compiler/crystal/**"
require "option_parser"
include Crystal
class CTagsVisitor < Visitor
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'blade' is installed as part of a gem, and
# this file is here to facilitate running it.
#
# Put this file on bin/blade
@fernandes
fernandes / qunit.js
Last active June 13, 2016 20:26
QUnit and Fixtures with timeout for a single test
QUnit.config.hidepassed = false;
var timeout = QUnit.config.testTimeout;
console.log(timeout);
QUnit.config.testTimeout = 10000;
QUnit.test( "VirtualMachines#index", function( assert ) {
assert.expect( 2 );
var done = assert.async(2);
assert.equal( sum(1, 1), 2, "Passed!" );
$ trailblazer generate operation Thing::Create
class Thing::Create < Trailblazer::Operation
end
$ trailblazer generate operation Thing::Create --steps
class Thing::Create < Trailblazer::Operation
step Model( Song, :new )
step :assign_current_user!
end
xcode-select --install
brew install \
bdw-gc \
gmp \
libevent \
libpcl \
libxml2 \
libyaml \
llvm
git clone https://github.com/crystal-lang/crystal.git
require 'trailblazer/endpoint'
require 'trailblazer/endpoint/app_matcher'
class Api::Controller < ApplicationController
protect_from_forgery with: :null_session
protected
def default_handler
->(m) do
@fernandes
fernandes / app_javascript_components_Hello.jsx
Last active August 8, 2017 01:00
styled components && rails && themes && SSR
import React from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'
import styled, {ThemeProvider} from 'styled-components';
const Button = styled.button`
font-size: 1em;
margin: 1em;
padding: 0.25em 1em;
border-radius: 3px;
@fernandes
fernandes / fs.test.js
Last active December 24, 2018 14:39
AVA test with mock-fs, reading file sync and async
import test from 'ava'
import fs from 'fs'
import mock from 'mock-fs'
test.before(t => {
mock({
'dir': {
'document': 'mocked content'
}
})