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 / server.js
Last active December 25, 2018 17:23
Apollo Server 2 + Prisma, E2E Testing with AVA, with a technique to reset database and load some fixtures
const { ApolloServer, gql } = require('apollo-server')
const { Prisma } = require('../generated/prisma-client')
const { importSchema } = require('graphql-import')
const resolvers = require('./resolvers')
const importedTypeDefs = importSchema(__dirname + '/../generated/prisma.graphql');
const typeDefs = gql`${importedTypeDefs}`
const endpoint = 'http://localhost:4466'
@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'
}
})
@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;
require 'trailblazer/endpoint'
require 'trailblazer/endpoint/app_matcher'
class Api::Controller < ApplicationController
protect_from_forgery with: :null_session
protected
def default_handler
->(m) do
xcode-select --install
brew install \
bdw-gc \
gmp \
libevent \
libpcl \
libxml2 \
libyaml \
llvm
git clone https://github.com/crystal-lang/crystal.git
$ 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
@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!" );
#!/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 / 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
@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: