Skip to content

Instantly share code, notes, and snippets.

View maclarensg's full-sized avatar
🎯
Focusing

Gavin Yap maclarensg

🎯
Focusing
  • 42dev.co
View GitHub Profile
@maclarensg
maclarensg / func_bashrc
Last active November 5, 2021 15:15
switch ssh keys snippet
# add this in ur bashrc script
switch_ssh(){
envs=()
for file in $(find ~/.ssh -name "id_rsa.pub.*" -printf "%f\n"); do
runtime=$( echo $file | awk -F '.' '{print $NF}' )
envs+=( $runtime )
done
i=0
Signal Value Action Comment
SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGILL 4 Core Illegal Instruction
SIGABRT 6 Core Abort signal from abort(3)
SIGFPE 8 Core Floating point exception
SIGKILL 9 Term Kill signal
SIGSEGV 11 Core Invalid memory reference
SIGPIPE 13 Term Broken pipe: write to pipe with no readers
@maclarensg
maclarensg / rhf.md
Last active September 13, 2018 08:32
RisingHR Commands

AT Commands RisingHF

Use serial set at 9600 baud rate, does not display INPUT is normal

Appkey 2B7E151628AED2A6ABF7158809CF4F3C

10.16.101.47

Commands

@maclarensg
maclarensg / lvm.md
Created September 12, 2018 04:00
LVM #linux

LVM

Prepare the new disk

Create partition on deisk

# fdisk /dev/sdb 

Command (m for help): p
@maclarensg
maclarensg / date_time.md
Last active September 17, 2018 03:54
Linux snippets

Epoch

Current Epoch Time

echo $(($(date +'%s * 1000 + %-N / 1000000')))

Set Epoch time

echo $(($(date --date="Sep 17 00:00:00 SGT 2018" +'%s * 1000 + %-N / 1000000')))
@maclarensg
maclarensg / Example.rb
Created September 7, 2018 14:40
[Ruby - Custom before and after call hooks] Snippet code of how to define and create custom hooks in Ruby #hooks #ruby
module Hooks
@@before_methods = []
@@after_methods = []
def before(*method_names, **actions)
# create a Module for preprend to exisitng class
to_prepend = Module.new do
method_names.each do |method|
@@before_methods << method
define_method(method) do |*args, &block|
send(actions[:do]) if @@before_methods.include? method
@maclarensg
maclarensg / index.md
Last active May 14, 2019 04:07
Integrating MDbootstrap to Rails 5

Guide to integrate mdbootstrap to rails5

Preparing a railsapp

  1. Create a new rails app
rails new MyNewApp --skip-active-record
  1. Add to Gemfile the with the following Gems:
gem 'mongoid', '~> 6.0'