Skip to content

Instantly share code, notes, and snippets.

View vodolaz095's full-sized avatar

Остроумов Анатолий vodolaz095

View GitHub Profile
@vodolaz095
vodolaz095 / decodeViberMessages.sh
Created September 10, 2016 17:42
Decode viber messages
#!/bin/bash
unzip Viber\ messages.zip
find . -name "*.CSV" -exec iconv -c -f UCS-2 -t UTF-8 {} -o {}.txt \;
@vodolaz095
vodolaz095 / print.js
Last active August 30, 2023 20:47
Print for NodeJS using CUPS backend
var ipp = require('ipp'); //get it from there - https://npmjs.org/package/ipp - $npm install ipp
var request = require('request'); //get it from there - https://npmjs.org/package/request - $npm install request
var fs = require('fs');
function getPrinterUrls(callback) {
var CUPSurl = 'http://localhost:631/printers';//todo - change of you have CUPS running on other host
request(CUPSurl, function (error, response, body) {
if (!error && response.statusCode == 200) {
var printersMatches = body.match(/<TR><TD><A HREF="\/printers\/([a-zA-Z0-9-^"]+)">/gm);//i know, this is terrible, sorry(
var printersUrls = [];
@vodolaz095
vodolaz095 / watchdog.sh
Last active November 20, 2022 12:59
watchdog.sh script for checking server running not mine, i stole it)
#!/bin/bash
# Service watchdog script
# Put in crontab to automatially restart services (and optionally email you) if they die for some reason.
# Note: You need to run this as root otherwise you won't be able to restart services.
#
# Example crontab usage:
#
# Strict check for apache2 service every 5 minutes, pipe results to /dev/null
# */5 * * * * sh /root/watchdog.sh apache2 "" > /dev/null
#
@vodolaz095
vodolaz095 / strings_test.go
Last active June 26, 2022 21:29
golang benchmark of string concatenation
package strings
import (
"bytes"
"fmt"
"os"
"strings"
"testing"
)
@vodolaz095
vodolaz095 / NumberOfTheWeekInMonth.go
Created February 19, 2016 15:33
Get the number of the week in Golang
package main
import(
"fmt"
"time"
)
func NumberOfTheWeekInMonth(now time.Time) int {
beginningOfTheMonth := time.Date(now.Year(), now.Month(), 1, 1, 1, 1, 1, time.UTC)
_, thisWeek := now.ISOWeek()
@vodolaz095
vodolaz095 / install.sh
Last active January 31, 2021 10:00
Little script to help me installing Fedora 32 linux on my home PCs (comment lines you do not need)
#!/bin/sh
echo "Start SSHD service"
systemctl enable sshd
systemctl start sshd
echo "Remove junky programs i hate"
dnf -y remove clipit asunder gnomebaker lxmusic gnumeric osmo pidgin xpad
echo "Upgrade system"
@vodolaz095
vodolaz095 / clearDockerCache.sh
Created December 8, 2015 20:25
Single command to clear docker containers and cache
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@vodolaz095
vodolaz095 / install.sh
Created December 15, 2018 13:47
basicFedoraSetup4Development.sh
#!/usr/bin/env bash
# upgrade system
su -c 'dnf upgrade -y'
# install extra repos
su -c 'dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm'
su -c 'dnf install -y https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'
su -c 'dnf upgrade -y rpmfusion-free-release rpmfusion-nonfree-release'
@vodolaz095
vodolaz095 / screenshot
Created November 18, 2018 08:02
screenshot - shell script to make and upload screenshot
#!/bin/bash
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 9 | head -n 1)
PIC_URL=$HOME/Pictures/Screenshots/$NEW_UUID.png
mkdir -p $HOME/Pictures/Screenshots
scrot -s -c $PIC_URL
scp $PIC_URL holod.local:/srv/www/s/
+ check_common_commands http://example.com
+ '[' 1 -gt 0 ']'
+ parm=http://example.com
+ shift
+ case "$parm" in
+ '[' 0 -gt 0 ']'
+ '[' -z '' ']'
+ unset XDG_UTILS_DEBUG_LEVEL
+ '[' 0 -lt 1 ']'
+ xdg_redirect_output=' > /dev/null 2> /dev/null'