Skip to content

Instantly share code, notes, and snippets.

View ptflp's full-sized avatar
🤟
Quality over quantity?

Petr Filippov ptflp

🤟
Quality over quantity?
View GitHub Profile
@ptflp
ptflp / main.go
Created August 19, 2021 07:00
int64 representation in bytes
package main
import (
"fmt"
"unsafe"
"reflect"
)
func main() {
var n uint64 = 1 << (1 << 6) - 1
@ptflp
ptflp / docker-compose.yml
Created August 17, 2021 08:11
nodejs docker-compose
version: '3.3'
services:
frontend:
container_name: frontend_${NODE_ENV}
image: node:14-stretch
command: npm run start
restart: always
working_dir: /app
environment:
- VIRTUAL_HOST=${ENDPOINT}
@ptflp
ptflp / WSL2GUIXvnc-en.md
Created February 8, 2021 01:13 — forked from tdcosta100/WSL2GUIXvnc-en.md
A tutorial to use GUI in WSL2 replacing original XServer by Xvnc, allowing WSL to work like native Linux, including login screen

WSL2 with GUI using Xvnc

In this tutorial, we will setup GUI in WSL2, and access it using VNC. No additional software outside WSL (like VcXsrv) is required, except, of course, a VNC Viewer (RealVNC, TightVNC, TigerVNC, UVNC, etc, all of them might work flawlessly).

The key components we need to install are tigervnc-standalone-server and systemd-genie.

For this setup, I will use Ubuntu 20.04 LTS (Focal Fossa), and install GNOME Desktop. Since the key components aren't bound to Ubuntu or GNOME, you can use your favorite distro and GUI. Check the Sample screenshots section for examples.

So let's go. First, we need a working [WSL2](https://docs.microsoft.com/pt-br/windows/wsl/w

@ptflp
ptflp / main.go
Last active December 4, 2020 15:18
Linux tree command, realized on golang (Draft)
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
)
@ptflp
ptflp / main.go
Last active May 10, 2022 20:44
Manual webserver golang
package main
import (
"bufio"
"fmt"
"net"
)
func main() {
l, err := net.Listen("tcp", ":8888")
@ptflp
ptflp / main.go
Created April 5, 2020 21:21
Upload file through telegram bot to chat id
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
@ptflp
ptflp / Dockerfile
Created March 23, 2020 23:59
Safe non root user container execution
FROM php:7.2-fpm
# Copy composer.lock and composer.json
# COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
@ptflp
ptflp / README.md
Last active March 23, 2020 18:49
Fast create OpenVPN server

Firstly

export OVPN_DATA="ovpn-data"

then

chmod +x ./startserver.sh
./startserver.sh
@ptflp
ptflp / main.go
Created January 31, 2020 13:16
Golang Fibonacci on channels
package main
import "fmt"
func fibonacci(out chan uint, quit chan struct{}) {
var x, y uint
x, y = 0, 1
for {
select {
case out <- x:
@ptflp
ptflp / finger.sh
Created January 27, 2020 13:42
Add fingerprint of github.com automatically by bash script
#!/bin/bash
echo "Applying fingerprint"
ssh-keygen -F github.com || ssh-keyscan github.com >>~/.ssh/known_hosts