Skip to content

Instantly share code, notes, and snippets.

@fospathi
fospathi / identical_errors_go.md
Last active May 5, 2024 16:15
Why are Go's identical errors not equal?

⚠️ This discussion applies to version 1.13 (released 2019) of the Go language.

Why are Go's identical errors not equal?

Or, more precisely, why are two separate but otherwise seemingly identical errors created by Go's errors.New function not equal according to the == operator?

Consider the output of the following small program (Go Playground link) which compares Go's error values for equality:

package main
@tantalor
tantalor / generator.js
Created April 20, 2011 23:43
buffering asynchronous iterator pattern
// produce: accepts a cb which is called with an array of items
// initial: initial array of results to return
// returns a function which accepts a cb which is called with one item
// each time it is called
function generator(produce, initial) {
var items;
var waiting = [];
var next = function (cb) {
if (items && items.length) {
@orion-v
orion-v / how-to.md
Last active May 5, 2024 16:14
Delete all messages of an user in a Discord channel or server

Delete discord user message history

This script allow for user specific message deletion from an entire server or a single channel using the browser console. This script uses discord search API and it will only delete messages of a chosen user.

How to use

1. Enable developer mode in discord

Go to user settings > appearance in discord and enable Developer mode.

2. Copy and paste the script to a file so you can change the server and author ids.

3. Replace the server and author ids with your own.

{"html": "line<br>break"}
@tantalor
tantalor / bliff.pl
Created March 12, 2011 03:07
Combines svn blame and diff.
#!/usr/bin/perl
use strict;
use List::Util 'max';
my ($from, $to) = @ARGV
or die "usage: $0 OLD-URL[\@OLDREV] NEW-URL[\@NEWREV]\n";
my @diff = `svn diff $from $to` or die;
my @blame = map {/^\s*(\d+)/} `svn blame $to` or die;
@Jiab77
Jiab77 / real-time-php-fpm-status.md
Last active May 5, 2024 16:13
Real-time PHP-FPM Status

Real-time PHP-FPM Status

This gist will explain you how to enable an undocumented feature of PHP-FPM which will give a real-time performance stats.

Everybody knows the famous phpinfo() and the page it generates, right? Then the real-time PHP-FPM status page design is very similar.

image

Some informations from the top are not displayed to avoid security issues.

Enable PHP-FPM Status

@masnick
masnick / gist:1654182
Created January 21, 2012 21:52
Amazon S3 bucket policy for www.maxmasnick.com
{
"Version": "2008-10-17",
"Id": "b2cc31d0-cc91-4285-a658-473099d2c867",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
@jedsundwall
jedsundwall / gist:2244379
Created March 29, 2012 22:26
hacking google spreadhseets
function makeURL(firstname,lastname) {
var name = "firstname + lastname";
if (name = null) {
return null
};
else return name;
}
@tantalor
tantalor / gist:2244383
Created March 29, 2012 22:27 — forked from jedsundwall/gist:2244379
hacking google spreadhseets
function makeURL(firstname,lastname) {
var name = firstname + lastname;
if (!name) {
return null;
} else {
return name;
}
}
@tantalor
tantalor / newcomments.pl
Created November 8, 2013 23:49
A perl script which outputs the usernames for new comments on Hacker News, preceded by the date.
#!/usr/bin/perl
my $url = "https://news.ycombinator.com/newcomments";
sub html {
`curl get $url 2>/dev/null`;
}
printf "# %s", `date`;