Skip to content

Instantly share code, notes, and snippets.

@brain64bit
brain64bit / 00_etc-hosts.md
Created July 31, 2021 07:16 — forked from mul14/00_etc-hosts.md
/etc/hosts for Vimeo, Reddit, and Imgur.

Unblock Vimeo, Reddit, Imgur, dan NPM

Saya support Internet Positif untuk memblokir porn, situs judi, dan hal-hal ilegal lainnya. Tapi pemerintah dan ISP sangat konyol karena tidak mengizinkan akses ke Vimeo, Reddit, Imgur, Netflix--yang mana bukanlah situs dengan konten utama ilegal.

Linux / BSD / macOS

Tambahkan list di bawah ke /etc/hosts.

Windows

@brain64bit
brain64bit / capybara-headless-chrome.rb
Created August 15, 2018 13:40 — forked from matthewrudy/capybara-headless-chrome.rb
Running headless chrome on capybara with selenium webdriver
require "selenium/webdriver"
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chromeOptions: { args: %w(headless disable-gpu) }
)
@brain64bit
brain64bit / Capybara.md
Created August 15, 2018 12:28 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@brain64bit
brain64bit / reactRailsTestSetup.md
Created February 26, 2018 17:22 — forked from andrewprogers/reactRailsTestSetup.md
Setting up A new React on Rails app with webpacker and full test suite

React on Rails with Test Suite (Karma, Jasmine, Enzyme, PhantomJS)

The steps included here detail the steps I followed to get a new React on Rails app set up, with a focus on testing JS components with Karma / Jasmine / Enzyme. A lot of this was liberally borrowed / modified from the Launch Academy curriculum, but there are some additional steps involved to get everything working with webpacker:

Unless otherwise specified, run the code in the terminal

Install Rails with Webpacker configured for React:

rails new project-name
cd project-name
@brain64bit
brain64bit / thread-pool.rb
Created January 30, 2018 16:13 — forked from rosenfeld/thread-pool.rb
Simple thread pool implementation in Ruby
require 'thread' # for Mutex: Ruby doesn't provide out of the box thread-safe arrays
class ThreadPool
def initialize(max_threads = 10)
@pool = SizedQueue.new(max_threads)
max_threads.times{ @pool << 1 }
@mutex = Mutex.new
@running_threads = []
end

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

require "rspec/core/formatters/base_text_formatter"
require 'headless'
require 'fileutils'
class AcceptanceVideoFormatter < RSpec::Core::Formatters::BaseTextFormatter
def initialize(output)
@headless = Headless.new(
video: {
nomouse: true,
@brain64bit
brain64bit / Selenium Cheat Sheet.md
Last active June 22, 2016 03:26 — forked from kenrett/Selenium Cheat Sheet.md
Selenium Cheat Sheet - Ruby
@brain64bit
brain64bit / README.md
Last active March 12, 2016 15:45 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@brain64bit
brain64bit / README.md
Created February 4, 2016 09:13 — forked from quiver/README.md
Who says PostgreSQL can't Pub/Sub like Redis?

Pub/Sub pattern with PostgreSQL's LISTEN/NOTIFY command

This is a simple chat-like program using pub-sub pattern, backed by PostgreSQL's LISTEN/NOTIFY command.

Publish

publish message to foo channel from user nickname.

$ python pub.py foo nickname
PUBLISH to channel #foo