Skip to content

Instantly share code, notes, and snippets.

View thejhh's full-sized avatar
💭
Excellence isn't believing you're best; It's about always striving to get better

Jaakko Heusala thejhh

💭
Excellence isn't believing you're best; It's about always striving to get better
View GitHub Profile
@thejhh
thejhh / gist:057be2d186a46b151868ecf24c2bd18f
Created November 14, 2021 20:22
bin/fix-log-timestamp.sh
#!/bin/bash
while read LINE; do
TIME="$(echo "$LINE"|awk '{print $1}')"
FIXED_TIME="$(date -d "$TIME" '+[%d/%b/%Y:%H:%M:%S %z]')"
echo -n "$FIXED_TIME "
echo "$LINE"|sed -re 's/^[^ ]+ //'
done
@thejhh
thejhh / list-rooms-by-state.ts
Created August 25, 2021 15:26
List Matrix rooms by latest room state
const response : MatrixSyncResponseDTO = await this._client.sync({
filter: {
presence: {
limit: 0
},
account_data: {
limit: 0
},
room: {
account_data: {
@thejhh
thejhh / git-archive.sh
Last active March 29, 2021 09:15
Simple script to archive branches as a git tag
#!/bin/bash
# Origin: https://gist.github.com/thejhh/7e505fdc56d08253cdaf7de5f25838db
# USAGE: git-archive BRANCH [...BRANCH_N]
set -e
#set -x
DATE="$(date '+%Y%m%d-%H%M%S')"
BRANCH_NAME=$1
@thejhh
thejhh / AuthController.md
Last active March 7, 2021 17:50
Simple stateless JWT Authentication REST service, written in TypeScript, using experimental request mapping annotations

Flow

@thejhh
thejhh / UserController.ts
Created February 8, 2021 19:26
POC: Spring style annotations in TypeScript
// Copyright (c) 2020 Sendanor. All rights reserved.
import Request from "../../core/Request";
import UserService, {UserModel} from "./UserService";
export interface ListDTO<T> {
pageNumber : number;
pageSize : number;
content : Array<T>;
// Copyright (c) 2020 Sendanor. All rights reserved.
export interface JsonSerializable {
toJSON () : JsonAny;
}
export type JsonAny = string | number | boolean | null | JsonArray | JsonObject | JsonSerializable;
export type JsonObjectOf<T extends JsonAny> = { [name: string]: T | undefined };
export type JsonObject = { [name: string]: JsonAny | undefined };
export type JsonArrayOf<T extends JsonAny> = Array<T>;
@thejhh
thejhh / InstallWp.ts
Last active December 10, 2020 06:59
Example how to write Ansible playbooks in TypeScript
// Copyright (c) 2020 Sendanor. All rights reserved.
import Ansible, {AnsibleTask as Task} from "../utils/Ansible";
import Build from "../utils/Build";
import Tag from "../types/Tag";
import Play from "../types/Play";
import {FileTaskState} from "../types/FileTask";
enum InstallWpVariable {
@thejhh
thejhh / Observer.ts
Last active September 19, 2020 09:55
Observer.ts
// Copyright 2020 Jaakko Heusala <jheusala@iki.fi>
// Licence: MIT
import {filter, forEach, has} from "../../modules/lodash";
export interface ObserverCallback<EventName extends keyof any> {
(event: EventName) : void;
}
export interface ObserverDestructor {
@thejhh
thejhh / compile.sh
Last active July 21, 2020 21:09
Bookmarklet to export order from holvi.com
#!/bin/bash
uglifyjs order-export.js --compress --mangle > min.js
sed -e 's/^function e(/function(/' -e 's/ /%20/g' min.js > min2.js
echo "javascript:($(cat min2.js))()"

Extra Short Getting Started for Ansible

This page has multiple mini guides about using Ansible.

Start using Ansible

Eg. How to automate rsync package installation on multiple Debian/Ubuntu based hosts.

1. Install Ansible