Skip to content

Instantly share code, notes, and snippets.

View toidang92's full-sized avatar

Bá Tới toidang92

  • Hồ Chí Minh City
  • 06:12 (UTC +07:00)
  • LinkedIn in/toidang92
View GitHub Profile
@toidang92
toidang92 / odi_keygen.py
Created September 7, 2024 14:59 — forked from rajkosto/odi_keygen.py
ODI SFP XPON stick MAC_KEY generator
#!/usr/bin/env python3
#ODI DFP-34X-2C2 MAC_KEY key generator by rajkosto
import sys
import string
import hashlib
args = sys.argv
if len(args) != 2:
sys.exit("Usage: odi_keygen.py YOURMACADDR")
@toidang92
toidang92 / notes.md
Created July 22, 2024 10:54 — forked from arthur-e/notes.md
Ubuntu for GIS Installation and Setup

Post-Installation Fixes and Setup

# Install compilers and linking tools; other tools
sudo apt-get install g++ swig curl build-essential python-all-dev

# Install package manager
sudo apt-get install synaptic

# Install Unity customization tool

sudo apt-get install unity-tweak-tool

@toidang92
toidang92 / README.md
Created April 25, 2024 00:54 — forked from jesster2k10/README.md
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

# My Adguard Home whitelist
#Adguard DNS
@@||dns.adguard.com^$important
@@||dns-family.adguard.com^$important
# Google
@@||0.client-channel.google.com^$important
@@||2.android.pool.ntp.org^$important
@@||android.clients.google.com^$important
@@||clients1.google.com^$important
@@||clients2.google.com^$important
@toidang92
toidang92 / nginx.conf
Created June 24, 2023 10:03 — forked from tolitius/nginx.conf
openresty (nginx + lua): redis connection pooling
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
init_worker_by_lua_block {
redis = require("resty.redis")
}
server {
class MeasureGC
def self.run(options = { gc: :enable })
if options[:gc] == :disable
GC.disable
elsif options[:gc] == :enable
# collect memory allocated during library loading
# and our own code before the measurement
GC.start
GC.start
GC.start
" Install Vim
" sudo apt-get install vim
" brew install vim --with-python3
" Install Vundle
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" $ vim
" $ :PluginInstall
set nocompatible " be iMproved, require
" Disable bell sound
@toidang92
toidang92 / letsencrypt_2017.md
Created March 4, 2018 09:28 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@toidang92
toidang92 / _form.html.erb
Created December 25, 2017 10:44 — forked from gilcierweb/_form.html.erb
Upload image crop with Ruby and Rails, CarrierWave and Cropper.js
#app/views/businesses/_form.html.erb
<%= form_with(model: business, scope: :business, local: true, :html => {multipart: true}) do |form| %>
<div class="row">
<div class="col-md-12">
<%= form.file_field :logo_image, id: :business_logo_image %>
<%= form.label :logo_image, class: 'upload' do %>
<i class="material-icons">file_upload</i>
<span>Choose image</span>
@toidang92
toidang92 / omniauth_dynamic_setup.md
Created February 27, 2017 13:14 — forked from jiggneshhgohel/omniauth_dynamic_setup.md
Omniauth Dynamic Setup Custom Params Custom Callback

/config/initializers/omniauth.rb

def provider_facebook
  'facebook'
end

def facebook_opts
  my_model_obj = MyModelService.find_by_provider_name(provider_facebook)