Skip to content

Instantly share code, notes, and snippets.

View thiagovsk's full-sized avatar
🏠
Working from home

Thiago Ribeiro thiagovsk

🏠
Working from home
View GitHub Profile
@thiagovsk
thiagovsk / semantic-commit-messages.md
Created September 13, 2021 15:06 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@thiagovsk
thiagovsk / rails http status codes
Created February 4, 2019 12:23 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@thiagovsk
thiagovsk / simple-twitter.rb
Created August 9, 2016 17:31 — forked from coderberry/simple-twitter.rb
Application oauth2 for Twitter using Ruby
require 'oauth'
require 'httpclient'
require 'json'
class SimpleTwitter
def initialize(config)
@config = config
@http_client = HTTPClient.new
end
@thiagovsk
thiagovsk / REAME.md
Created November 23, 2015 23:02 — forked from romansklenar/REAME.md
How to set up your VPS with Chef Solo

How to set up your VPS with Chef Solo

1. What is it?

There are many different provisioning tools out there, the most popular of which are Chef and Puppet. Chef uses Ruby, Puppet uses a DSL (Domain Specific Language), there are others that use simple bash too, but today we're going to focus on Chef Solo.

2. Dependencies

To get Chef working properly on your local machine you need a few things.

Make sure you use Ruby 1.9.x and not Ruby 2.x as you will get errors with the json 1.6.1 gem on 2.x. Use rbenv or RVM to manage several different Rubies on the one machine.

sudo vim core/setup/controller.php
71 $autosetup_file = \OC::$SERVERROOT.'/owncloud_dev/autoconfig.php';
sudo vim lib/base.php
102 } elseif(isset($_SERVER["OWNCLOUD_CONFIG_DIR"])) {
103 self::$configDir = OC::$SERVERROOT . '/' . $_SERVER["OWNCLOUD_CONFIG_DIR"] . '/';
#include <pthread.h>
#include <stdio.h>
#include <semaphore.h>
#define MAX_ITENS 100
#define USE_SEM
#ifdef USE_SEM
sem_t mutex; // protege a operação de adicionar ou remover itens
sem_t producer_calls_available; // verifica se há chamadas disponíves para o produtor
# sudo nano /opt/nginx/conf/nginx.conf
worker_processes 2;
worker_rlimit_nofile 100000;
events {
worker_connections 768;
use epoll;
multi_accept on;
@thiagovsk
thiagovsk / oop.md
Last active August 29, 2015 14:14 — forked from robotlolita/oop.md

Objeto é a noção de uma entidade que é definida inteiramente pelo seu comportamento. E esse comportamento é dinâmicamente selecionado. Em outras palavras, eu "peço" um objeto para "andar," e como ele vai fazer isso é inteiramente definido pelo objeto.

O exemplo:

objeto.anda()

Captura bem essa idéia. Eu tenho uma mensagem "anda," mas eu não consigo dizer o que essa função faz direto do meu código, porque isso depende no comportamento dinâmico da execução do programa (em uma linguagem estáticamente tipada você consegue optimizar isso, mas o raciocínio do código continua o mesmo).

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h