Skip to content

Instantly share code, notes, and snippets.

View adzeitor's full-sized avatar
🦇

Aleksandr Voikov adzeitor

🦇
  • Tomoko combinator
  • Novi Sad
View GitHub Profile
@adzeitor
adzeitor / factorio-server-guide.md
Last active April 16, 2023 05:40
Run (very slow) factorio headless server (or other x86 binary) on Ubiquiti EdgeRouter ER-4, ER-12
Requirements

Needed mips packages:

$ curl -L curl -L http://ftp.us.debian.org/debian/pool/main/q/qemu/qemu-user-static_3.1+dfsg-8+deb10u8_mips.deb \
 -o qemu-user-static_3.1+dfsg-8+deb10u8_mips.deb \
@adzeitor
adzeitor / govet_equaltime.go
Created January 16, 2020 15:54
govet utility finds comparing time.Time and time.Time throught `==` instead of `.Equal`
package equaltime
import (
"go/ast"
"go/token"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
)
@adzeitor
adzeitor / mysql_copy_database.php
Last active February 9, 2018 20:22
PHP Copy mysql database from one host to another
<?php
function copy_database($source, $destinations) {
$temp_prefix = "_TMP_";
$tables = [];
$tables_res = $source->query("SHOW TABLES") or die($source->error);
while ($row = $tables_res->fetch_row()) {
$table_name = $row[0];
$temp_table = $temp_prefix . $table_name;
import unittest
class StrRangeTest(unittest.TestCase):
tests = [
("1-5", ["1", "2", "3", "4", "5"]),
("01-05", ["01", "02", "03", "04", "05"]),
("000-001", ["000", "001"]),
(" 1 - 2 ", ["1", "2"]),
("", [])
]
package main
import (
"fmt"
"log"
"net/http"
"runtime"
"sync"
)
package main
import (
"fmt"
"runtime"
"time"
"sync"
)
fetch("https://gist.githubusercontent.com/adzeitor/0777c61a27a377828fc5764ff2db1f82/raw/d4366172e79802c2ecb1e3ccf01c2e2155038ded/fizzbuzz.json")
.then(x => x.json())
.then(list => list.forEach(x => console.log(x)))
package main
import (
"encoding/xml"
"fmt"
"golang.org/x/net/html/charset"
"io"
"log"
"net/http"
"os"
package main
import (
"net"
"log"
"os/exec"
"bufio"
"os"
"strings"
)
@adzeitor
adzeitor / subscription.php
Last active September 28, 2016 14:38
Send document after confirm email (sqlite, php). Shared hosting compatible.
<?php
$SCRIPTURL="http://example.com/subscription.php";
function generateSecret() {
return md5(uniqid(rand(), TRUE));
}
class Subscription
{