Skip to content

Instantly share code, notes, and snippets.

@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@JulienBlancher
JulienBlancher / filter.d_nginx-auth.conf
Last active October 22, 2024 21:17
Fail2ban Config with Nginx and SSH
#
# Auth filter /etc/fail2ban/filter.d/nginx-auth.conf:
#
# Blocks IPs that makes too much accesses to the server
#
[Definition]
failregex = ^<HOST> -.*"(GET|POST).*HTTP.*"
ignoreregex =
@Manouchehri
Manouchehri / cloudflare.sh
Last active November 17, 2024 15:09
Allow CloudFlare only
# Source:
# https://www.cloudflare.com/ips
# https://support.cloudflare.com/hc/en-us/articles/200169166-How-do-I-whitelist-CloudFlare-s-IP-addresses-in-iptables-
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
for i in `curl https://www.cloudflare.com/ips-v6`; do ip6tables -I INPUT -p tcp -m multiport --dports http,https -s $i -j ACCEPT; done
# Avoid racking up billing/attacks
# WARNING: If you get attacked and CloudFlare drops you, your site(s) will be unreachable.
iptables -A INPUT -p tcp -m multiport --dports http,https -j DROP
@mdang
mdang / RAILS_CHEATSHEET.md
Last active November 4, 2024 15:59
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@kriswebdev
kriswebdev / novpn.sh
Last active October 11, 2024 19:13
novpn: Bypass VPN for specific apps [Linux / OpenVPN]
#!/bin/bash
# === INFO ===
# NoVPN
# Description: Bypass VPN tunnel for applications run through this tool.
VERSION="3.0.0"
# Author: KrisWebDev
# Requirements: Linux with kernel > 2.6.4 (released in 2008).
# This version is tested on Ubuntu 14.04 and 19.10 with bash.
# Main dependencies are automatically installed.
@adrian17
adrian17 / kanji_easy.json
Last active June 2, 2023 18:43
kanji data for NHK News Web Easy
{
"desc": "kanji frequency for NHK News Web Easy, 1855 articles from 2014-12-02 to 2016-07-15",
"source": "https://gist.github.com/adrian17/836b97ee5740b20e63edbe35251d6bc1",
"label": "easy news",
"total": 158118,
"list": [
[
"人",
5093
],
@sander1
sander1 / nginx.local
Last active January 23, 2024 15:40
fail2ban filters for nginx
# fail2ban filter configuration for nginx, by Sander
# 1) Catch WordPress related requests (we don't have WordPress on this server)
# 2) Catch requests for certain scripts we don't host
# 3) Catch script requests we don't host
# 4) Catch referer spam
[Definition]
failregex = ^<HOST> .* "(GET|POST|HEAD) /+(?i)(wp(-|/)|xmlrpc\.php|\?author=1)
^<HOST> .* "(GET|POST|HEAD|PROPFIND) /+(?i)(a2billing|admin|apache|axis|blog|cfide|cgi|cms|config|etc|\.git|hnap|inc|jenkins|jmx-|joomla|lib|linuxsucks|msd|muieblackcat|mysql|myadmin|n0w|owa-autodiscover|pbxip|php|pma|recordings|sap|sdk|script|service|shell|sqlite|vmskdl44rededd|vtigercrm|w00tw00t|webdav|websql|wordpress|xampp|xxbb)
@Brainiarc7
Brainiarc7 / conky-setup-clevo-p751dm2-g.md
Last active February 21, 2024 09:24
My Conky configuration

Setting up Conky on Ubuntu 16.04LTS for the Clevo P751DM2-G

System Information:

We extract this with inxi:

installation:

sudo apt-get install inxi
@komasaru
komasaru / regression_curve_ln.rb
Last active February 2, 2024 00:36
Ruby script to calculate a simple regression curve.(ln)
#! /usr/local/bin/ruby
#*********************************************
# Ruby script to calculate a simple regression curve.
# : y = a + b * ln(x)
# : 連立方程式を ガウスの消去法で解く方法
#*********************************************
#
class Array
def reg_curve_ln(y)
# 以下の場合は例外スロー
@wareya
wareya / texthook.js
Last active July 18, 2020 11:16
subtitle text grabbing script for mpv
"use strict";
function on_new_sub(name, text)
{
if(text == null || text == "")
return;
var newtext = "";
for(var i = 0; i < text.length; i += 1)
{
var c = text[i];