Skip to content

Instantly share code, notes, and snippets.

@brain64bit
brain64bit / public_subnet_b.sh
Created March 15, 2022 05:11
Get public subnet class B of my IP
echo "$(wget --timeout=30 http://ipinfo.io/ip -qO - | cut -d"." -f1-2).0.0"
@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 / hello.md
Last active February 21, 2019 19:30
Ruby IO Writing & Slurping

Writing a file using IO

producer will write a single line of string to file every 1s

require 'securerandom'

fd = IO.sysopen("/tmp/lala.log", "w+")
writer = IO.new(fd)
writer.sync = true
i = 1
while true do
@brain64bit
brain64bit / ruby-high-sierra.md
Created September 23, 2018 15:44
Mac OSX High Sierra Ruby Problems
  • Cannot start vim/macvim cause ruby
sudo install_name_tool -change /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/libruby.2.3.0.dylib /usr/local/bin/vim
@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:

@brain64bit
brain64bit / kfcrecipes.md
Created October 22, 2017 06:26
KFC 11 secret recipes:

KFC Secret Recipe:

Mix with 2 cups white flour:

  • 2/3 tablespoon salt
  • 1/2 tablespoon thyme
  • 1/2 tablespoon basil
  • 1/3 tablespoon oregano
  • 1 tablespoon celery salt
  • 1 tablespoon black pepper
  • 1 tablespoon dried mustard
  • 4 tablespoons paprika