Skip to content

Instantly share code, notes, and snippets.

🌤
The sun is behind every cloud

Fedir RYKHTIK fedir

🌤
The sun is behind every cloud
  • Stratis
  • Toulon, France
Block or report user

Report or block fedir

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fedir
fedir / pdf_compress.sh
Last active Oct 8, 2019
PDF compression with gs (works well on Linux Mint)
View pdf_compress.sh
# Compressing to EBook quality (between "screen" and "preprocess")
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
# Black and white output, with custom resolution
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dCompressFonts=true -r150 -dNOPAUSE -dQUIET -dBATCH -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -sOutputFile=output.pdf input.pdf
@fedir
fedir / result_check.md
Last active Mar 28, 2019
Install WKHTMLTOPDF / WKHTMLTOX on CentOS
View result_check.md

Installation verification

Bad

$ wkhtmltopdf https://www.google.fr output.pdf
Loading pages (1/5)
Error: Failed loading page https://www.google.fr (sometimes it will work just to ignore this error with --ignore-load-errors)

Good

@fedir
fedir / dd_dsync_check.sh
Last active Mar 21, 2019
Disk performance check with dd dsync (synchronized I/O for data)
View dd_dsync_check.sh
#!/bin/bash
# Small files (64KB)
dd if=/dev/zero of=./dsync64KB.img bs=64 count=1000 oflag=dsync 2>&1|tee dsync-test-1-64KB.log
# Medium files (8MB)
dd if=/dev/zero of=./dsync8MB.img bs=8k count=1000 oflag=dsync 2>&1|tee dsync-test-2-8MB.log
# Big files (128MB)
dd if=/dev/zero of=./dsync128MB.img bs=128k count=1000 oflag=dsync 2>&1|tee dsync-test-3-128MB.log
@fedir
fedir / slice_filtering.go
Last active Mar 13, 2019
golang > the fastest version of a slice of structs filtering will be a recreation of new slice of structs
View slice_filtering.go
// ref. https://pauladamsmith.com/blog/2016/07/go-modify-slice-iteration.html
y := x[:0]
for _, n := range x {
if n.property !=42 {
y = append(y, n)
}
}
// If some further sorting should be done, requires Go 1.8+
// https://stackoverflow.com/a/42872183/634275
@fedir
fedir / go_imagemagickgo_pdf.md
Last active Mar 8, 2019
Go > ImageMagick & JPG2PDF on Debian / Ubuntu
View go_imagemagickgo_pdf.md

Go > ImageMagick & JPG2PDF on Debian / Ubuntu

Installation

sudo apt-get install libmagickwand-dev
go get -u gopkg.in/gographics/imagick.v2/imagick

Additional ressources

@fedir
fedir / fix_mysql_too_many_fiels.md
Created Mar 8, 2019
Fix MySQL "[ERROR] Error in accept: Too many open files" on start on Debian
View fix_mysql_too_many_fiels.md

Fix MySQL "[ERROR] Error in accept: Too many open files" on start

Check system limtis

cat /proc/$(cat /var/run/mysqld/mysqld.pid)/limits

Update system limits

$ vim /etc/security/limits.conf
@fedir
fedir / iptables_route_ports.md
Created Mar 7, 2019
iptables routes port 80 to 4000
View iptables_route_ports.md

iptables port routing from 80 to 4000

Configuration

Route via iptables

$ iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 4000

Make it persistent (on Debian, Ubuntu)

@fedir
fedir / argon2i.php
Last active Feb 21, 2019
PHP Argon2i test
View argon2i.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo password_hash("test", PASSWORD_ARGON2I) . "\n";
// expected output:
// $argon2i$v=19$m=1024,t=2,p=2$Si9YUTV5Mk50clRPckJmNg$iiaHUvfJpx2fwVJLUDr2J0XePR31gxxIu5VHlgFMA/k
View history.sh
git clone https://github.com/GoogleCloudPlatform/kubernetes-engine-samples
cd kubernetes-engine-samples/hello-app
cat main.go
cat Dockerfile
gcloud container clusters get-credentials <;cluster-name> \
gcloud container clusters get-credentials cluster-1 --zone europe-west1
docker build -t gcr.io/meeetup-golang-marseille-03/hello-node:v1 $PWD
gcloud docker -- push gcr.io/meetup-golang-marseille-03/hello-node:v1
kubectl run hello-node --image=gcr.io/meetup-golang-marseille-03/hello-node:v1 --port=8080
kubectl expose deployment hello-node --type="LoadBalancer"
View README.md

Open Weather API call

Installation procedure

  • Create scripts
  • Define CITY_ID and APP_ID in each script
  • Add scritps into the crontab

Crontab

You can’t perform that action at this time.