Skip to content

Instantly share code, notes, and snippets.

View zxsanny's full-sized avatar

Alex B. zxsanny

  • 2c2p
  • Lviv, Ukraine
View GitHub Profile
@zxsanny
zxsanny / LambdaEqualityComparer.cs
Last active July 17, 2020 15:14
Lambda Equality Comparer
public class EqualityComparerFactory
{
private sealed class Impl<T> : IEqualityComparer<T>
{
private readonly Func<T, T, bool> Eq;
private readonly Func<T, int> HashFunc;
public Impl(Func<T, T, bool> eq, Func<T, int> hashFunc)
{
Eq = eq;
HashFunc = hashFunc;
@zxsanny
zxsanny / RemoveSerializedAttributes
Created December 4, 2014 11:07
Remove unnecessary properties and so one when you are
var data = JsonConvert.SerializeObject(message, Formatting.None, new JsonSerializerSettings
{
ContractResolver = new ExcludePropertiesContractResolver(new []{"SuccessMessage", "ErrorMessage"})
});
public class ExcludePropertiesContractResolver : DefaultContractResolver
{
private readonly List<string> ExcludedProperties;
(New-Object System.Net.WebClient).DownloadFile("http://link.exe", "D:\Downloads\file.exe")
function zxdiff(arr, arrDiff, propFn) {
var hash = [];
for (var x = 0; x < arrDiff.length; x++) {
hash[propFn(arrDiff[x])] = true;
}
var res = [];
for (var i = 0; i < arr.length; i++) {
if (!hash[ propFn(arr[i]) ]) {
res.push(arr[i]);
set @token = 'OrderBy';
SELECT *
FROM
(
SELECT replace( substring(settings, position(@token in settings) + length(@token) + 2,
locate(',', settings, position(@token in settings) + length(@token) + 2) - (position(@token in settings) + length(@token) + 2)),
'"','') as field
FROM widgets
) t
WHERE t.field != 'null';
sudo apt install terminator git -y
git clone https://github.com/zxsanny/linux-init-install.git
linux-init-install/install.sh
TimeSpan PerformanceTest(Action action, int repeats)
{
var sw = new Stopwatch();
sw.Start();
for (int i = 0; i < repeats; i++)
action();
sw.Stop();
return sw.Elapsed;
}
1. ssh-keygen - generate public key
2. copy it from C:\Users\{user}\.ssh id_rsa.pub and paste to
https://scm.2c2p.com/plugins/servlet/ssh/account/keys (or other place)
3. ssh-agent (runs ssh agent, Powershell: Set-Service ssh-agent -StartupType Automatic to run it automatically after start)
4. ssh-add (or put to C:\Program Files\Git\etc\ssh\ssh_config to the end of the file: IdentityFile C:\Users\zxsanny\.ssh\id_rsa)