Skip to content

Instantly share code, notes, and snippets.

View xchinjo's full-sized avatar

xchinjo hank xchinjo

  • DevZ
  • Bangkok , Thailand
View GitHub Profile
@xchinjo
xchinjo / mongodb_c#_cheatsheet.md
Created March 19, 2021 13:21 — forked from a3dho3yn/mongodb_c#_cheatsheet.md
MongoDB C# Driver Cheat Sheet

MongoDB C# Driver Cheat Sheet

(C) 2015 by Derek Hunziker, (C) 2017 by AppsOn

As of releasing MongoDB 3.4 and C# Driver v2.4, original cheatsheet by Derek is outdated. In addition, it has some deficiencies like connecting to MongoDB, creating indexes, etc. This updated version works fine with C# Driver v2.4.7 and MongoDB v3.4.

Setup

Define Document Models

Note: Defined models and collections will be used in entire cheatsheet.

@xchinjo
xchinjo / next_nginx.md
Created March 10, 2021 13:32 — forked from kocisov/next_nginx.md
How to setup next.js app on nginx with letsencrypt

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

@xchinjo
xchinjo / security.conf
Created February 10, 2021 15:56 — forked from mattia-beta/security.conf
NGINX Security Config
## Block SQL injections
set $block_sql_injections 0;
if ($query_string ~ "union.*select.*\(") {
set $block_sql_injections 1;
}
if ($query_string ~ "union.*all.*select.*") {
set $block_sql_injections 1;
}
@xchinjo
xchinjo / ddos.conf
Created February 10, 2021 15:56 — forked from mattia-beta/ddos.conf
IPtables DDoS Protection for VPS
### 1: Drop invalid packets ###
/sbin/iptables -t mangle -A PREROUTING -m conntrack --ctstate INVALID -j DROP
### 2: Drop TCP packets that are new and are not SYN ###
/sbin/iptables -t mangle -A PREROUTING -p tcp ! --syn -m conntrack --ctstate NEW -j DROP
### 3: Drop SYN packets with suspicious MSS value ###
/sbin/iptables -t mangle -A PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -j DROP
### 4: Block packets with bogus TCP flags ###
@xchinjo
xchinjo / generateLaunchScreen.sh
Created January 27, 2020 15:19 — forked from roblabs/generateLaunchScreen.sh
Generate iOS Launch or splash screen from a single image
#!/bin/bash -e
# --------------------------------------------------------
# Generate iOS Launch items from a single image
# (c) 2017 ePi Rational, Inc.
#
# Modified from original script which generated app icons for iOS,
# originally written by
# Ben Clayton, Calvium Ltd.
# https://gist.github.com/benvium/2be6d673aa9ac284bb8a
package chemp.notes.linenotify;
import java.io.*;
import java.net.*;
import java.util.regex.Pattern;
public class LineNotify {
private static final String strEndpoint = "https://notify-api.line.me/api/notify";
public boolean callEvent(String token, String message) {
boolean result = false;
# HEADER: This file was autogenerated at 2016-11-29 20:10:40 -0800
# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.
# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
# name = value