Skip to content

Instantly share code, notes, and snippets.

View eSlider's full-sized avatar

Andrey Oblivantsev eSlider

View GitHub Profile
@eSlider
eSlider / Dockerfile
Created April 16, 2021 09:32
Build, make ready to run and dramatically shrink .net 5.0 lambda docker image size by using alpine
#FROM public.ecr.aws/lambda/dotnet:5.0
#
#WORKDIR /var/task
#
## This COPY command copies the .NET Lambda project's build artifacts from the host machine into the image.
## The source of the COPY should match where the .NET Lambda project publishes its build artifacts. If the Lambda function is being built
## with the AWS .NET Lambda Tooling, the `--docker-host-build-output-dir` switch controls where the .NET Lambda project
## will be built. The .NET Lambda project templates default to having `--docker-host-build-output-dir`
## set in the aws-lambda-tools-defaults.json file to "bin/Release/net5.0/linux-x64/publish".
##
package main
import (
"fmt"
"sort"
)
type Person struct {
Name string
Age int
@eSlider
eSlider / remove-duplicates.sh
Created May 2, 2020 15:10
Remote duplicates
#!/bin/bash
fdupes -rSdNI ./
@eSlider
eSlider / go-shell-script.go
Created February 27, 2020 13:19
Golang Shell Script
//usr/bin/env test -x $0 && (go build -o "${0}c" "$0" && "${0}c" $@; r=$?; rm -f "${0}c"; exit "$r"); exit "$?"
//
// The top "comment" defines shebang
// More over:
// * https://gist.github.com/posener/73ffd326d88483df6b1cb66e8ed1e0bd
// * https://getstream.io/blog/switched-python-go/
package main
import (
@eSlider
eSlider / Dockerfile
Last active December 22, 2019 14:57
Dramatically shrinking .net core 3.1 docker image publishing size
# Officia microsoft .NET SDK image
FROM mcr.microsoft.com/dotnet/core/sdk:latest AS api-build
# Set directory for build
WORKDIR /app
# Copy anything from where docker would be builded
COPY ./. ./
# Reice packages, Build and shrink as an standalone exutable file
@eSlider
eSlider / mbtiles2pbf.sh
Created September 24, 2019 13:53
Extract PBF tiles from mbtiles (SQLite)
#!/bin/sh
git clone https://github.com/mapbox/mbutil
cd mbutil
./mb-util --image_format=pbf *.mbtiles tiles
gzip -d -r -S .pbf *
find . -type f -exec mv '{}' '{}'.pbf \;
@eSlider
eSlider / spatialite_example.go
Created August 26, 2019 18:53 — forked from ptrv/spatialite_example.go
SpatiaLite example in Go
package main
import (
"database/sql"
"github.com/mattn/go-sqlite3"
"log"
"os"
)
func runQuery(db *sql.DB, query string) {
@eSlider
eSlider / get-org-name-by-host-name.sh
Created August 25, 2019 20:05
Get organisation name by hostname
#!/bin/sh
whois $(dig +short @1.1.1.1 produktor.io | head -1) | grep -Po "org-name\:\s+\K.+"
@eSlider
eSlider / stop-cpu-throttling.sh
Last active June 23, 2020 08:01
Fix broken DC cable connection and CPU throttling for HP Spectre x360
#!/bin/sh
# Determinate CPU capabilities
MAX_CPU=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq)
MIN_CPU=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq)
# Install MSR tools and Linux tools to get hack BIOS
# apt install -y msr-tools linux-tools-common linux-tools-$(uname -r)
@eSlider
eSlider / getThisFuckingObject.js
Last active July 20, 2018 22:16
Get over HTTPS
/**
* Get this fucking object
*
* @param {String} url URL я для http не учитывал
* @param {Function} onData(data) колбэк когда всё норм, будет вызван с уже готовым объектом
* @return {*}
*/
function getThisFuckingJsonObject(url, onData) {
let chunks = [];
return require('https').get(url, res => {