Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

require "try-catch"
try {
function()
error('oops')
end,
catch {
function(error)
print('caught error: ' .. error)
@worldmind
worldmind / gist:2724846
Created May 18, 2012 11:47
Perl $SIG{CHLD} handler
# see http://perldoc.perl.org/perlipc.html#Signals
# http://www.calpoly.edu/cgi-bin/man-cgi?wait+2
# and Perl Cookbook, part 16.19. Avoiding Zombie Processes
sub REAPER {
local ($!, $?);
while ( (my $pid = waitpid(-1, WNOHANG)) > 0 ) {
say "Process $pid send CHLD with status $?";
if ( WIFEXITED($?) or WIFSIGNALED($?) ) {
if ( $kids{$pid} ) {
@jboner
jboner / latency.txt
Last active April 22, 2024 15:20
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@jkstill
jkstill / proc_net_tcp_decode
Last active April 17, 2024 07:03
decode entries in /proc/net/tcp
Decoding the data in /proc/net/tcp:
Linux 5.x /proc/net/tcp
Linux 6.x /proc/PID/net/tcp
Given a socket:
$ ls -l /proc/24784/fd/11
lrwx------ 1 jkstill dba 64 Dec 4 16:22 /proc/24784/fd/11 -> socket:[15907701]
@panzi
panzi / portable_endian.h
Last active April 18, 2024 20:59
This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, Mac OS X, and QNX. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh. License: I hereby put …
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
@jeffreykegler
jeffreykegler / kv_extend.pl
Created March 11, 2014 02:29
Hypothetical extension to Perl 5's hash initialization
use 5.010;
use strict;
use warnings;
use Data::Dumper;
use Marpa::R2 2.082000;
my $input = <<'END_OF_STRING';
{
name => 'test hash 1',
@Bonno
Bonno / create-ssl-cert
Created July 6, 2015 08:33
generate x509 SHA256 hash self-signed certificate using OpenSSL
openssl req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout example.com.crt -out example.com.crt
# Check cerificate
openssl x509 -noout -text -in example.com.crt
@NikolayS
NikolayS / abstracts_writings.md
Last active July 15, 2021 13:02
Как написать хорошие тезисы для доклада на конференции

Рекомендации для докладов типа Case Study (компания/проект делится своим опытом)

Недостаточно просто описать задачу в тезисах. Довольно часто бывает так, что заинтересованные слушатели могут это сделать не хуже докладчика. Хорошие же тезисы отличает конкретика: конкретные названия, конкретные числовые показатели (последнее особенно важно для Highload++).

Главное — приоткрыть суть вашего доклада, оставаясь при этом в рамках сжатых тезисов.

И это не так сложно. При подготовке доклада и его тезисов нужно сделать всего лишь три шага.

@oshliaer
oshliaer / .ru.md
Last active July 16, 2019 10:46
oshlibot

oshlibot

  • Как вызвать бота? В Telegram ник @oshlibot

  • Как запустить своего бота? Скопировать код. Получить [apikey][BotFather link]. Добавить apikey в свойства скрипта. Опубликовать скрипт как веб-приложение для всех. Запустить вручную setWebhook() из модуля ScriptService.gs

  • Важно. В настройках необходимо в свойства скрипта добавить apikey

  • Как получить apikey? Необходимо спросить у [@BotFather][BotFather link]

  • Какие бывают способы доступа для бота? Два метода API определяют будущее поведение приложения: [getUpdates][getUpdates link] или [setWebhook][setWebhook link]

  • @oshlibot использует подписку на [Webhooks][setWebhook link]

@eyecatchup
eyecatchup / git-commit-log-stats.md
Last active April 12, 2024 14:50
Some commands to get git commit log statistics for a repository on the command line.

git commit stats

Commands to get commit statistics for a Git repository from the command line -
using git log, git shortlog and friends.