Skip to content

Instantly share code, notes, and snippets.

View Dakad's full-sized avatar
🐦

David A. K. Ad. Dakad

🐦
View GitHub Profile
@zulhfreelancer
zulhfreelancer / local-ruby-gem.md
Last active December 4, 2023 21:17
How to use a local Ruby gem in Rails project?

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

DietPi Give your Single-board computer some Lightweight justice. What you'll need:

4GB or greater Micro SD card.
Internet Access (Ethernet or Wifi, required to complete the DietPi setup).
Dedicated USB Drive is highly recommended (Allows DietPi-Software installations to utilize USB over SD).

Step 1 (Download DietPi Image): Download - dietpi.com

@lbarasti
lbarasti / select_terminate.cr
Created May 2, 2020 23:54
select use case 1: graceful termination
def producer(name : String, &generator : -> T) forall T
Channel(T).new.tap { |ch|
spawn(name: name) do
loop do
ch.send generator.call
end
end
}
end
@lbarasti
lbarasti / select_send_receive.cr
Created May 2, 2020 23:50
use case 2: mixing send and receive
def producer(name : String, &generator : -> T) forall T
Channel(T).new.tap { |ch|
spawn(name: name) do
loop do
ch.send generator.call
end
end
}
end
@lbarasti
lbarasti / select_pipeline.cr
Created May 2, 2020 23:43
select use case 4: dealing with back-pressure
def producer(name : String, &generator : -> T) forall T
Channel(T).new.tap { |ch|
spawn(name: name) do
loop do
ch.send generator.call
end
end
}
end
@mousavian
mousavian / k8s-cronjob-suspend.sh
Last active September 15, 2023 08:40
Suspending all cronjobs in all namespaces in kubernetes
#!/bin/bash
for ns in $(kubectl get ns -o jsonpath="{.items[*].metadata.name}"); do
for cj in $(kubectl get cronjobs -n "$ns" -o name); do
kubectl patch "$cj" -n "$ns" -p '{"spec" : {"suspend" : true }}';
done
done
@rampfox
rampfox / Chromium-at-startup.md
Last active June 1, 2024 03:55
How to open Chromium in full screen at startup on the Raspberry Pi

(debian 10 buster)

First, it seems that ~/.config/lxsession/LXDE-pi/autostart does not exist by default.

  1. copy the autostart
cp /etc/xdg/lxsession/LXDE-pi/autostart ~/.config/lxsession/LXDE-pi/
@olejorgenb
olejorgenb / places-exploration.sql
Last active April 7, 2024 00:35
Firefox places.sqlite exploration (browser history)
--- Firefox places.sqlite exploration
-- https://developer.mozilla.org/en-US/docs/Mozilla/Tech/Places/Database
-- https://wiki.mozilla.org/images/d/d5/Places.sqlite.schema3.pdf
-- http://forensicswiki.org/wiki/Mozilla_Firefox_3_History_File_Format (probably somewhat outdated)
-- [select text -> right click -> search] does not set from_visit :(
-- Gotchas :angry-face: https://superuser.com/a/1405880/153095 (Explains why your history is incomplete)
@viktorbenei
viktorbenei / main.go
Last active October 14, 2023 00:53
sha1 hmac hexdigest signature
package main
import (
"crypto/hmac"
"crypto/sha1"
"crypto/subtle"
"encoding/hex"
"fmt"
"os"
)
@francoisromain
francoisromain / project-create.sh
Last active June 14, 2024 09:55
A bash script to create a Git post-receive hook to deploy after a Git push
#!/bin/bash
# source: https://gist.github.com/francoisromain/58cabf43c2977e48ef0804848dee46c3
# and another script to delete the directories created by this script
# project-delete.sh: https://gist.github.com/francoisromain/e28069c18ebe8f3244f8e4bf2af6b2cb
# Call this file with `bash ./project-create.sh project-name`
# - project-name is mandatory
# This will creates 4 directories and a git `post-receive` hook.