Skip to content

Instantly share code, notes, and snippets.

1, 1. SemaphoreSlim. Time = 13ms
1, 1. SemaphoreSlim. Time = 11ms
1, 1. SemaphoreSlim. Time = 11ms
1, 1. SemaphoreSlim. Time = 11ms
1, 1. SemaphoreSlim. Time = 12ms
1, 1. SemaphoreSlim. Time = 12ms
1, 1. SemaphoreSlim. Time = 12ms
1, 1. SemaphoreSlim. Time = 12ms
1, 1. SemaphoreSlim. Time = 11ms
1, 1. SemaphoreSlim. Time = 11ms
@alexandrnikitin
alexandrnikitin / linux-cheatsheet.sh
Last active December 14, 2022 13:14
Linux cheatsheet
// Find used space
df -h
du -h / | grep '[0-9\.]\+G'
du -h --max-depth=1 | sort -hr
/bin/treesize
#/bin/sh
du -k --max-depth=1 | sort -nr | awk '
BEGIN {
split("KB,MB,GB,TB", Units, ",");
import scala.collection.mutable
import scala.io.BufferedSource
import scala.collection.mutable.ListBuffer
val linkToSpreadsheet = "https://docs.google.com/spreadsheets/d/1wce5rPQ-g8I-cIkL_e2eVsau52m6OSe5uoKh5Xk4lfE"
val linkToTabSeparatedData = linkToSpreadsheet + "/export?format=tsv"
def source = io.Source.fromURL(linkToTabSeparatedData)
//def source = io.Source.fromFile("C:\\Projects\\my\\LambdaConfTicket\\src\\main\\resources\\data.tsv")
case class Talk(name: String, value: Int, length: Int, scheduled: Boolean)
<#
.SYNOPSIS
Find all files excluded from a Visual Studio solution with options to delete.
.DESCRIPTION
Finds all excluded files in all projects in the provided Visual Studio solution with options to delete the files.
.PARAMETER Solution
The path to the .sln file
@alexandrnikitin
alexandrnikitin / install-sbt-on-ubuntu.sh
Last active August 29, 2015 14:15
Install sbt on Ubuntu
// from the package repository
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-get update
sudo apt-get install sbt
// or from the deb package
wget http://dl.bintray.com/sbt/debian/sbt-0.13.7.deb
sudo dpkg -i sbt-0.13.7.deb
sudo apt-get install -f
@alexandrnikitin
alexandrnikitin / git-cheatsheet.sh
Last active March 23, 2023 04:56
Git cheatsheet
// remove untracked files, including directories (-d) and files ignored by git (-x) to force (-f) to exclude files (-e)
git clean -n -d -x -e ".idea"
// compare content of moved folder
git diff --ignore-space-change \
HEAD:source/oldDir/someDir \
HEAD~1:source/newDir/someDir/
// delete merged local branches (use "| xargs -n 1 echo" if not sure)
git branch --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git branch -d
@alexandrnikitin
alexandrnikitin / AhoCorasickTree.cs
Created January 16, 2015 16:05
Aho-Corasick for language detection
using System;
using System.Collections.Generic;
namespace LanguageDetection
{
public class AhoCorasickTree
{
private readonly AhoCorasickTreeNode _rootNode;
public AhoCorasickTree(IEnumerable<Tuple<string, int>> mapings)
import scala.collection.mutable.LinkedHashMap
val catFile = Seq("1\0012\0013\0014", "5\0016\0017\0018")
var categoryMap = LinkedHashMap[ Int, Tuple2[ String, Int ] ]()
catFile.foreach(line => {
val strs = line.split("\001")
categoryMap += (strs(0).toInt ->(strs(2), strs(3).toInt))
})
categoryMap
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace HttpClientMemoryLeak
{
class Program
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace HttpClientMemoryLeak
{
class Program
{
public static async Task TestMethod()
{