Skip to content

Instantly share code, notes, and snippets.

View SuperPaintman's full-sized avatar
🐻
Nice!

Aleksandr Krivoshchekov SuperPaintman

🐻
Nice!
View GitHub Profile
@SuperPaintman
SuperPaintman / result.h
Last active March 3, 2018 11:56
Rust flavored error handling for C
#ifndef RESULT_H_
#define RESULT_H_
// Includes
#include <stdbool.h>
#include <stdint.h>
// Macros
#define RESULT_TEMPLATE(name, typeOk, typeErr) \
typedef struct name { \
@SuperPaintman
SuperPaintman / postgresql_fixing_sequences.sh
Last active June 7, 2017 18:23
PostgreSQL fixing sequences
#!/bin/bash
#
# Author: SuperPaintman <[email protected]>
#
database_name="my_awesome_database"
psql -Atq "$database_name" <<SQL | psql -Atq "$database_name"
SELECT 'SELECT ' ||
@SuperPaintman
SuperPaintman / sweet.setd.sjs.js
Last active October 12, 2016 22:19
Sweet.js - set default
syntax setd = (ctx) => {
const dummy = #`dummy`.get(0);
let result = #``;
ctx.expand('expr');
ctx.reset();
const selectors = [];
export class AbstractClass {
constructor(constructor, name) {
if (!name) {
name = constructor.name;
}
if (this.constructor === AbstractClass) {
throw new Error(`Cannot create an instance of the abstract class "AbstractClass"`);
}
@SuperPaintman
SuperPaintman / mongodb_git_backup_export.sh
Last active September 13, 2016 01:37
Backup a MongoDB database using Git
#!/bin/bash
#
# Author: SuperPaintman <[email protected]>
#
# Export
# Init
me=$(basename "$0")
@SuperPaintman
SuperPaintman / create_default_gl_labels.sh
Created September 8, 2016 02:44
Create default labels for Gitlab project
#!/bin/bash
#
# Author: SuperPaintman <[email protected]>
#
# Init
me=$(basename "$0")
RETVAL=0
env_name_token="GITLAB_PRIVATE_TOKEN"
escape_json () {
echo "${1//$'\n'/\\n}" | sed 's/\\/\\\\/g' | sed 's/\\\\n/\\n/g' | sed 's/"/\\"/g' | sed "s/'/\\'/g"
}
#!/bin/bash
if [[ $(swapon -s) != "" && $(swapon -s | wc -l) != 0 ]]; then
echo "Swap already created"
exit 1
fi
SWAP_FILENAME="/swapfile"
mem_size="$(free | grep -i 'mem:' | awk '{ print $2 }')"
#!/usr/bin/bash
RETVAL=0
if [ -z "$1" ]; then
echo "Usage: build <bin_name>"
exit 1
fi
bin_name="$1"
@SuperPaintman
SuperPaintman / docker-letsencrypt-renew.sh
Last active September 22, 2021 04:45
Auto renew Let's Encrypt throw Docker
#!/bin/bash
#
# Author: SuperPaintman <[email protected]>
#
###
# Constants
###
RETVAL=0