Skip to content

Instantly share code, notes, and snippets.

View cotin18's full-sized avatar
🎯
Focusing

cotin18

🎯
Focusing
View GitHub Profile
@cotin18
cotin18 / ClassGenerator.sql
Created July 20, 2022 13:53 — forked from DanElliott/ClassGenerator.sql
Generate C# class from database table
--modified from SO: http://stackoverflow.com/questions/5873170/generate-class-from-database-table
--added table and column
declare @TableName sysname = 'TableName'
declare @Result varchar(max) = '[Table(Name = "' + @TableName + '")]
public class ' + @TableName + '
{'
select @Result = @Result + '
[Column(DbType = "' +
@cotin18
cotin18 / ExtractTarGz.cs
Created May 23, 2022 14:02 — forked from ForeverZer0/ExtractTarGz.cs
Use pure C# to extract .tar and .tar.gz files
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
namespace TarExample
{
public class Tar
{
@cotin18
cotin18 / compile-nginx-brotli-modules.sh
Created January 29, 2022 16:32 — forked from jivanpal/compile-nginx-brotli-modules.sh
Compile Brotli modules for Nginx 1.18.0 on Ubuntu 20.04
#!/bin/bash
sudo apt install \
build-essential \
libpcre3-dev \
libssl-dev \
zlib1g-dev \
libxml2-dev \
libxslt1-dev \
libgd-dev \
@cotin18
cotin18 / CountryCodes.json
Created May 9, 2021 12:57 — forked from Goles/CountryCodes.json
Country and Dial or Phone codes in JSON format
[{"name":"Israel","dial_code":"+972","code":"IL"},{"name":"Afghanistan","dial_code":"+93","code":"AF"},{"name":"Albania","dial_code":"+355","code":"AL"},{"name":"Algeria","dial_code":"+213","code":"DZ"},{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},{"name":"Andorra","dial_code":"+376","code":"AD"},{"name":"Angola","dial_code":"+244","code":"AO"},{"name":"Anguilla","dial_code":"+1 264","code":"AI"},{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG"},{"name":"Argentina","dial_code":"+54","code":"AR"},{"name":"Armenia","dial_code":"+374","code":"AM"},{"name":"Aruba","dial_code":"+297","code":"AW"},{"name":"Australia","dial_code":"+61","code":"AU"},{"name":"Austria","dial_code":"+43","code":"AT"},{"name":"Azerbaijan","dial_code":"+994","code":"AZ"},{"name":"Bahamas","dial_code":"+1 242","code":"BS"},{"name":"Bahrain","dial_code":"+973","code":"BH"},{"name":"Bangladesh","dial_code":"+880","code":"BD"},{"name":"Barbados","dial_code":"+1 246","code":"BB"},{"name":"Belarus","dial_code":"+375","
@cotin18
cotin18 / countries.js
Created May 8, 2021 16:49 — forked from electerious/countries.js
All country codes in one object.
var countries = {
AF: 'Afghanistan',
AX: 'Aland Islands',
AL: 'Albania',
DZ: 'Algeria',
AS: 'American Samoa',
AD: 'Andorra',
AO: 'Angola',
AI: 'Anguilla',
AQ: 'Antarctica',
@cotin18
cotin18 / deploy-forwarding-rules.sh
Created April 4, 2021 15:23
Build a backend instance for Minecraft packet forwarding
#!/bin/bash
export EXPOSED_PORT=25565
export BACKEND_HOST=10.10.10.10:25565
cat <<END | sudo tee /etc/sysctl.d/55-enable-ip-forward.conf
# `/sbin/sysctl net.ipv4.ip_forward`
net.ipv4.ip_forward = 1
END
sudo sysctl -p /etc/sysctl.d/55-enable-ip-forward.conf
@cotin18
cotin18 / iptables
Created April 4, 2021 15:22 — forked from Calvin-Huang/iptables
Minecraft Anti-DDoS iptables configuration
*raw
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -p tcp -m tcp --dport 25565 -j CT --notrack
COMMIT
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
@cotin18
cotin18 / swap.sh
Created April 1, 2021 14:12
Shell script for adding swap to Linux
#!/bin/sh
# size of swapfile in megabytes
swapsize=1024
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then
@cotin18
cotin18 / JS-LINQ.js
Created March 22, 2021 16:58 — forked from DanDiplo/JS-LINQ.js
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },
{ name: "Judy", age: 42 },
{ name: "Tim", age: 8 }
@cotin18
cotin18 / CustomerController.cs
Created March 14, 2021 14:04 — forked from vkhorikov/CustomerController.cs
Handling failures and input errors in a functional way
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(