Skip to content

Instantly share code, notes, and snippets.

View piotrmaslanka's full-sized avatar

Piotr Maślanka piotrmaslanka

View GitHub Profile
@piotrmaslanka
piotrmaslanka / antivir-psql.sh
Created April 12, 2023 16:38
antivir-psql.sh
#!/bin/bash
#
# After noticing a bunch of weird psql processes running on my server I decided all of them needed to die.
# This is what this script is for.
# Just put the following line (without the "# " at the beginning) into your crontab, this process in /usr/bin/antivir-psql.sh.
# and make it executable only for the owner (readable for the owner as well). If you want to disable the conditional disable, just remove
# the lines starting with if and fi. If you want to disable the antivirus for some time, just drop a /antivir-disabled file. Remember
# to edit it out when you're gone. And there goes the fabulous crontab line:
#
@piotrmaslanka
piotrmaslanka / backup_cassandra.py
Last active April 7, 2023 12:22
Moving data between different Cassandras if you're running them using Docker
#!/usr/bin/python3
import os
import sys
"""
A tool to copy a named snapshot of a cassandra to a target rsynced thing.
Will use ssh to create target directories
Requires: rsync ssh
@piotrmaslanka
piotrmaslanka / gist:83fcf36b0f28b423bafc
Last active January 7, 2023 21:52
In case you fuck your SyncMaster's 2343NW EDID
If you suddently find your SyncMaster 2343 fucking at low resolution, DON'T WORRY.
Your EDID card is toast. It's the card that tells the computer what resolutions are supported.
Again, don't worry. This shit supports only VGA, and that sucks, but you can still win.
First, make sure you have a graphics control panel sophisticated enough to manually define resolutions.
When you do, whip it up. You are going to manually configure it.
Native resolution is 2048x1152, 60 Hz.
@piotrmaslanka
piotrmaslanka / get_distance.py
Created May 8, 2022 13:09
Python code to calculate great circle distance between two points on Earth
import math
from dataclasses import dataclass
__all__ = ['get_distance', 'Coordinates']
@dataclass
class Coordinates:
"""
A set of coordinates on Earth
"""
@piotrmaslanka
piotrmaslanka / luasz.cpp
Last active February 3, 2022 20:14
A function plotter in C++. You give it a function in Lua via stdin, it plots it. Compile using Visual Studio. Requires lua.hpp.
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
#include <lua.hpp> // hpp to plik nagłówkowy C++, taki ukłon w naszą stronę ze strony autorów Lua
extern "C" // lua jest pisana w C, uzyj wiec odpowiedniego importu
{
#include "lualib.h"
#include "lauxlib.h"
}
@piotrmaslanka
piotrmaslanka / kolekcjoner.py
Created December 30, 2021 14:37
KOLEKCJONER. A script used by Tarnobrzeska Spółdzielnia Mieszkaniowa before they had SMOK
# Python 2
# -*- coding: utf-8 -*-
'''Komunikacja MODBUS i kod Kolekcjonera Frisko'''
from __future__ import division
import struct
import socket
from threading import Thread
from threading import Timer
import datetime
import os
@piotrmaslanka
piotrmaslanka / screenreader.py
Last active December 30, 2021 14:35
Script to read the screen of a suitably equipped FRISKO PLC. Requires a Windows to run.
# Python 2
import socket # System lacznosci sieciowej
import WConio # System obslugi konsoli tekstowej
import msvcrt # Obsluga klawiatury, ta w WConio wydaje sie nawalac
from array import array # Edycja stringow (stringi w Pythonie sa niemodyfikowalne)
from struct import pack # Niezbedne do skladania pakietow w calosc
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Korzystamy z zestawu protokolow Internetowych,
# gniazdo strumieniowe
host = raw_input("Give the address (demo version - type DEMO): ")
@piotrmaslanka
piotrmaslanka / turnoff.pas
Created December 30, 2021 14:16
A program that I wrote that was intended to prevent my sister from using her computer for too long.
program TOFF;
uses
Registry, Windows;
var
r: TRegistry;
h1, min1, h2: Integer;
st: _SYSTEMTIME;
godown: Boolean;
@piotrmaslanka
piotrmaslanka / cpuid.h
Last active April 19, 2021 16:01
A cpuid.h replacement for POWER8
/*
* Copyright (C) 2021 Dronehub Group sp. z o. o.
*
* This file is free software; you can redistribute it and/or modify it
* under the terms of the MIT license.
*/
#ifndef _CPUID_H_INCLUDED
#define _CPUID_H_INCLUDED
@piotrmaslanka
piotrmaslanka / script.sh
Last active March 1, 2021 16:47
Script to launch a Cassandra instance on our production server.
#!/bin/bash
#
# This accepts a two commandline arguments, ie
# * the IP address of the host that is to become the node,
# * comma-separated list of hosts that are to be seed nodes
#
docker run --restart always --name cassandra -v /v2/var/lib/cassandra:/var/lib/cassandra -e GC=G1 -e I_ACCEPT_ORACLE_JAVA_LICENSE=1 -e "CLUSTER_NAME=SMOK4 Production" -e MAX_HEAP_SIZE=16G -e HEAP_NEWSIZE=3000M -e "SEED_NODES=$2" -e NUM_TOKENS=256 -e LISTEN_ADDRESS=$1 -e BROADCAST_ADDRESS=$1 -e RPC_ADDRESS=$1 -e RPC_BROADCAST_ADDRESS=$1 -e STREAMING_SOCKET_TIMEOUT_IN_MS=360000000 -e LOCAL_JMX=no -e JMX_REMOTE_PASSWORD=cass -e DISABLE_JOLOKIA=1 -e KEY_CACHE_SIZE_IN_MB=256 -e FILE_CACHE_SIZE_IN_MB=2560 -e JAEGER_AGENT_HOST=$1 -e JAEGER_TRACE_KEY=jaeger-trace -e ROW_CACHE_SIZE_IN_MB=256 -e BATCH_SIZE_FAIL_THRESHOLD_IN_KB=500 -e TOMBSTONE_FAIL_THRESHOLD=1000000 --cpus=30 -d --network=host smokserwis/cassandra