Skip to content

Instantly share code, notes, and snippets.

View NaiveCAI's full-sized avatar
🎹
A CRUD programmer,钢琴业余0级爱好者,价值投资门口的赌徒。

Tracy Cai NaiveCAI

🎹
A CRUD programmer,钢琴业余0级爱好者,价值投资门口的赌徒。
  • Xometry
  • Shanghai
View GitHub Profile
@rameerez
rameerez / kamal-production-server-setup.sh
Last active November 19, 2025 03:26
Set up a Ubuntu server to deploy Kamal 2.x Docker containers to, hardened security and production ready
#!/bin/bash
# Production Docker Host Hardening Script v2
# For Ubuntu Server 24.04 LTS (Noble)
# Suitable for both Kamal deployment and builder hosts
set -euo pipefail
IFS=$'\n\t'
# --- Constants ---
@kohheepeace
kohheepeace / memo.md
Last active January 27, 2025 08:31
Rails ajax comparison (fetch, Rails.ajax, axios, @rails/request.js, Turbo)

Rails ajax comparison (fetch, Rails.ajax, axios, @rails/request.js, Turbo)

I wrote this gist because I felt that the Rails documentation was lacking a description of ajax requests.

📌 Options for ajax request

There are various ways to send ajax requests in Rails.

  1. Browser default Fetch API
  2. Rails.ajax (No Official docs and request for docs)
  3. http client like axios
  4. @rails/request.js 👈 I'm using this one now !
@bodrick
bodrick / datatables.js
Last active June 11, 2024 22:07
esbuild and datatables.net
import $ from 'jquery'
window.jQuery = window.$ = $
import JSZip from 'jszip'
window.JSZip = JSZip
import 'pdfmake'
import dataTable from 'datatables.net-bs4'
dataTable(window, $)
import buttons from 'datatables.net-buttons-bs4'
buttons(window, $)
import columnVisibility from 'datatables.net-buttons/js/buttons.colVis.js'
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active November 10, 2025 07:59
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@Grawl
Grawl / webpack-https-mkcert.md
Created August 10, 2019 06:21
Running Webpack Dev Server with HTTPS on developer machine using MKCERT
  1. Add local domain to /etc/hosts:

    127.0.0.1 my-project.dev

  2. Install mkcert

  3. Create certificate for this domain:

    ➜ mkcert my-project.dev
@shobhitsharma
shobhitsharma / ssl-localhost-webpack.md
Last active August 7, 2023 09:13
SSL support for localhost with Webpack

HTTPS using localhost

To generate a local certiticate and using it, please follow these steps (note: replace MY_DOMAIN, MY_FILENAME and MY_PASSPHRASE based on your choice):

Step 1: Generate private key

openssl genrsa -out MY_FILENAME.key 4096
@andyyou
andyyou / rails_webpacker_bootstrap_expose_jquery.md
Last active November 14, 2025 00:54
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@tunguskha
tunguskha / Gradient shadow in pure CSS.md
Last active October 12, 2024 17:02
Gradient shadow in pure CSS

Gradient shadow in pure CSS

alt text

HTML
<button>Let's Go !</button>
@johvet
johvet / array_validator.rb
Created August 31, 2017 18:42
A Rails validator which is allows to apply any validator to array type columns
# frozen_string_literal: true
##
# Validator for array columns
#
# Credits go to Alexander Menzhinsky, who created an initial version of this [https://gist.github.com/amenzhinsky/c961f889a78f4557ae0b].
#
# Usage:
# validates :array_column, array: { length: { is: 20 }, allow_blank: true }
# validates :array_column, array: { numericality: true }
@xiaojue
xiaojue / t.js
Last active March 18, 2025 01:47
countdown
/**
* @author xiaojue
* @date 20160420
* @fileoverview 倒计时
*/
(function() {
function timer(delay) {
this._queue = [];
this.stop = false;