Skip to content

Instantly share code, notes, and snippets.

View lastk's full-sized avatar

Rafael Oliveira lastk

  • Salvador-Ba, Brazil
View GitHub Profile
@lastk
lastk / using-uuid-as-pk.md
Created December 29, 2020 23:14 — forked from rponte/using-uuid-as-pk.md
Não use UUID como PK nas tabelas do seu banco de dados

Pretende usar UUID como PK em vez de Int/BigInt no seu banco de dados? Pense novamente...

TL;TD

Não use UUID como PK nas tabelas do seu banco de dados.

Um pouco mais de detalhes

@lastk
lastk / reboot_mysql_database.php
Created December 12, 2020 01:34 — forked from jasondavis/reboot_mysql_database.php
Start / Stop / Reboot MySQL Database server using SSH with PHP
<?php
// Start / Stop / Reboot MySQL Database server using SSH with PHP
// Requires the library from phpseclib.sourceforge.net / https://github.com/phpseclib/phpseclib
// Server user login data
$ssh_user = '';
$ssh_password = '';
$ssh_server_ip = '';
?>
<!DOCTYPE html>
@lastk
lastk / service-objects.md
Created November 10, 2020 16:54 — forked from blaix/service-objects.md
Martin Fowler on Service Objects via the Ruby Rogues Parley mailing list

On Tue, Mar 12, 2013 at 1:26 PM, Martin Fowler martinfowlercom@gmail.com wrote:

The term pops up in some different places, so it's hard to know what it means without some context. In PoEAA I use the pattern Service Layer to represent a domain-oriented layer of behaviors that provide an API for the domain layer. This may or may not sit on top of a Domain Model. In DDD Eric Evans uses the term Service Object to refer to objects that represent processes (as opposed to Entities and Values). DDD Service Objects are often useful to factor out behavior that would otherwise bloat Entities, it's also a useful step to patterns like Strategy and Command.

It sounds like the DDD sense is the sense I'm encountering most often. I really need to read that book.

The conceptual problem I run into in a lot of codebases is that rather than representing a process, the "service objects" represent "a thing that does the process". Which sounds like a nitpicky difference, but it seems to have a real impact on how people us

@lastk
lastk / pg_pub_sub.rb
Created August 20, 2020 20:01 — forked from chsh/pg_pub_sub.rb
PostgreSQL LISTEN/NOTIFY example for ruby
#
# A:
# pubsub = PgPubSub.new('channelname')
# pubsub.subscribe do |data|
# puts "data: #{data} is coming!"
# end
#
# B:
# pubsub = PgPubSub.new('channelname')
# pubsub.publish("hello world")
@lastk
lastk / Gemfile
Created June 25, 2020 15:46 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@lastk
lastk / spacemacs-cheshe.md
Created May 14, 2019 15:29 — forked from robphoenix/spacemacs-cheshe.md
Spacemacs Cheat Sheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
  • SPC TAB - switch to previous buffer
  • SPC b b - switch buffers
@lastk
lastk / osx_setup.md
Last active April 5, 2019 13:59 — forked from mcls/osx_setup.md
Setup mac for ruby dev
@lastk
lastk / reproduce.rb
Created April 3, 2019 16:50 — forked from albb0920/reproduce.rb
Unnecessary & slow query executed when using scope as condition
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.2.0' # use correct rails version
@lastk
lastk / Node.JS best practices and conventions.md
Created March 22, 2019 14:46 — forked from sidorares/README.md
node.js conventions and best practices

Node.JS best practices and conventions

This is not about JS style

Advice: if you have style guide / policy, apply it automatically ( in the editor or git hook ) https://github.com/jshint/fixmyjs

Collection of (mostly) JS styles (pick one you like or write another one if none fits you)

@lastk
lastk / promises-reading-list.md
Created August 14, 2018 11:37 — forked from joepie91/promises-reading-list.md
Promises (Bluebird) reading list

Promises reading list

This is a list of examples and articles, in roughly the order you should follow them, to show and explain how promises work and why you should use them. I'll probably add more things to this list over time.

This list primarily focuses on Bluebird, but the basic functionality should also work in ES6 Promises, and some examples are included on how to replicate Bluebird functionality with ES6 promises. You should still use Bluebird where possible, though - they are faster, less error-prone, and have more utilities.

I'm available for tutoring and code review :)

You may reuse all gists for any purpose under the WTFPL / CC0 (whichever you prefer).