Skip to content

Instantly share code, notes, and snippets.

View Dakad's full-sized avatar
🐦

David A. K. Ad. Dakad

🐦
View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@Dakad
Dakad / local-ruby-gem.md
Created May 26, 2022 09:54 — forked from zulhfreelancer/local-ruby-gem.md
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

@Dakad
Dakad / default-dillinger-doc.md
Created March 19, 2022 21:09
Default Dillingerr Document.md

Dillinger

The Last Markdown Editor, Ever

N|Solid

Build Status

Dillinger is a cloud-enabled, mobile-ready, offline-storage compatible, AngularJS-powered HTML5 Markdown editor.

@Dakad
Dakad / gdb_cheat_sheet.txt
Created January 21, 2022 21:16
GDB cheat sheet
GDB commands by function - simple guide
---------------------------------------
More important commands have a (*) by them.
Startup
% gdb -help print startup help, show switches
*% gdb object normal debug
*% gdb object core core debug (must specify core file)
%% gdb object pid attach to running process
% gdb use file command to load object
@Dakad
Dakad / select_terminate.cr
Created January 11, 2022 14:47 — forked from lbarasti/select_terminate.cr
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
@Dakad
Dakad / select_pipeline.cr
Created January 11, 2022 14:46 — forked from lbarasti/select_pipeline.cr
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
@Dakad
Dakad / select_send_receive.cr
Created January 11, 2022 14:46 — forked from lbarasti/select_send_receive.cr
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
@Dakad
Dakad / git-deploy-creating.sh
Last active January 28, 2020 17:04
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.
6018 Books
6000 Business
6022 Catalogs
6017 Education
6016 Entertainment
6015 Finance
6023 Food and Drink
6014 Games
6013 Health and Fitness
6012 Lifestyle
from functools import wraps
def transaction(fn):
'''Decorator that encloses the decorated function in a DB transaction.
The decorated function does not need to session.commit(). Usage::
@transaction
def my_function(): # (...)
If any exception is raised from this function, the session is rewinded.