Skip to content

Instantly share code, notes, and snippets.

View jimmynguyc's full-sized avatar

Jimmy Ngu jimmynguyc

  • Kuala Lumpur, Malaysia
View GitHub Profile
require "action_mailbox/test_helper"
include ActionMailer::TestHelper
ActionaMailbox::InboundEmail.last.destroy
# Example 1
# ==========
# We have an email that shows Manifested weight: 0.0 Kg
# But the actual weight is defined somewhere else
# E.g. The total chargeable weight on this shipment is
❯ bundle env
## Environment
```
Bundler 2.4.1
Platforms ruby, arm64-darwin-21
Ruby 3.1.2p20 (2022-04-12 revision 4491bb740a9506d76391ac44bb2fe6e483fec952) [arm64-darwin-21]
Full Path /Users/jimmy/.rubies/ruby-3.1.2ossl3/bin/ruby
Config Dir /Users/jimmy/.rubies/ruby-3.1.2ossl3/etc
RubyGems 3.3.7
@jimmynguyc
jimmynguyc / install multiple rubies
Last active December 29, 2022 08:43
Installing ruby with different OpenSSL lib version using ruby-install
#!/bin/sh
rm -fr ~/.gem/ruby/3.1.2
export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"
ruby-install 3.1.2 --install-dir ~/.rubies/ruby-3.1.2ossl11 -- --enable-shared --with-openssl-dir=$(brew --prefix [email protected]) CC=clang
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
@jimmynguyc
jimmynguyc / ossl3_test.rb
Created December 28, 2022 14:26
Test case for OpenSSL3 PKCS7
require "openssl"
require "minitest/autorun"
require "pry"
class OpenSSL3Test < Minitest::Test
def ca_key
@ca_key ||= OpenSSL::PKey::RSA.new(2048)
end
def ca_cert
# kubeconfig per session
file="$(mktemp -t "kubectx.XXXXXX")"
cat $HOME/.kube/config > $file
export KUBECONFIG="${file}:$HOME/.kube/config"
@jimmynguyc
jimmynguyc / manual_publication_write.rb
Created May 23, 2020 03:49
Overcoming lack of publication_write permission for Shopify private apps
require "byebug"
require "time"
require "capybara/cuprite"
require "capybara/dsl"
require "capybara/rspec/matchers"
require "rspec/expectations"
include Capybara::DSL
include Capybara::RSpecMatchers

Keybase proof

I hereby claim:

  • I am jimmynguyc on github.
  • I am jimmynguyc (https://keybase.io/jimmynguyc) on keybase.
  • I have a public key whose fingerprint is E641 270B 9341 2C98 EA50 A6DA A950 2DDA 80D8 C260

To claim this, I am signing this object:

class JimmyBot < RTanque::Bot::Brain
NAME = 'jimmy_bot'
include RTanque::Bot::BrainHelper
def tick!
@current_heading ||= nil
@current_turret_heading ||= nil
command.speed = 3.0
command.heading = sensors.radar_heading + 10.0
@jimmynguyc
jimmynguyc / activerecord_without_rails.rb
Last active November 21, 2015 22:07
ActiveRecord without Rails
require 'active_record'
require 'sqlite3'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => "teachers.db"
)
# Migration
ActiveRecord::Schema.define do