Skip to content

Instantly share code, notes, and snippets.

View sergeyklay's full-sized avatar
🇺🇦

Serghei Iakovlev sergeyklay

🇺🇦
View GitHub Profile
@sergeyklay
sergeyklay / rpn.kt
Last active May 30, 2020 09:17
Reverse Polish Notation
import java.util.Stack
import java.lang.Long.parseLong
fun String.isNumeric(): Boolean {
return try {
parseLong(this)
true
} catch (e: NumberFormatException) {
false
}
@sergeyklay
sergeyklay / get_phalcon_events.sh
Last active September 15, 2020 12:26
Phalcon : Get list of all events from source
$ pwd
/home/klay/projects/c/cphalcon
$ git branch
2.0.0
* 2.0.x
master
$ php --ri phalcon | grep 'Version =>'
@sergeyklay
sergeyklay / install.sh
Last active October 18, 2020 11:03
Install Nginx with Nchan
#!/usr/bin/env bash
# Works fine on Ubuntu 14.0.4 LTS
NGINX_VERSION="1.9.9"
NCHAN_VERSION="0.97"
HEADERS_MORE_VERSION="0.29"
DEV_KIT_VERSION="0.2.19"
ECHO_VERSION="0.58"
FANCY_INDEX_VERSION="0.3.5"

My Personal WeeChat Cheat Sheet

Requirements

You need at least WeeChat 3.2-dev

Install

Ubuntu/Debian

@sergeyklay
sergeyklay / pyenv-install.md
Last active July 4, 2021 13:04
Multiple Python versions using pyenv and python-build

Multiple Python versions using pyenv and python-build

Installation

Install pyenv

git clone git@github.com:pyenv/pyenv.git ~/.pyenv
cd ~/.pyenv && src/configure && make -C src
@sergeyklay
sergeyklay / no-omit-frame-pointer.md
Last active July 6, 2021 10:57
GCC/Clang -fno-omit-frame-pointer and -fsanitize=address

Description

Frame pointer omission does make debugging significantly harder. Local variables are harder to locate and stack traces are much harder to reconstruct without a frame pointer to help out. Also, accessing parameters can get more expensive since they are far away from the top of the stack and may require more expensive addressing modes.

The -fno-omit-frame-pointer option direct the compiler to generate code that maintains and uses stack frame pointer for all functions so that a debugger can still produce a stack backtrace even with optimizations flags.

Irrespective if you use the flag, not every function needs a frame pointer in the first place, so you can't always expect a difference with the flag.

Also, whether the function has a frame pointer is an implementation detail. Compilers can differ in implementation details (and usually they do).

@sergeyklay
sergeyklay / hpd.md
Last active July 15, 2021 08:36
Happy PHP Debugging

Happy PHP Debugging

Usage

gdb --args /usr/bin/php script.php
(gdb) source ~/src/php/7.2.1/.gdbinit
@sergeyklay
sergeyklay / gpg-import-and-export-instructions.md
Last active August 30, 2022 23:15 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

GPG: Import and export instructions

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Export keys and ownertrust

gpg --export --armor 1E0B5331219BEA88 > 1E0B5331219BEA88.pub.asc
gpg --export-secret-keys --armor 1E0B5331219BEA88 > 1E0B5331219BEA88.priv.asc
gpg --export-secret-subkeys --armor 1E0B5331219BEA88 > 1E0B5331219BEA88.sub_priv.asc

gpg --export-ownertrust > ownertrust.txt

package main
import (
"fmt"
"golang.org/x/net/context"
cc "golang.org/x/oauth2/clientcredentials"
"io/ioutil"
"net/http"
"os"
)
@sergeyklay
sergeyklay / phpenv-install.md
Last active March 3, 2024 10:45
Multiple PHP versions using phpenv and php-build

Multiple PHP versions using phpenv and php-build

Install dependecies

Debian/Ubuntu users

sudo apt install \
  autoconf \
  bison \