openssl x509 -in stackexchangecom.crt -text -noout
openssl x509 -in cert.pem -text -noout
openssl x509 -inform der -in foobar.cer -noout -text
from functools import wraps | |
class exception_guard(object): | |
"""Guard against the given exception and raise a different exception.""" | |
def __init__(self, catchable, throwable=RuntimeError): | |
if is_exception_class(catchable): | |
self._catchable = catchable | |
else: | |
raise TypeError('catchable must be one or more exception types') |
If you are setting up nginx,chances are you will discover your worker_connections is at some low number, such as 1024.
You can’t increase this number unless you increase kernel limit as well.
First of all run cat /proc/sys/fs/file-max
to discover your maximum limit.
abc@ubuntu:~$ cat /proc/sys/fs/file-max
1048576
abc@ubuntu:~$ ulimit -n
1024
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
CREATE OR REPLACE FUNCTION pseudo_encrypt(VALUE bigint) returns bigint AS $$ | |
DECLARE | |
l1 bigint; | |
l2 bigint; | |
r1 bigint; | |
r2 bigint; | |
i int:=0; | |
BEGIN | |
l1:= (VALUE >> 32) & 4294967295::bigint; | |
r1:= VALUE & 4294967295; |
from itertools import islice, chain | |
def batches_from_iterable(iterable, size): | |
# Iterate over an iterable producing iterables of batches. Based on: | |
# http://code.activestate.com/recipes/303279-getting-items-in-batches/ | |
iterator = iter(iterable) | |
while True: | |
try: # Try get the first element in the iterator... | |
head = (next(iterator),) | |
except StopIteration: |
#define _GNU_SOURCE | |
#include <errno.h> | |
#include <sched.h> | |
#include <signal.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/mount.h> | |
#include <sys/stat.h> | |
#include <sys/syscall.h> | |
#include <sys/types.h> |
#!/usr/bin/env bash | |
# abort if we get any error | |
set -e | |
_tag=$1 | |
_branch="$(git rev-parse --abbrev-ref HEAD)" | |
if [ "${_tag}" == "" ]; then | |
echo "Missing version param. ex './tag_release.sh v5.1.1'" |
A non-exhaustive list of WebGL frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are outdated/not maintained anymore.
/* global createImageBitmap */ | |
function loadImageWithImageTag(src) { | |
return new Promise((resolve, reject) => { | |
const img = new Image; | |
img.crossOrigin = ''; | |
img.src = src; | |
img.onload = () => { resolve(img); }; | |
img.onerror = () => { reject(img); }; | |
}); |