Skip to content

Instantly share code, notes, and snippets.

Avatar
👊

MarshalOfficial

👊
View GitHub Profile
@MarshalOfficial
MarshalOfficial / nginx.conf
Created Jul 7, 2021 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
View nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@MarshalOfficial
MarshalOfficial / resetident.sql
Created Jun 28, 2021
reset identity column value to the max id in postgresql
View resetident.sql
SELECT 'SELECT SETVAL(' ||
quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname)) ||
', COALESCE(MAX(' ||quote_ident(C.attname)|| '), 1) ) FROM ' ||
quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';'
FROM pg_class AS S,
pg_depend AS D,
pg_class AS T,
pg_attribute AS C,
pg_tables AS PGT
WHERE S.relkind = 'S'
@MarshalOfficial
MarshalOfficial / torwinservice.txt
Created Jun 22, 2021
installing tor as windows service
View torwinservice.txt
How to install Tor on Windows without the Tor Browser running - Tutorial
These are the installation instructions for installing Tor on Windows without the need to have the Tor Browser Bundle (TBB) running all the time as well.
Running Tor as a service on Windows separately from the Tor Browser Bundle is only usefull for users who want to keep Tor running all the time, without having to have the Tor Browser running as well.
This lets you use Tor for other services, such as instant messaging, email, or remotely accessing other computers through the Tor network. It can be especially usefull for you if you want to host onion services (Hidden Services/.onion Sites) on your Windows computer or relay traffic for other Tor users.
The Tor Browser Bundle installer for Windows, provided by the Tor Project, does not include an option during installation to configure Tor to run as a Windows service. But, by using the Windows command line interface (CLI) you can easily instruct tor.exe to install a Windows Service with
@MarshalOfficial
MarshalOfficial / autopgsqlbackup
Created Feb 27, 2021 — forked from matthewlehner/autopgsqlbackup
Auto PostgreSQL backup script.
View autopgsqlbackup
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <axelseaa@amadmax.com>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@MarshalOfficial
MarshalOfficial / pgsql_backup.sh
Created Feb 27, 2021 — forked from sirbrillig/pgsql_backup.sh
Postgresql daily backup script.
View pgsql_backup.sh
#!/bin/bash
#
# Backup a Postgresql database into a daily file.
#
BACKUP_DIR=/pg_backup
DAYS_TO_KEEP=14
FILE_SUFFIX=_pg_backup.sql
DATABASE=
USER=postgres
@MarshalOfficial
MarshalOfficial / export.cs
Last active Jan 13, 2021
streaming rows from mssqlserver db and export to excel by limit size sheet
View export.cs
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
@MarshalOfficial
MarshalOfficial / pagination.sql
Created Jan 5, 2021
sql server 3 pagination ways
View pagination.sql
declare @PageNumber int = 1,@PageSize int = 1000000
------------------------------------
--method 1
declare @edge int
select @edge = @PageNumber * @PageSize
select top (@PageSize) (SELECT ID
, UID
@MarshalOfficial
MarshalOfficial / redis.cs
Created Jan 5, 2021
batch insert to redis via MSET in stackexchange.redis c# library
View redis.cs
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
@MarshalOfficial
MarshalOfficial / bcp.cs
Created Jan 5, 2021
export sql server data to text file via bcp and parallelism and pagination
View bcp.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YOURPROJECTNAMESPACE
{
@MarshalOfficial
MarshalOfficial / cmd.cs
Created Jan 5, 2021
run a cmd command in c#
View cmd.cs
public static void RunCmd(string command)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "app name like bcp";
proc.StartInfo.Arguments = command;
proc.Start();
proc.WaitForExit();
}