Skip to content

Instantly share code, notes, and snippets.

Slawomir Jasinski slav123

View GitHub Profile
@slav123
slav123 / distance.sql
Created Jun 9, 2020
distance-km-sql.sql
View distance.sql
(6371 * acos ( cos ( radians(' . $address['latitude'] . ') ) * cos( radians( clients.latitude ) ) * cos( radians( clients.longitude ) - radians(' . $address['longitude'] . ') ) + sin ( radians(' . $address['latitude'] . ') ) * sin( radians( clients.latitude ) ) ) ) AS distance_adv'
View ST_Distance_Sphere.sql
DELIMITER //
CREATE FUNCTION `GCDistDeg`(
_lat1 DOUBLE,
_lon1 DOUBLE,
_lat2 DOUBLE,
_lon2 DOUBLE
) RETURNS double
DETERMINISTIC
SQL SECURITY INVOKER
COMMENT 'Degrees in, Degrees out. For conversion: 69.172 mi/deg or 111.325 km/deg'
@slav123
slav123 / threeSum.php
Created Apr 26, 2020
threeSum optimised
View threeSum.php
<?php
class Solution {
/**
* @param Integer[] $nums
* @return Integer[][]
*/
function threeSum($nums) {
$results = [];
$max = count($nums);
@slav123
slav123 / threeSum.php
Last active Apr 26, 2020
threes sum brutforce
View threeSum.php
<?php
function threeSum($nums) {
$results = [];
$max=count($nums);
sort($nums);
print_r($nums);
for ($a = 0;$a < $max;$a++) {
View 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);
View main.go
package main
import (
"database/sql"
"encoding/csv"
"flag"
_ "github.com/go-sql-driver/mysql"
"io"
"log"
"os"
@slav123
slav123 / address_helper.php
Last active Mar 13, 2020
australia address parser based on js library - DEV
View address_helper.php
<?php
if ( ! function_exists('parse_address'))
{
// https://github.com/gordonlkc/autralia-address-parser/blob/master/parser.js
/**
* match state
@slav123
slav123 / sanitze.go
Created Feb 18, 2020
remove accents in go
View sanitze.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 Feb 18, 2020
text normalization in golang (remove accents from string_
View main.go
package main
import (
"fmt"
"unicode"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)
@slav123
slav123 / strings_builder.go
Created Feb 12, 2020
strings manipulation in go
View strings_builder.go
package main
import (
"strings"
"fmt"
)
func main() {
var str strings.Builder
You can’t perform that action at this time.