Skip to content

Instantly share code, notes, and snippets.

View Gyvastis's full-sized avatar

Vaidas Bagdonas Gyvastis

View GitHub Profile
@Gyvastis
Gyvastis / removeduplicatevertice.js
Created March 9, 2023 09:47 — forked from tyohan/removeduplicatevertice.js
Remove duplicate vertice on mongodb geojson collection
#!/usr/bin/env node
var path=require('path');
var fs = require('fs');
if(process.argv.length<3)
throw new Error('You\'re not passing the geojson file');
var file=process.argv[2];
var gjFile=fs.statSync(file);
if(!gjFile.isFile())
throw new Error('File not found');

How to setup a practically free CDN

I've been using [Backblaze][bbz] for a while now as my online backup service. I have used a few others in the past. None were particularly satisfactory until Backblaze came along.

It was - still is - keenly priced at a flat $5 (£4) per month for unlimited backup (I've currently got just under half a terabyte backed-up). It has a fast, reliable client. The company itself is [transparent about their operations][trans] and [generous with their knowledge sharing][blog]. To me, this says they understand their customers well. I've never had reliability problems and everything about the outfit exudes a sense of simple, quick, solid quality. The service has even saved the day on a couple of occasions where I've lost files.

Safe to say, I'm a happy customer. If you're not already using Backblaze, [I highly recommend you do][recommend].

Taking on the big boys with B2

@Gyvastis
Gyvastis / php_enum_as_class.php
Last active May 5, 2021 13:06
PHP Enum as Class
<?php
namespace Earth;
class Enum {
protected string $constName;
public function __construct(string $constName) {
$this->constName = $constName;
}
@Gyvastis
Gyvastis / phpstorm_evaluation_license_reset.md
Last active May 3, 2024 23:57
PhpStorm reset evaluation license/period

PhpStorm reset evaluation license/period

Make sure to export/import your settings through File -> Manage IDE settings before/after

Windows 10

  1. Close PHPStorm
  2. Run these in PowerShell to remove PhpStorm configuration:
Remove-Item '.\AppData\Local\Jetbrains\PhpStorm*'
Remove-Item '.\AppData\Roaming\Jetbrains\PhpStorm*'
@Gyvastis
Gyvastis / visa_free_days_left.php
Last active March 4, 2021 19:42
visa 90 days in 180 days calculator
<?php
$visitDates = [
['2020-06-16', '2020-06-30'],
['2020-07-23', '2020-07-28'],
['2020-10-09', '2020-11-04'],
['2020-12-15', '2021-01-16'],
['2021-01-30', '2021-02-26'],
];
@Gyvastis
Gyvastis / gist:036398f6d773c1d68563f9f2cc95cede
Created November 19, 2020 14:59
php currency enumerable
<?php
final class CurrencyEnum extends BaseEnumerable
{
public const ALL = 'ALL';
public const AFN = 'AFN';
public const ARS = 'ARS';
public const AWG = 'AWG';
public const AUD = 'AUD';
public const AZN = 'AZN';
@Gyvastis
Gyvastis / translate.js
Created October 28, 2020 08:53
Bing translate
const translate = text => fetch("https://www.bing.com/ttranslatev3", {
"headers": {
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
"content-type": "application/x-www-form-urlencoded",
},
"body": `&fromLang=nb&text=${encodeURIComponent(text)}&to=en`,
"method": "POST",
"mode": "cors"
})
.then(response => response.json())
@Gyvastis
Gyvastis / test.go
Created October 22, 2020 11:09
golang testify return on consecutive calls
func() {
consecutive := -1
responseMocks := []string{
responseString1,
responseString2,
}
httpClientMock.On("SendRequest", req).Return(func() *http.Response {
consecutive++
return &http.Response{
StatusCode: 200,
@Gyvastis
Gyvastis / gist:4ba63fa9b0d80973c677a48d7b52e4ee
Created October 14, 2020 10:15
JSON country codes and country names list
{
"AF": "Afghanistan",
"AX": "Åland Islands",
"AL": "Albania",
"DZ": "Algeria",
"AS": "American Samoa",
"AD": "Andorra",
"AO": "Angola",
"AI": "Anguilla",
"AQ": "Antarctica",
@Gyvastis
Gyvastis / zipcode.go
Last active October 14, 2020 10:01
Global ZipCode regexes
package helpers
import (
"errors"
"fmt"
"regexp"
)
type ZipCode struct{}