Skip to content

Instantly share code, notes, and snippets.

View dzmitryk's full-sized avatar

Dzmitry Kazimirchyk dzmitryk

View GitHub Profile
@dzmitryk
dzmitryk / docker-shutdown.sh
Last active February 21, 2020 18:02
Shutdown Docker for mac if no containers are running
#!/bin/bash
TIMEOUT=$1
LAST_USED_FILE=~/.docker_last_usage
docker ps -q > /dev/null 2> /dev/null
result=$?
if [[ $result -eq 0 && -z $(docker ps -q) && $(cat $LAST_USED_FILE 2> /dev/null) && $(expr $(date +%s) - $(cat $LAST_USED_FILE 2> /dev/null)) -gt $TIMEOUT ]]; then
osascript -e 'quit app "Docker"'
version: '2'
services:
zk1:
image: 31z4/zookeeper
restart: always
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888
networks:
solr_cluster:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>OAuth code</title>
</head>
<body>
<div>
<label for="code">Your authorization code is:</label>
<b><span id="code"></span></b>
@dzmitryk
dzmitryk / enrolment.groovy
Last active August 29, 2015 14:06
enrolment sending script
def run(args) {
def enrolment = args.entity
if (enrolment.status == EnrolmentStatus.SUCCESS && enrolment.confirmationStatus == ConfirmationStatus.NOT_SENT) {
def m = Email.create("Enrolment Confirmation")
m.bind(enrolment: enrolment)
m.to(enrolment.student.contact)
m.send()
@dzmitryk
dzmitryk / invoice.groovy
Last active August 29, 2015 14:06
invoice sending script
def run(args) {
def invoice = args.entity
if (invoice.confirmationStatus == ConfirmationStatus.NOT_SENT) {
def m = Email.create("Tax Invoice")
m.bind(invoice: invoice)
m.to(invoice.contact)
m.send()
@dzmitryk
dzmitryk / crypt.c
Created February 23, 2014 15:00
Call UNIX crypt function from command line. Compile using: $gcc crypt.c -lcrypt -o crypt
#include <stdio.h>
#include <unistd.h>
#include <crypt.h>
int main(int argc, char **argv) {
int option;
int debug = 0;
const char *salt;
const char *pass;
@dzmitryk
dzmitryk / pkcs5.c
Last active June 22, 2024 00:22
Simple command line tool to demonstrate using of PKCS#5 PBKDF2 HMAC SHA1 capabilities of OpenSSL library.Params: -i number of iterations; -s salt; -p password; -l hash length; -x flag which allows to specify salt as hex string;Compile using: $gcc pkcs5.c -L/usr/lib -lssl -lcrypto -o pkcs5
/*
MIT License
Copyright (c) 2013 Dzmitry Kazimirchyk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is