Skip to content

Instantly share code, notes, and snippets.

View ArturT's full-sized avatar

Artur Trzop ArturT

View GitHub Profile
@subfuzion
subfuzion / curl.md
Last active April 24, 2025 13:48
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@lucasdicioccio
lucasdicioccio / GildedTulip.hs
Last active March 19, 2019 02:39
What an immutable GildedRose would look like
-- An alternative GildedRose using an immutable approach.
-- Context on the GildedRose:
-- * http://blog.lunarlogic.io/2015/what-ive-learned-by-doing-the-gilded-rose-kata-4-refactoring-tips/
-- * my comment in the linked blog post
-- One could take this GildedTulip approach and encapsulate a similar "immutable API"
-- to re-create the "mutable API" of the GildedRose.
--
-- This example is written in Haskell. This example uses three notable features (available in other languages):
-- - pattern matching: a way to hide a lot of "if"
@Dr-Nikson
Dr-Nikson / README.md
Last active December 30, 2024 11:14
Auth example (react + redux + react-router)
@masutaka
masutaka / Vagrantfile
Last active October 20, 2015 18:18
CI of Chef recipes using CircleCI + Vagrant + AWS + serverspec
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :local do |local|
local.vm.box = "ubuntu/trusty64"
local.vm.network "private_network", ip: "192.168.50.13"

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@buren
buren / rails_strong_parameters_refactor.rb
Last active December 24, 2020 11:59
A simple pattern to refactor permitted params for Rails with StrongParameters included.
# Rails StrongParameters refactor
#
# Inspired by Ryan Bates's Screencast #371
# http://railscasts.com/episodes/371-strong-parameters
#
# A simple pattern to refactor permitted params for Rails with StrongParameters.
# app/models/author.rb
class Author < ActiveRecord::Base
validates_presence_of :name, :birth_date
@emaraschio
emaraschio / SOLID.markdown
Last active February 16, 2025 23:43
SOLID Principles with ruby examples

SOLID Principles with ruby examples

SRP - Single responsibility principle

A class should have only a single responsibility.

Every class should have a single responsibility, and that responsibility should be entirely encapsulated. All its services should be narrowly aligned with that responsibility, this embrace the high cohesion.

OCP - Open/closed principle

Software entities should be open for extension, but closed for modification.

@rafaelcaricio
rafaelcaricio / howto.md
Last active December 4, 2019 15:17
Using git bisect

Using git bisect

Git provides a simple way to find out where some code was modified or removed from your codebase. You can use git bisect for that and the processes can be completely automated.

As example I will try to find out when the method send_email_notification was removed from the file app/models/person.rb. So you have to create a automated bash file, or other kind of script, that should return 0 when the method is found and 1 otherwise. So git can run this script for each commit until it returns 1, which means that the method was removed in that commit. There's the script we gonna use:

if [[ `cat app/models/person.rb | grep send_email_notification` ]]; then
@staltz
staltz / introrx.md
Last active April 24, 2025 06:10
The introduction to Reactive Programming you've been missing
@dhh
dhh / test_induced_design_damage.rb
Last active November 2, 2024 00:52
This is an extraction from Jim Weirich's "Decoupling from Rails" talk, which explained how to apply the hexagonal design pattern to make every layer of your application easily unit testable (without touching the database etc). It only seeks to extract a single method, the EmployeesController#create method, to illustrate the design damage that's …
# Original Rails controller and action
class EmployeesController < ApplicationController
def create
@employee = Employee.new(employee_params)
if @employee.save
redirect_to @employee, notice: "Employee #{@employee.name} created"
else
render :new
end