Instantly share code, notes, and snippets.

View latency.txt
Latency Comparison Numbers
--------------------------
L1 cache reference/hit 1.5 ns 4 cycles
Floating-point add/mult/FMA operation 1.5 ns 4 cycles
L2 cache reference/hit 5 ns 12 ~ 17 cycles
Branch mispredict 6 ns 15 ~ 20 cycles
L3 cache hit (unshared cache line) 16 ns 42 cycles
L3 cache hit (shared line in another core) 25 ns 65 cycles
Mutex lock/unlock 25 ns
L3 cache hit (modified in another core) 29 ns 75 cycles
View example.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace csharp
{
class Program
{
static void Main(string[] args)
{
View detect_marker.py
import numpy as np
import random
import math
import cv2
from PIL import Image
def detect_markers(im):
markers = []
# 輪郭線抽出のための二値化
im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
View check_docker_container.sh
#!/bin/bash
# Author: Erik Kristensen
# Email: erik@erikkristensen.com
# License: MIT
# Nagios Usage: check_nrpe!check_docker_container!_container_id_
# Usage: ./check_docker_container.sh _container_id_
#
# Depending on your docker configuration, root might be required. If your nrpe user has rights
# to talk to the docker daemon, then root is not required. This is why root privileges are not
View main.go
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
View bench.kt
import org.apache.commons.lang.RandomStringUtils
import java.util.*
fun main(args: Array<String>) {
val tryCount = 1000000
val formatStart = Date()
for (i in 1..tryCount) {
var string = "%s%s%s"
string += RandomStringUtils.randomAlphabetic(10)
val aa = string.format(RandomStringUtils.randomAlphabetic(3), RandomStringUtils.randomAlphabetic(3), RandomStringUtils.randomAlphabetic(3))
View curl.sh
while true; do sleep 3; curl -o /dev/null -sw %{time_total}\\n https://bootjp.me/ ;done
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View append_noopener.js
Array.prototype.slice.call(document.getElementsByTagName('a')).forEach(function(element) {
if (element.target === '_blank' && element.rel.indexOf('noopener') === -1) {
element.rel += ' noopener';
}
});
View display_error_code.sh
# this file added ~/.bashrc
# fork from http://qiita.com/takayuki206/items/f4d0dbb45e5ee2ee698e
function __show_exit_code() {
local status=$(echo ${PIPESTATUS[@]})
local SETCOLOR_FAILURE="echo -en \\033[1;31m"
local SETCOLOR_NORMAL="echo -en \\033[0;39m"
for s in ${status}
do
if [ ${s} -ne 0 ]; then