Skip to content

Instantly share code, notes, and snippets.

View ad's full-sized avatar
💎
danielapatin.ton

Daniel Apatin ad

💎
danielapatin.ton
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

@ad
ad / ems.sh
Created March 27, 2017 08:44
Tracking EMS (Russian Post) parcel
#!/bin/bash
# usage: ems.sh <tracking> <sleep_duration>
export SLEEP=60
export TRACKING=""
if [ $1 ]; then
TRACKING="$1"
else
@ad
ad / example.sql
Last active February 23, 2018 22:14
database with triggers and history example
CREATE OR REPLACE FUNCTION "json_append"(IN "data" json, IN insert_data json) RETURNS "json" AS $BODY$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)
) t;
$BODY$
LANGUAGE sql
COST 100
@ad
ad / BTT.json
Last active April 1, 2018 16:05
BetterTouchTool
{
"BTTPresetName" : "Default",
"BTTPresetUUID" : "4DA9BBE8-9392-4B6C-A22B-AAF8189CE7C1",
"BTTPresetContent" : [
{
"BTTAppBundleIdentifier" : "BT.G",
"BTTAppName" : "Global",
"BTTAppSpecificSettings" : {
},
@ad
ad / NSString+extension.swift
Created April 23, 2018 11:51
Strip json comments (singleline, multiline), respect base64 //
extension String {
func stripComments() -> String {
// ((\s|,)\/\*[\s\S]*?\*\/)|(( |, ")\/\/.*)
return self.replacingOccurrences(of: "((\\s|,)\\/\\*[\\s\\S]*?\\*\\/)|(( |, \\\")\\/\\/.*)", with: "", options: .regularExpression)
}
}
@ad
ad / manager.go
Last active July 13, 2018 13:43
goroutine lifetime (start/stop goroutine)
package main
import (
"fmt"
"runtime"
"sync"
"time"
"github.com/tevino/abool"
)
CREATE OR REPLACE FUNCTION change_trigger() RETURNS trigger AS $$
BEGIN
IF TG_OP = 'INSERT'
THEN
INSERT INTO history (tabname, schemaname, operation, new_val, item_id)
VALUES (TG_RELNAME, TG_TABLE_SCHEMA, TG_OP, row_to_json(NEW), NEW.id);
RETURN NEW;
ELSIF TG_OP = 'UPDATE'
THEN
INSERT INTO history (tabname, schemaname, operation, new_val, old_val, item_id)