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 / git_global_ssh.sh
Last active May 6, 2020 09:55
Golang private repository go.mod go get
#!/bin/bash
git config \
--global \
url."git@github.com".insteadOf \
"https://github.com"
@ptflp
ptflp / fib.go
Last active January 23, 2020 23:20
fibonacci sequence golang implementation
package main
import (
"fmt"
)
func fib() func() int{
a, b := 0, 1
return func() int{
a, b = b, a+b
@ptflp
ptflp / readme.md
Last active January 23, 2020 21:37
Sizeof slice golang
[]uint8 => len: 13 bytes, cap: 24 bytes
[][]int16 => len: 24 bytes, cap: 156 bytes
[][]int32 => len: 24 bytes, cap: 24 bytes
[][]int64 => len: 24 bytes, cap: 24 bytes
[]bool => len: 13 bytes, cap: 13 bytes
[]struct {} => len: 12 bytes, cap: 12 bytes
@ptflp
ptflp / gist:695aef0ad160428d3f0995188718c3b7
Last active April 5, 2020 21:23
clone organization repos
curl -sL --user "login:pass" https://$GITHUB_AT:@api.github.com/orgs/REPO/repos?per_page=200 | jq .[].ssh_url | xargs -n 1 -P 4 git clone
@ptflp
ptflp / main.go
Created October 17, 2019 06:56
Unix tree cli
package main
import (
"errors"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
@ptflp
ptflp / reboot.go
Created August 20, 2019 11:52
Windows reboot shutdown example golang go
package main
import (
"fmt"
"syscall"
"unsafe"
)
// error is nil on success
func reboot() error {
@ptflp
ptflp / main.go
Created August 19, 2019 07:21
Check Xdebug connection on golang
package main
import (
"fmt"
"net"
"os"
)
const (
CONN_INTERFACE = "0.0.0.0"
@ptflp
ptflp / socket.php
Last active August 19, 2019 07:22
check xdebug connection on interface and port PHP
<?php
$interface = '0.0.0.0';
$port = 9000;
$sock = socket_create(AF_INET,SOCK_STREAM,0);
socket_bind($sock, $interface, $port) or die();
socket_listen($sock);
$client = socket_accept($sock);
echo "connection established: $client";
@ptflp
ptflp / main.go
Created July 25, 2019 22:56
go Golang windows reboot shutdown
package main
import (
"fmt"
"syscall"
"unsafe"
)
// error is nil on success
func reboot() error {
@ptflp
ptflp / default.conf
Created February 27, 2019 12:27
nginx php-fpm config
upstream phpfpm {
server unix:/run/php/php7.0-fpm.sock;
}
server {
set $main_path /var/www/html;
server_name localhost default;
charset utf-8;
source_charset utf-8;
listen 0.0.0.0:80 ;