Skip to content

Instantly share code, notes, and snippets.

@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();
}
@MarshalOfficial
MarshalOfficial / scp.cs
Last active Jan 5, 2021
SCP Sample C#, it will copy all the files in target folder to a remote server target location via scp and parallelism with max thread count is manageable
View scp.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WinSCP;
namespace YOURPROJECTNAMESPACE
@MarshalOfficial
MarshalOfficial / crossapply.sql
Created Nov 23, 2020
call table value function with base table select statement
View crossapply.sql
--The APPLY operator should do the trick:
SELECT *
from MarketDataMaster
cross apply dbo.fn_MarketDataDetails (MarketDataMasterID)
--This essentially calls the function once per row returned from MarketDataMaster. "cross apply" works like an inner join, in that only rows for which data is returned by the function will be returned; use "outer apply" for functionality similar to left outer joins.
@MarshalOfficial
MarshalOfficial / config.txt
Created Oct 20, 2020
raspberry pi 7 inch monitor config
View config.txt
init_uart_clock=16000000 # set uart clock to 16mhz
kernel_old=1 # load kernel.img at physical memory address 0x0
safe_mode_gpio=8 # a temp firmware limitation workaround
max_usb_current=1 # enable maximum usb current
gpu_mem=32
hdmi_force_hotplug=1 # enable hdmi display even if it is not connected (640x480)