Skip to content

Instantly share code, notes, and snippets.

@sancar
sancar / README.md
Last active April 22, 2024 16:15
An upgradable read write lock for go

And upgradable read write lock for go

UpgradableRWMutex is an enhanced version of the standard sync.RWMutex. It has the all methods sync.RWMutex with exact same semantics. It gives more methods to give upgradable-read feature.

The new semantics for upgradable-read are as follows:

  • Multiple goroutines can get read-lock together with a single upgradable-read-lock.
  • Only one goroutine can have a write-lock and no read-lock/upgradable-read-lock can be acquired in this state.
package main
import (
"sync"
)
func Highway(asyncProcessor EventProcessor, numWorkers int, inputC chan Event) chan HydratedEvent {
outputC := make(chan HydratedEvent, 0)
type worker struct {
@leonardofed
leonardofed / README.md
Last active May 3, 2024 01:24
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


@TJHeuvel
TJHeuvel / MeshVisualizeWindow.cs
Last active June 17, 2021 09:03
Visualizes the mesh vertices and triangles
using UnityEngine;
using UnityEditor;
using System.Collections;
using System;
public class MeshVisualizeWindow : EditorWindow
{
[MenuItem("Window/Mesh visualizer")]
public static void OpenWindow()
{
@swissmanu
swissmanu / vpn.sh
Last active January 31, 2019 09:35
A shell script to start/stop Check Point Endpoint VPN/Firewall clients on Mac OS X. No more unreachable machines in your network if no VPN is necessary. Tested with version 80.61
#!/bin/bash
#
# by Manuel Alabor <manuel@alabor.me>
# https://github.com/swissmanu
#
SCRIPT_NAME=`basename $0`
VERSION="0.0.1"
print_help()
@MichaelF25
MichaelF25 / ImmutableData.java
Last active March 25, 2022 00:37
Immutable Data with builder and proper Jackson mapping
package de.cpg.test;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import lombok.Builder;
import lombok.Value;
@Value
@Builder(builderClassName = "Builder")
@JsonDeserialize(builder = ImmutableData.Builder.class)
@bhauman
bhauman / README.md
Last active December 3, 2019 16:43
ClojureScript minimal dev and prod setup.

Recent improvements to the ClojureScript compiler have greatly simplified setting up development versus production outputs.

This example uses Figwheel as something that you want to exclude for production, but the pattern is general.

With this simple setup you only need one html file/view and it will work for developement and production.

@rodricios
rodricios / summarize.py
Last active November 18, 2020 17:21
Flipboard's summarization algorithm, sort of
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
pip install networkx distance pattern
In Flipboard's article[1], they kindly divulge their interpretation
of the summarization technique called LexRank[2].
@thomasdarimont
thomasdarimont / objectCount.md
Last active August 29, 2015 14:11
Determine # of instances of a Java Klass in Java 9 via js with Nashorn, HotspotAgent

We use Java 9 since it's new and already includes sa-jdi.jar in classpath :) Note that the debugee JVM dosen't need to be Java 9.

tom@gauss ~/dev/repos/thomasdarimont/playground/tmp $ java -version
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b41)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b41, mixed mode)
/**
* Written by Gil Tene of Azul Systems, and released to the public domain,
* as explained at http://creativecommons.org/publicdomain/zero/1.0/
*/
package org.HdrHistogram;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import java.util.concurrent.locks.ReentrantLock;