Skip to content

Instantly share code, notes, and snippets.

View dmitry-ra's full-sized avatar
🌐

Dmitry Razumikhin dmitry-ra

🌐
View GitHub Profile
@omgtehlion
omgtehlion / Program.cs
Last active August 18, 2020 00:22
this code generates a copy of officedaytime’s intrinsic guide, but for .NET Core
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Xml.Linq;
using System.Xml.XPath;
// generated page is hosted at https://drachev.com/officedaytime/
Hello there! You are currently visiting gopherspace through a
proxy. To learn more about gopher and how to browse it, read this.
______________________________________________________________________
###################################################################
Writing C software without the standard library
Linux Edition
###################################################################
There are many tutorials on the web that explain how to build a
simple hello world in C without the libc on AMD64, but most of them
@whistler
whistler / import.sh
Created March 16, 2015 17:31
Copy files to another repository while saving git history
# copied from http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/
git clone <git repository A url> # clone source repository
cd <git repository A directory>
git remote rm origin # to make sure it doesn't affect the original repository
git filter-branch --subdirectory-filter <directory 1> -- --all # remove all files other than the ones needed
mkdir <directory 1> # move them into another directory where they will be stored in the destination repository (if needed)
mv * <directory 1>
git add .
git commit
@davidfowl
davidfowl / dotnetlayout.md
Last active July 22, 2024 09:49
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@guyellis
guyellis / removeMongoField.js
Last active November 30, 2021 23:37
How to remove a field from a collection in MongoDB
// Params:
// 1. query (filter) if you only want to remove this field from some records. {} will select any.
// 2. $unset the field(s) that you want to remove. Here I've set them to null but the value doesn't matter as it's ignored.
// 3. multi must be set to true otherwise it will only operate on the first record that it finds.
//
// Run this command in the MongoDB shell
db.<collectionName>.update( {}, {$unset: {<fieldName1>: null, <fieldName2>: null}}, {multi: true});
@kmcallister
kmcallister / gist:5640703
Created May 24, 2013 01:18
C++ range class
#include <iostream>
template <typename T>
class range {
private:
class iter {
private:
T m_x;
public:
@da9l
da9l / Install-Chocoaltey
Last active February 6, 2017 13:40
Install chocolatey behind proxy with system settings in Internet Explorer.
$wc=new-object net.webclient
$wp=[system.net.WebProxy]::GetDefaultProxy()
$wp.UseDefaultCredentials=$true
$wc.Proxy=$wp
iex ($wc.DownloadString('https://chocolatey.org/install.ps1'))
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jboner
jboner / latency.txt
Last active July 26, 2024 04:31
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@SteveDunn
SteveDunn / EnumMapper.cs
Created August 17, 2011 21:25
Enum Mapper in C#
public class EnumMapper : IDisposable
{
readonly Dictionary<Type, Dictionary<string, object>> _stringsToEnums =
new Dictionary<Type, Dictionary<string, object>>( ) ;
readonly Dictionary<Type, Dictionary<int, string>> _enumNumbersToStrings =
new Dictionary<Type, Dictionary<int, string>>( ) ;
readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim( ) ;