Skip to content

Instantly share code, notes, and snippets.

View revskill10's full-sized avatar
🎯
Focusing

Truong Hoang Dung revskill10

🎯
Focusing
  • Freelancer
  • Haiphong, Vietnam
View GitHub Profile
@revskill10
revskill10 / gist:de2a856859221a11c4ad3b93ba4dfd6e
Created December 16, 2022 12:24 — forked from regedarek/gist:3734399
Extending models in Rails
# See http://blog.waxman.me/extending-your-models-in-rails-3 for original post
module Extensions
module Popular
module ClassMethods
def most_popular(limit=10)
order('points desc').limit(limit).all
end
end
def popularity
@revskill10
revskill10 / galleries.rb
Created December 16, 2022 10:12 — forked from bbonamin/galleries.rb
ActiveAdmin relationships and related models
# encoding: utf-8
ActiveAdmin.register Gallery do
menu :label => 'GalerΓ­as'
# => Índice
index do
column :name
column :description
column :date
default_actions
@revskill10
revskill10 / admin-product.rb
Created December 14, 2022 09:09 — forked from serradura/admin-product.rb
Example: Use Acts-As-Taggable-On gem with Active-Admin and rails observers
ActiveAdmin.register Product do
permit_params :name, :category_id, :description, :text, :slug, :in_slider, :tag_ids => []
filter :category
filter :base_tags
filter :name
filter :text
filter :created_at
filter :updated_at
@revskill10
revskill10 / Main.hs
Created December 4, 2022 02:07 — forked from 221V/Main.hs
haskell + postgresql (postgresql-simple + resource-pool) (async)
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BlockArguments #-}
module Main where
import Database.PostgreSQL.Simple (Connection, ConnectInfo (..), Only (..),
defaultConnectInfo, connect, query_, close)
import Data.Pool (Pool, createPool, withResource, destroyAllResources)
@revskill10
revskill10 / full_text_search.sql
Created July 4, 2022 05:18 — forked from cpursley/postgres_full_text_search.md
Postgres Full Text Search
CREATE EXTENSION unaccent;
ALTER TABLE client
ADD COLUMN full_text_search VARCHAR;
-- Do an initial update and apply the UNACCENT function searchable content
UPDATE client
SET full_text_search = tsvector_to_array(to_tsvector('english', UNACCENT(name || ' ' || COALESCE(notes, ' ') || ' ' || COALESCE(location_address, ' '))));
-- Create an AFTER INSERT OR UPDATE trigger (to maintain the column data for inserted/updated rows)
@revskill10
revskill10 / Dockerfile-prod1
Created June 11, 2022 16:10 — forked from yossisp/Dockerfile-prod1
nginx setup for multiple docker-compose containers (react.js app, node.js server)
# Dockerfile for react.js app and nginx
# build environment
FROM node:8-alpine as builder
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
RUN npm install
COPY . /usr/src/app
RUN npm run build --loglevel verbose
@revskill10
revskill10 / pubsub.ts
Created June 2, 2022 17:35 — forked from sidola/pubsub.ts
Basic typesafe pub-sub implementation in Typescript
/* ------------------------------------------
Alternative impl. as a class can be found here: https://gist.github.com/sidola/eaf987d8c4c7e8445b61dc07c33a842f
Has a way smaller footprint and less typescript magic to grasp.
------------------------------------------ */
/**
* Defines the function type of the publish function.
*
@revskill10
revskill10 / install-docker.md
Created February 23, 2022 09:48 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@revskill10
revskill10 / JavaScript.Magic.js
Created December 12, 2021 12:36 — forked from ufocoder/JavaScript.Magic.js
JavaScript Magic
/*******************************************
*
* Javascript Magic Page
*
* Author: Sergey Ivanov <[email protected]>
*
* (\_/)
* (=':'=)
* β–€β–€β–€β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–€β–€β–€
* β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
@revskill10
revskill10 / nextjs-deploy.md
Created October 24, 2021 23:29 — forked from jjcodes78/nextjs-deploy.md
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw