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 June 18, 2024 16:07
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
@tnqsoft
tnqsoft / example.html
Last active June 29, 2024 14:09
Preview image for ng2-file-upload
<div *ngFor="let item of uploader.queue; let first = first;">
<img src="" thumbnail [image]="item?._file"/>
{{ item?.file?.name }}
{{ item?.file?.size }}
</div>
<input type="file" ng2FileSelect [uploader]="uploader" #fileInput [accept]="accept.toString()" [multiple]="multiple"/>
@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 July 14, 2024 19:55
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: