Skip to content

Instantly share code, notes, and snippets.

@glebov21
glebov21 / SendMail.cs
Created September 8, 2021 12:55
Send mail
using System;
using System.Text;
using System.Net.Mail;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Net.Mime;
using System.Diagnostics;
@glebov21
glebov21 / App.config
Last active September 2, 2021 11:23
trace listeners
var logSW = new StreamWriter("output.txt", false);
logSW.AutoFlush = true;
Trace.Listeners.Add(new TextWriterTraceListener(logSW));
Trace.Listeners.Add(new ConsoleTraceListener(true));
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
@glebov21
glebov21 / gist:a8a110dc759e83e66966ee48dbcdedcd
Last active May 31, 2021 13:49
.net 4.0 download async
using System;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Calibration {
public static class Server {
public delegate void ProgressDelegate(int percents, long bytesReceived, long totalBytesToReceive);
@glebov21
glebov21 / AppSettings.cs
Last active May 17, 2021 14:08
AppSettings read write
public static string GetSettings(string key)
{
return ConfigurationManager.AppSettings[key] ?? "";
}
public static void SetSetting(string key, string value)
{
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
configuration.AppSettings.Settings[key].Value = value;
configuration.Save();
@glebov21
glebov21 / WebClient.cs
Last active May 14, 2021 13:05
WebClient with progress
namespace AutogrammaLauncher
{
using System;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
public static class Server
@glebov21
glebov21 / pgx.go
Created August 22, 2019 13:52
pgx postgresql connection example
package main
import (
"log"
"time"
"github.com/jackc/pgx"
)
func main() {
@glebov21
glebov21 / UnityExtensions.cs
Last active January 13, 2024 05:08
unity extensions
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
public static class UnityExtensions
{
@glebov21
glebov21 / restore.bash
Created August 19, 2019 10:28
restore postgresql backup
#!/bin/bash
backupfile="pgsql_2019-08-06.sql.gz"
cd /data/pgbackup
gunzip -c ${backupfile} > restore.sql
systemctl stop aero
service postgresql restart
su postgres -c 'dropdb aerodb'
su postgres -c $'psql -f /data/pgbackup/restore.sql postgres'
systemctl restart aero
rm restore.sql
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
@glebov21
glebov21 / pgdump
Last active March 4, 2021 08:02
pgdump
#!/bin/sh
pathB=/data/pgbackup
dbUser=postgres
database=aerodb
mkdir -p $pathB
chmod 775 -R $pathB
find $pathB -mtime +61 -delete
su $dbUser -c "/usr/bin/pg_dumpall --database=$database | gzip > $pathB/pgsql_$(date -u "+%Y-%m-%d").sql.gz"