Skip to content

Instantly share code, notes, and snippets.

View 421p's full-sized avatar
🖥️
supervising daemons

Andrii B. 421p

🖥️
supervising daemons
View GitHub Profile
@421p
421p / tg-forwarder.php
Last active January 12, 2019 13:38
Script for pulling telegram bot updates and forwarding to your webhook.
#!/usr/bin/env php
<?php
class Forwarder
{
private $offset = 0;
private $limit = 100;
private $timeout = 120;
private $botToken;
private $webHook;
<?php
final class Days
{
const MONDAY = 1;
const TUESDAY = 2;
const WEDNESDAY = 3;
const THURSDAY = 4;
const FRIDAY = 5;
const SATURDAY = 6;
@421p
421p / wpa_supplicant.conf
Created October 14, 2018 07:56
Useful for raspbian headless setup
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="your_real_wifi_ssid"
scan_ssid=1
psk="your_real_password"
key_mgmt=WPA-PSK
}
@421p
421p / install_nano.sh
Last active July 5, 2018 11:11
Compilling nano text editor from source
#! /usr/bin/env bash
sudo apt-get install -y libncursesw5-dev autopoint texinfo autoconf dh-autoconf
cd /tmp
git clone git://git.savannah.gnu.org/nano.git
cd nano
./autogen.sh
./configure
sudo make install
@421p
421p / Executor.php
Created June 20, 2018 20:15
pthreads-reactphp
<?php
use IainConnor\ComposerPthreads\AutoloadWorker;
use IainConnor\ComposerPthreads\ResponseDataBundle;
use Pool;
use React\EventLoop\LoopInterface;
use React\Promise\Deferred;
use React\Promise\PromiseInterface;
class Executor
@421p
421p / docker-compose.yml
Created September 18, 2017 20:23 — forked from huksley/docker-compose.yml
Launches fully configured Graylog 2.3.1 instance
#
# Launches configured Graylog 2.3.1 instance
#
# - Docker-compose 1.16 required
# - Please configure following according to your network:
# * gelf-address URL (for each container)
# * GRAYLOG_WEB_ENDPOINT_URI
# - After launch define GELF tcp and GELF udp inputs in graylog web ui
# - Containers send logging to the graylog itself
# - By default tuned to 30 days retention
@421p
421p / memoize.ts
Last active June 12, 2022 22:21
Lazy / Memoize decorator for TypeScript's getter
export function memoize(target: any, prop: string, descriptor: PropertyDescriptor)
{
let original = descriptor.get;
descriptor.get = function (...args: any[])
{
const privateProp = `__memoized_${prop}`;
if (!this.hasOwnProperty(privateProp)) {
Object.defineProperty(this, privateProp, {
@421p
421p / json_minify.php
Created January 2, 2017 01:38
minify json
#!/usr/bin/env php
<?php
file_put_contents($argv[1], json_encode(json_decode(file_get_contents($argv[1]), true)));
@421p
421p / boost_asio_http_request.cxx
Created January 1, 2017 23:27
boost::asio http request
// url should always match template: host/path
std::string url_get_contents(std::string url)
{
using namespace boost::asio;
ip::tcp::iostream stream;
auto tokens = explode("/", url);
auto host = tokens[0];
auto request = tokens[1];
@421p
421p / gcc.bash
Created January 1, 2017 15:32
gcc 6 on ubuntu
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update && \
sudo apt-get install gcc-snapshot -y && \
sudo apt-get update && \
sudo apt-get install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5;