Skip to content

Instantly share code, notes, and snippets.

Avatar

Zulhilmi Zainudin zulhfreelancer

View GitHub Profile
@zulhfreelancer
zulhfreelancer / k8s-ephemeral.sh
Created Oct 8, 2021
Kubernetes ephemeral pod (like `docker run --rm`)
View k8s-ephemeral.sh
kubectl run debug --rm -i --tty --restart=Never --image=alpine --namespace=default -- /bin/sh
@zulhfreelancer
zulhfreelancer / local-ruby-gem.md
Last active Jun 21, 2021
How to use a local Ruby gem in Rails project?
View local-ruby-gem.md

Situation

You are working on a Rails app that uses a gem named abc. This gem is hosted on RubyGems and the source code of the gem is available at https://github.com/your-username/abc.

You created a new branch locally for your gem (new-feature). You wanted to modify the gem and load it directly to your local Rails app. And, you don't want to push the gem changes to GitHub and publish the gem to RubyGems just yet.

You want all the changes that you made in your local gem directory get reflected immediately in your local Rails app without requiring you to run gem build and gem install command in the gem's local directory.

Steps

@zulhfreelancer
zulhfreelancer / _flash.html.erb
Last active Jun 13, 2021
How to add link inside Rails flash message? Tested with Rails 6.
View _flash.html.erb
<!--
* File: app/views/shared/_flash.html.erb
* Note: the `html_safe` is important here
-->
<% flash.each do |type, msg| %>
<div class="alert alert-info">
<%= msg.html_safe %>
</div>
<% end %>
@zulhfreelancer
zulhfreelancer / gps-glonass-golang.go
Last active Jun 12, 2021
Get latitude and longitude from Glonass GPS USB stick (U-blox7) using Golang
View gps-glonass-golang.go
package main
import (
"fmt"
"github.com/stratoberry/go-gpsd"
"time"
)
func main() {
var gps *gpsd.Session
@zulhfreelancer
zulhfreelancer / README.md
Last active Jul 14, 2021
How to install an older or specific version of Homebrew tap package?
View README.md

Problem

When using Homebrew Tap, it's quite hard to install an older or specific version of Homebrew package.

It took me awhile to run some tests before I found the solution (see below).

If you are facing the same problem, you can use my script below to solve the problem.

Solution

@zulhfreelancer
zulhfreelancer / fix-multipass-starting-on-mac.md
Last active Oct 20, 2021
How to fix Multipass stuck at "Starting" state on Mac OSX?
View fix-multipass-starting-on-mac.md
# Step 1: see the status of VMs
$ multipass ls
Name   State          IPv4           Image
vm1    Stopped        --             Ubuntu 20.04 LTS <-- this one is OK, stopped in previous command
vm2    Starting       --             Ubuntu 20.04 LTS <-- this one is not OK, why it's stuck?



# Step 2: apply the fix
@zulhfreelancer
zulhfreelancer / pbcopy-on-remote-server.md
Created May 24, 2021
How to use `pbcopy` on Linux server when using SSH?
View pbcopy-on-remote-server.md

If you are using iTerm2 on Mac OSX and trying to have pbcopy experience when using Linux server (over SSH), try this remote-pbcopy-iterm2 tool.

@zulhfreelancer
zulhfreelancer / kubevirt-virsh.md
Created Apr 26, 2021
How to use Virsh command to interact with Kubevirt VMs running in Kubernetes cluster?
View kubevirt-virsh.md
$ kubectl get pods
NAME                     READY   STATUS    RESTARTS   AGE
virt-launcher-vm-4sd8h   1/1     Running   0          2d13h



$ kubectl exec -it virt-launcher-vm-4sd8h -- bash
bash-5.0# virsh list
 Id   Name         State
@zulhfreelancer
zulhfreelancer / regex.md
Last active Mar 23, 2021
Regex to find WIP Golang function comments in VS Code
View regex.md