Skip to content

Instantly share code, notes, and snippets.

View hanseartic's full-sized avatar
🏠
Working from home

Paul hanseartic

🏠
Working from home
View GitHub Profile
@hanseartic
hanseartic / listen.js
Created August 15, 2022 22:56
listen to transactions stream
const {Server} = require("stellar-sdk");
const server = new Server("https://horizon.stellar.org");
server.transactions().limit(1).order("desc").call()
.then(({records}) => {
var lastCreatedAt;
const stop = server.transactions().cursor(records[0].paging_token).stream({
onmessage: m => {
const createdAt = new Date(m.created_at);
@hanseartic
hanseartic / create_riddle.js
Last active September 14, 2022 11:53
[RIDDLE] a treasury hunt on the blockchain
const { Keypair, Networks, Server, TransactionBuilder, Operation, BASE_FEE, Memo, Claimant, Asset, LiquidityPoolAsset} = require('stellar-sdk');
const StellarHDWallet = require("stellar-hd-wallet");
const random = require("@sefinek/random-emoji");
const server = new Server("https://horizon-testnet.stellar.org");
const friendbotAccount = "GAIH3ULLFQ4DGSECF2AR555KZ4KNDGEKN4AFI4SU2M7B43MGK3QJZNSR";
const keyChars = "234567ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const solution = (() => {
if (process.env.SECRET) return Keypair.fromSecret(process.env.SECRET);
@hanseartic
hanseartic / README.md
Created April 6, 2022 21:55
polyfills for js-stellar-sdk and webpack > 5 with craco

webpack > 5 does not ship polyfills anymore

Creating a current (i.e. ^5.0.0) CRA will result in missing polyfills.

That will make a typescript project fail to compile.

A workaround is to provide the polyfills with craco. Find the neccessary configuration snippets in the files below.

@hanseartic
hanseartic / fetch_keys.sh
Created January 3, 2021 23:37
fetch team member's keys from github
#!/usr/bin/env bash
set -e
ORGANIZATION=${GH_ORG:?"Please set variable GH_ORG."}
TEAM=${GH_TEAM:?"Please set variable GH_TEAM"}
API_TOKEN=${GH_API_TOKEN:?"Please set variable GH_API_TOKEN."}
curl -s -X POST \
-H"Authorization: Bearer ${API_TOKEN}" \
-d"{ \"query\": \"query { \
organization(login: \\\"${ORGANIZATION}\\\") { \
@hanseartic
hanseartic / README.md
Created May 14, 2020 20:53
Use ubiquiti EdgeRouter X (er-x) as offloader for freifunk with unifi APs and ff nodes

Why to use an offloader for freifunk

  • The er-x has more computing power than cheap WiFi router and can act as a VPN tunnel gateway for multiple nodes.
  • It is possible to connect several APs (in my case unifi AC lite) to the LAN ports of the er-x to increase coverage

How to connect

@hanseartic
hanseartic / ImgTools.php
Last active November 10, 2015 22:15
calculate image (re)size and keep ratio
<?php
class ImgTools
{
/**
* Calculate image dimensions from given ratio and desired new x-/y- values
*
* @param int $desired_width desired image width
* @param int $desired_height desired image height
* @param int $ratio desired ratio
@hanseartic
hanseartic / 69-yubikey.rules
Created November 9, 2015 15:31
yubikey PGP udev rules
ACTION!="add|change", GOTO="yubico_end"
# Udev rules for letting the console user access the Yubikey USB
# device node, needed for challenge/response to work correctly.
# Yubico Yubikey II
SUBSYSTEMS=="usb",\
ATTRS{idVendor}=="1050",\
ATTRS{idProduct}=="0010|0110|0111|0114|0116", \
ENV{ID_SECURITY_TOKEN}="1", GROUP="plugdev",\
@hanseartic
hanseartic / c.py
Created November 4, 2015 07:04
scan buergeramt
#!/usr/bin/env python3
import sys
import argparse
import time
import lxml
import requests
import lxml.html as lhtml
@hanseartic
hanseartic / gitlab_shared-key.md
Last active January 17, 2017 08:24
Allow shell-login and repository-access with the same key in gitlab

Make a single ssh-key work as well for ssh-logins as for access to gitlab-repositories

Imagine you have a server, that does not allow you to create a dedicated user for gitlab (e.g. uberspace). That puts you in the situation that you would need different ssh-keys to either access gitlab or the shell.

gitlab-shell redirection

Gitlab uses the command option in authorized_keys to limit access for the owner of the private key to only gitlab-shell. This in fact disables regular shell-access for that very key.

Add a switch

Keybase proof

I hereby claim:

  • I am hanseartic on github.
  • I am fraggedreality (https://keybase.io/fraggedreality) on keybase.
  • I have a public key whose fingerprint is 6B7E 0422 C03B E477 04F0 DE7C CAC0 1914 8FF8 80AC

To claim this, I am signing this object: