Skip to content

Instantly share code, notes, and snippets.

View henry701's full-sized avatar
🎯
Focusing

Henrique Campos henry701

🎯
Focusing
View GitHub Profile
@jonlabelle
jonlabelle / ConsolePortScanner.cs
Created July 1, 2017 20:09
Simple async C# Open Port Network Scanner
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Net.Sockets;
namespace ConsolePortScanner
{
class MainClass
@negz
negz / kubedump.sh
Last active July 11, 2024 10:57
Dump Kubernetes cluster resources as YAML
#!/usr/bin/env bash
set -e
CONTEXT="$1"
if [[ -z ${CONTEXT} ]]; then
echo "Usage: $0 KUBE-CONTEXT"
exit 1
fi
@tomwhoiscontrary
tomwhoiscontrary / DoesNotCompute.java
Created May 19, 2017 17:45
Reentrant use of HashMap::computeIfAbsent leaves the map in an inconsistent state
import java.util.HashMap;
import java.util.Map;
public class DoesNotCompute {
public static void main(String[] args) {
System.out.println(System.getProperty("java.version"));
Map<String, Integer> map = new HashMap<>();
map.computeIfAbsent("spud", s -> calculate(s, map));
@soapdog
soapdog / Naive benchmark for Luvit vs Nodejs
Created September 21, 2016 20:23
Naive benchmark for Luvit vs Nodejs
This is a naive benchmark, it may not reflect real world usage. I basically used the same server script for Lua (luvit) and NodeJS
and fired the siege tool against it for 60 seconds and then 120 seconds. Luvit came ahead on both cases.
=== NodeJS 60s ===
Transactions: 18136 hits
Availability: 94.64 %
Elapsed time: 49.61 secs
Data transferred: 0.21 MB
Response time: 0.04 secs
@ishu3101
ishu3101 / loop_string.pl
Created June 7, 2016 00:53
3 ways to loop through each character in a string in Perl
# 3 ways to loop through each character in a string
$text = "hello world";
for $i (0..length($text)-1){
$char = substr($text, $i, 1);
print "Index: $i, Text: $char \n";
}
foreach $char (split //, $text) {
@wellwind
wellwind / ClearVisualStudioComponentModelCache.bat
Created February 23, 2016 03:04
Clear Visual Studio component model cache, it's useful when visual studio crash but have no ideal how to fix.
DEL %userprofile%\AppData\Local\Microsoft\VisualStudio\10.0\ComponentModelCache
DEL %userprofile%\AppData\Local\Microsoft\VisualStudio\12.0\ComponentModelCache
DEL %userprofile%\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
@drmalex07
drmalex07 / README-setup-minimal-ca.md
Last active October 3, 2024 17:14
Setup a minimal certificate authority (CA). #openssl #ca #certificate

README

Choose a directory to be the root for this CA. All paths will be relative to it.

Create CA configuration

Create your local configuration for this CA. E.g. edit ca.conf:

[ca]
@drmalex07
drmalex07 / README-certificate-with-extensions.md
Last active November 12, 2024 08:45
Provide a certificate with extended attributes (X509 v3 extensions). #x509 #openssl #certificate

README

Configure OpenSSL

The creation of a certificate has a request phase and a signing phase. Both phases need to refer to an SSL configuration file which will include the required extensions. The supported extensions are documented at man x509v3_config.

The system-wide openssl configuration usually lies at /etc/ssl/openssl.cnf. Suppose we need to request some X509 extensions (like keyUsage, extendedKeyUsage and subjectAltName), so we need to add/override some parts and we create a configuration fragment in request.conf:

@gtallen1187
gtallen1187 / scar_tissue.md
Created November 1, 2015 23:53
talk given by John Ousterhout about sustaining relationships

"Scar Tissues Make Relationships Wear Out"

04/26/2103. From a lecture by Professor John Ousterhout at Stanford, class CS142.

This is my most touchy-feely thought for the weekend. Here’s the basic idea: It’s really hard to build relationships that last for a long time. If you haven’t discovered this, you will discover this sooner or later. And it's hard both for personal relationships and for business relationships. And to me, it's pretty amazing that two people can stay married for 25 years without killing each other.

[Laughter]

> But honestly, most professional relationships don't last anywhere near that long. The best bands always seem to break up after 2 or 3 years. And business partnerships fall apart, and there's all these problems in these relationships that just don't last. So, why is that? Well, in my view, it’s relationships don't fail because there some single catastrophic event to destroy them, although often there is a single catastrophic event around the the end of the relation

@qntm
qntm / multiline.js
Last active October 16, 2023 12:39
// TODO: longer method name
Function.prototype.extractBlockCommentAsMultilineString = function() {
return this.toString().match(/^function \(\)\{\s*\/\*((?:[^*]|\*+[^*\/])*)\*+\/\s*\}$/)[1];
};
var s = function(){/*
STRING
GOES
HERE
*/}.extractBlockCommentAsMultilineString();