Skip to content

Instantly share code, notes, and snippets.

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

Aruna Tennakoon kakopappa

🏠
Working from home
View GitHub Profile
@mrwormhole
mrwormhole / xfs-on-hetzner.yaml
Last active January 27, 2024 06:31
XFS disk partitioning on Hetzner, please adjust the percentages carefully so that root partition can have at least 5GB, or it won't do partitioning from this script. 25%~30% is ideal for 40GB SSD, 10% won't work for 40GB SSD
#cloud-config
# Ubuntu 22.04+
resize_rootfs: false
write_files:
- content: |
path: /etc/growroot-disabled
runcmd:
- [ sgdisk, -e, /dev/sda ]
- [ partprobe ]
@erev0s
erev0s / README.md
Last active November 3, 2023 07:49
@yekver
yekver / prom-client_pm2_cluster.js
Last active August 11, 2023 18:47
Instead of `cluster` module there is no direct access to the master process in `pm2`. To return metrics for the whole cluster you can do IPC calls from the active instance to the rest of them and wait while all their locally collected metrics will be sent. Finally you have to aggregate all received metrics.
const prom = require('prom-client');
const pm2 = require('pm2');
let pm2Bus;
const REQ_TOPIC = 'get_prom_register';
function pm2exec(cmd, ...args) {
return new Promise((resolve, reject) => {
pm2[cmd](...args, (err, resp) => (err ? reject(err) : resolve(resp)));
@kakopappa
kakopappa / app.js
Created February 18, 2019 13:05
Hmac sha256 url parameter signature validate using dart and nodejs
// Dart
void _incrementCounter() {
String secret = "762c4144-1630-4fab-9161-0fef8b18d316";
List<int> key = utf8.encode(secret);
String message = "clientId=android-app&type=action&ts=1550493108338&actions=%5B%7B%22name%22%3A%22setOn%22%2C%22parameters%22%3A%7B%7D%7D%5D";
List<int> messageBytes = utf8.encode(message);
Hmac hmac = new Hmac(sha256, key);
Digest digest = hmac.convert(messageBytes);
import 'package:flutter/material.dart';
import 'dart:math' as math;
import 'dart:async';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
@exocode
exocode / xfs-on-hetzner.yml
Last active January 27, 2024 06:33
Create xfs partitions on Hetzner via cloud-init. It keeps root disk available again after rebooting. Simply change your desired sizes and filesystem to use it for your needs.
#cloud-config
resize_rootfs: false
disk_setup:
/dev/sda:
table_type: 'mbr'
layout:
- 25
- 75
overwrite: true
@mikemimik
mikemimik / asyncWidget.dart
Last active July 21, 2018 05:31
Flutter: Async widget
import 'package:flutter/material.dart';
import 'loadScreen.dart';
class AsyncWidget extends StatefulWidget {
@override
_AsyncWidgetState createState() => _AsyncWidgetState();
}
class _AsyncWidgetState extends State<AsyncWidget> {
Widget currentComponent;
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@AysadKozanoglu
AysadKozanoglu / jail.conf
Last active November 2, 2023 00:31
fail2ban nginx 404 400 403 444 filter /etc/fail2ban/filter.d/nginx-4xx.conf enable
# to enable this filter add to jail.conf following (/etc/fail2ban/jail.conf)
# Thanks to -> TheBarret
[nginx-4xx]
enabled = true
port = http,https
logpath = /var/log/nginx/access.log
maxretry = 3