Skip to content

Instantly share code, notes, and snippets.

@glebov21
glebov21 / svgtopdf.js
Created March 17, 2023 11:10
Save svg to pdf by jspdf
let svgEl = drawdiv.children[1];
//Если черный квадрат, то убрать прозрачность на none
svg2pdf(svgEl, pdf, {
xOffset: this.pdfPageDefaultOffsetX,
yOffset: pdfOffsetY,
scale: divToPdfRatio
});
let prevFontSize = pdf.internal.getFontSize();
@glebov21
glebov21 / OpenFileDialog.cs
Created June 16, 2022 11:46
C# OpenFileDialog with multiselect OFN_ALLOWMULTISELECT lpstrFile
var ofn = new NativeMethods.OpenFileName();
ofn.lStructSize = Marshal.SizeOf(ofn);
if (Filter != null)
ofn.lpstrFilter = Filter.Replace('|', '\0') + "\0\0";
var maxFilePathLength = 250;
var maxFilesForMultiselect = 100;
ofn.nMaxFile = 1 * maxFilePathLength;
if (AllowMultiSelect)
{
ofn.Flags |= (
@glebov21
glebov21 / web.config
Last active September 9, 2021 15:24
Allow to download all files from iis folder (applicationHost.config -> allowSubDirConfig="false")
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="ForDownload" allowOverride="false" inheritInChildApplications="false">
<system.webServer>
<security>
<authorization>
<!-- Allow all users access to the Public folder -->
<remove users="*" roles="" verbs="" />
<add accessType="Allow" users="*" roles="" />
</authorization>
@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>
команды adb:
- вкл режим OTG
выключаешь, пишешь команду чтобы она висела в консоли, включаешь (потому что там маленький промежуток когда команда работает, потом он ставит себе режим host и уже не прокатит)
adb wait-for-device && adb shell setprop monitor.otg.mode force_device
adb devices - проверить подключено ли устройство
adb logcat - Лог
@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 / 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"