Skip to content

Instantly share code, notes, and snippets.

View jamel's full-sized avatar

Sergey Polovko jamel

View GitHub Profile
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 10
#
# Samples: 8K of event 'cycles:ppp'
# Event count (approx.): 23242659568
#
# Children Self Period Command Shared Object Symbol
# ........ ........ ............ .......... .................. .............................................................
package com.mongodb.async.client;
import java.util.concurrent.CompletableFuture;
import com.mongodb.async.SingleResultCallback;
import com.mongodb.client.model.Filters;
import com.mongodb.connection.netty.NettyStreamFactoryFactory;
import com.mongodb.event.CommandFailedEvent;
import com.mongodb.event.CommandListener;
import com.mongodb.event.CommandStartedEvent;
@jamel
jamel / ssh-agent-forwarding-screen.md
Created September 19, 2016 11:34 — forked from martijnvermaat/ssh-agent-forwarding-screen.md
SSH agent forwarding and screen

SSH agent forwarding and screen

When connecting to a remote server via SSH it is often convenient to use SSH agent forwarding so that you don't need a separate keypair on that server for connecting to further servers.

This is enabled by adding the

ForwardAgent yes

option to any of your Host entries in ~/.ssh/config (or alternatively with the -A option). Don't set this option in a wildcard Host * section since any user on the remote server that can bypass file permissions can now als use keys loaded in your SSH agent. So only use this with hosts you trust.

@jamel
jamel / BuildersHelper.java
Created March 11, 2016 12:37
fixed BuildersHelper class to support arrays, collections and maps
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.bson.BsonDocument;
import org.bson.BsonDocumentWriter;
import org.bson.codecs.Codec;
import org.bson.codecs.Encoder;
import org.bson.codecs.EncoderContext;
@jamel
jamel / chacha.h
Last active August 29, 2015 14:19 — forked from orlp/chacha.h
#include <cstdint>
#include <limits>
template<size_t R>
class ChaCha {
public:
typedef uint32_t result_type;
explicit ChaCha(uint64_t seedval, uint64_t stream = 0);
template<class Sseq> explicit ChaCha(Sseq& seq);

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

$ ls -la /private/tmp/gcc48-KEjk/gcc-4.8.2/
total 21248
drwxr-xr-x 74 jamel wheel 2.5K Nov 22 00:51 ./
drwx------ 3 jamel wheel 102B Nov 22 00:50 ../
-rw-r--r-- 1 jamel wheel 317B Jan 10 2013 .gitignore
-rw-r--r-- 1 jamel wheel 38K Jul 4 2003 ABOUT-NLS
-rw-r--r-- 1 jamel wheel 18K Jul 14 2005 COPYING
-rw-r--r-- 1 jamel wheel 26K Jul 14 2005 COPYING.LIB
-rw-r--r-- 1 jamel wheel 3.2K Apr 9 2009 COPYING.RUNTIME
-rw-r--r-- 1 jamel wheel 34K Jul 17 2007 COPYING3
@jamel
jamel / wpkg.patch
Created October 17, 2013 12:33
Patch that helps to build wpkg on Mac OS X 10.8 with GCC 4.8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 566aa71..e55238d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -87,7 +87,7 @@ if( UNIX )
message( FATAL_ERROR "Unknown architecture '${ARCH}'!" )
endif()
if( DEFINED ENV{WPKG_COVERAGE} )
- set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Werror -Wall -Wextra -pedantic -std=gnu++0x -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=1 -Wundef -Wno-unused -Wunused-variable -Wno-variadic-macros -Wno-parentheses -Wno-unknown-pragmas -Wwrite-strings -Wswitch -fdiagnostics-show-option -fprofile-arcs -ftest-coverage" )
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -Werror -Wall -Wextra -pedantic -std=gnu++0x -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Winit-self -Wlogical-op -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls