Skip to content

Instantly share code, notes, and snippets.

View slav123's full-sized avatar

Slawomir Jasinski slav123

View GitHub Profile
@slav123
slav123 / twoSum.php
Created April 24, 2020 10:29
twoSum.php
<?php
function twoSum($nums, $target) {
for($a = 0, $max = count($nums);$a < $max-1; $a++) {
$looking = $target - $nums[$a];
$where = array_slice($nums, $a+1);
@slav123
slav123 / main.go
Created March 16, 2020 11:22
import gnaf
package main
import (
"database/sql"
"encoding/csv"
"flag"
_ "github.com/go-sql-driver/mysql"
"io"
"log"
"os"
@slav123
slav123 / address_helper.php
Last active March 13, 2020 08:11
australia address parser based on js library - DEV
<?php
if ( ! function_exists('parse_address'))
{
// https://github.com/gordonlkc/autralia-address-parser/blob/master/parser.js
/**
* match state
@slav123
slav123 / sanitze.go
Created February 18, 2020 12:43
remove accents in go
package sanitze
import (
"bytes"
)
var transliterations = map[rune]string{'\u0041': "A", '\u24B6': "A", '\uFF21': "A", '\u00C0': "A", '\u00C1': "A", '\u00C2': "A", '\u1EA6': "A", '\u1EA4': "A", '\u1EAA': "A", '\u1EA8': "A",
'\u00C3': "A", '\u0100': "A", '\u0102': "A", '\u1EB0': "A", '\u1EAE': "A", '\u1EB4': "A", '\u1EB2': "A", '\u0226': "A", '\u01E0': "A", '\u00C4': "A",
'\u01DE': "A", '\u1EA2': "A", '\u00C5': "A", '\u01FA': "A", '\u01CD': "A", '\u0200': "A", '\u0202': "A", '\u1EA0': "A", '\u1EAC': "A", '\u1EB6': "A",
'\u1E00': "A", '\u0104': "A", '\u023A': "A", '\u2C6F': "A", '\uA732': "AA", '\u00C6': "AE", '\u01FC': "AE", '\u01E2': "AE", '\uA734': "AO", '\uA736': "AU",
@slav123
slav123 / main.go
Created February 18, 2020 11:58
text normalization in golang (remove accents from string_
package main
import (
"fmt"
"unicode"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)
@slav123
slav123 / strings_builder.go
Created February 12, 2020 08:38
strings manipulation in go
package main
import (
"strings"
"fmt"
)
func main() {
var str strings.Builder
@slav123
slav123 / null.php
Last active August 13, 2019 15:30
Null coalescing operator
<?php
// Fetches the value of $_GET['user'] and returns 'nobody'
// if it does not exist.
$username = $_GET['user'] ?? 'nobody';
// This is equivalent to:
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
// Coalescing can be chained: this will return the first
// defined value out of $_GET['user'], $_POST['user'], and
@slav123
slav123 / go-install.sh
Last active July 10, 2019 09:55 — forked from mlabouardy/go-install.sh
Setup Go environment variables
# GOROOT is the location where Go package is installed on your system
export GOROOT=/usr/lib/golang
# GOPATH is the location of your work directory
export GOPATH=$HOME/go
# PATH in order to access go binary system wide
export PATH=$PATH:$GOROOT/bin
@slav123
slav123 / sub.go
Created May 29, 2019 16:22
AWS SNS SubscriptionConfirmation
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
const subConfrmType = "SubscriptionConfirmation"
@slav123
slav123 / keylock.ino
Created March 6, 2019 08:35
Arduino double relay keypad lock
#include <Keypad.h>
#define PasswordLength 5
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','2','3', 'A'},
{'4','5','6', 'B'},
{'7','8','9', 'C'},