Skip to content

Instantly share code, notes, and snippets.

View YouSysAdmin's full-sized avatar
🤪

Oleksii Samoliuk YouSysAdmin

🤪
View GitHub Profile

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@YouSysAdmin
YouSysAdmin / travis.rb
Created February 8, 2015 14:40
Get Travis-CI status
require 'open-uri'
require 'string_color'
xml_data = open('https://api.travis-ci.org/repos/POStroi/EveOnlineItemParse/cc.xml').read
status = xml_data.scan(%r{lastBuildStatus="(.*)"})[0][0]
case status
when 'Success'
puts 'Ok'.green
when 'Failure'
puts 'Not Ok'.red
@YouSysAdmin
YouSysAdmin / scan.rb
Last active October 30, 2015 07:37
Async network scanner
#!/usr/bin/env ruby
# gem install celluloid net-ping
require 'celluloid/current'
require 'net/ping'
require 'ipaddr'
class ScanPort
include Celluloid
def scan host, port
@YouSysAdmin
YouSysAdmin / ogv2gif.sh
Created October 21, 2015 12:33
Convert OGV to GIF
mplayer -ao null out.ogv -vo jpeg:outdir=output
convert output/* output.gif
convert output.gif -fuzz 10% -layers Optimize optimised.gif
// config/initializers/appconfig.rb
APP_CONFIG = YAML.load_file(Rails.root.join('config/app_config.yml'))[Rails.env]
package main
import (
"fmt"
"net/http"
"github.com/julienschmidt/httprouter"
)
func main() {
@YouSysAdmin
YouSysAdmin / postgresql_cron_env.sh
Created August 26, 2019 14:26
execute SQL query from cron
# .cron_env
# Save to /root directory, chmod 400/600
export DB_HOST="127.0.0.1"
export DB_USER="postgres"
export DB_PASSWORD="postgres"
# cron
59 23 * * * . /root/.cron_env; /usr/bin/psql_super_puper.sh $DB_USER $DB_PASSWORD $DB_HOST "select * from ololo"
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
@YouSysAdmin
YouSysAdmin / run-before-shutdown.service
Created October 28, 2020 07:54
Systemd - Run before shutdown/reboot
# systemd unit file
# /etc/systemd/system/run-before-shutdown.service
# TimeoutStartSec - set a timeout for your task or set "0" to disable.
# When the timeout is turned off and the task "hangs",
# the process will never be interrupted and the system
# shutdown will stop
# Before - Specify the services before which the task should run
# after add unit file in systemd/system catalogue, "run systemctl daemon-reload"
# and enable new service "systemctl enable run-before-shutdown.service"
@YouSysAdmin
YouSysAdmin / remove_old_builds.sql
Created March 28, 2021 07:34 — forked from david-zw-liu/remove_old_builds.sql
Keep 1000 builds per repos for DroneCI (sqlite3 version >= 3.25 required)
-- Thank @sbengo to figure out foreign_keys constraints is defaults to false in sqlite
-- Enable to delete logs by cascading delete
PRAGMA foreign_keys = ON;
WITH n_build_ids_per_repo as (
SELECT build_id
FROM (
SELECT
build_id,
build_repo_id,