Skip to content

Instantly share code, notes, and snippets.

@quant61
quant61 / call_nil_func.go
Last active January 15, 2023 19:48
Allocating on zero example
package main
import (
"fmt"
"golang.org/x/sys/unix"
)
func main(){
_, _, e := unix.Syscall6(
unix.SYS_MMAP,
@quant61
quant61 / description.txt
Last active December 14, 2022 06:04
scenario about git branches
A case where switching branches doesn't work as expected.
In my case pushing to dev was prevented by gitlab,
but someone can accidentally push things to master/main while thinking they are pushing to feature branch
@quant61
quant61 / find-shm-mentions.go
Created July 17, 2022 10:40
Find processes which are using files in /dev/shm
package main
import (
"fmt"
"io/ioutil"
"os"
"strings"
)
// TODO: write it in asm
<?php
class CartesianIterator implements IteratorAggregate {
private $first;
private $second;
private $add;
public function __construct(iterable $first, iterable $second, callable $add) {
$this->first = $first;
$this->second = $second;
$this->add = $add;
@quant61
quant61 / main.md
Last active February 18, 2018 19:47
Recommended settings for international sites and services

IMHO, best settings for international sites and services are:

  • Timezone: UTC
  • Date format: YYYY-MM-DD
  • Time format: YYYY-MM-DD HH:mm:ss - 24hours, not am/pm
  • Encoding: UTF-8
  • Language: English
  • Timezone: UTC
  • Keyboard layont: En
  • Video: Original sound + English subtitles
@quant61
quant61 / gist:4dcf7cc23ad54c877b9b0556f7d7a084
Created January 28, 2018 13:58
эксперимент со слепой печатью
*скорее всего, эксперимент проводился в 2016, а текст только сейчас залил.
слепая печать
для эксперимента печатал непрерывно и с закрытыми глазами в течении 5 минут.
5 минут
1017 символов(всего)
974 не считая ентеров
@quant61
quant61 / functions.go
Last active March 4, 2021 17:16
functions
// protects from directory traversal
func safeJoin(baseDir, path string) string{
return filepath.Join(baseDir, filepath.Join("/", path))
}
func getSyscallArg(v interface{}) uintptr {
@quant61
quant61 / extensions.md
Last active February 3, 2018 16:01
msgpack extensions

some proposals of msgpack extensions

some general notes

msgpack ext value has following structure:

+--------+--------+--------+========+
|  extX  |  SIZE  |  type  |  data  |
+--------+--------+--------+========+
@quant61
quant61 / SafeNullClass.php
Created August 26, 2017 17:17
SafeNullClass.php
<?php
/**
* Created by PhpStorm.
* User: kwant
* Date: 26.08.17
* Time: 19:50
*
* attempt to create NullObject in php
* this object does nothing
@quant61
quant61 / vnode.md
Last active January 20, 2018 13:34

idea about variable inode(vnode)

it's like php's zval, but more compact and supports many types as primitives

vnode takes 16 bytes exactly 4 bytes is header 12 bytes - value

vnodes could be useful for big arrays of mixed values