Skip to content

Instantly share code, notes, and snippets.

View Aketzu's full-sized avatar

Anssi Kolehmainen Aketzu

View GitHub Profile
@Aketzu
Aketzu / kompassi-google-sync.rb
Created August 18, 2024 17:51
Synchronization script from Kompassi users to Google Workspace
#!/usr/bin/ruby
# as gem google-apis-admin_directory_v1
require "google/apis/admin_directory_v1"
require "googleauth"
require "googleauth/stores/file_token_store"
require "fileutils"
require 'securerandom'
require 'mail'
@Aketzu
Aketzu / tbot.py
Created March 6, 2022 17:56
UkrzalInfo translator bot
from telethon import TelegramClient, events
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
import os
import sys
from google.cloud import translate_v3 as translate
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/path/key.json"
gclient = translate.TranslationServiceClient()
@Aketzu
Aketzu / gcc -E test.c
Created February 27, 2022 21:23
cppcheck 2.7 internalAstError
# 0 "test.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "test.c"
# 1 "uthash.h" 1
# 29 "uthash.h"
# 1 "/usr/include/string.h" 1 3 4
# 26 "/usr/include/string.h" 3 4
# cleanzwsp.pl
#
# Cleans zero width spaces from text
#
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
@Aketzu
Aketzu / Dockerfile
Created March 1, 2021 10:40
Azure App service ssh support
# Azure SSH support
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssh-server \
&& echo "root:Docker!" | chpasswd
COPY sshd_config /etc/ssh/
EXPOSE 2222
#Depending on your actual application
COPY start_sshd.sh $SCRIPT_DIR/init_2_start_sshd.sh
#!/usr/bin/ruby
require 'vici'
require 'socket'
require 'syslog'
Syslog.open('ipsec-reconnect', Syslog::LOG_PID, Syslog::LOG_DAEMON | Syslog::LOG_LOCAL4)
# Requires uncommenting socket in /etc/strongswan.d/charon/vici.conf
v = Vici::Connection.new(UNIXSocket.new('/var/run/charon.vici'))
@Aketzu
Aketzu / main.cf
Created January 9, 2020 17:50
Postfix sender specific smtp with auth
sender_dependent_default_transport_maps = hash:/etc/postfix/sender_transport
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_sasl_security_options = noanonymous
@Aketzu
Aketzu / auth-index.php
Created January 2, 2020 06:52
PHP Azure auth
<?php
session_start();
require('vendor/autoload.php');
$provider = new TheNetworg\OAuth2\Client\Provider\Azure([
'clientId' => '12345678-1234-1234-1234-12345678abcd',
'clientSecret' => 'xxx',
'redirectUri' => 'https://example.com/auth',
'tenant' => 'example.com',
'scope' => 'openid email profile User.Read Directory.Read.All',
@Aketzu
Aketzu / macserv.c
Created July 11, 2018 16:05
Local webserver to provice MAC address
// Compile with -lmicrohttpd
#include <arpa/inet.h>
#include <errno.h>
#include <limits.h>
#include <linux/rtnetlink.h>
#include <linux/types.h>
#include <microhttpd.h>
#include <net/if.h>
#include <stdio.h>
@Aketzu
Aketzu / irssi
Created May 16, 2018 09:07
irssi slack
https://api.slack.com/custom-integrations/legacy-tokens
/NETWORK ADD fooslack -autosendcmd "/MSG slack login xoxp-............"
/SERVER ADD -network fooslack -auto localhost 6669
/CONNECT fooslack
/NETWORK ADD barslack -autosendcmd "/MSG slack login xoxp-............"
/SERVER ADD -network barslack -auto localhost 6669
/CONNECT barslack