Skip to content

Instantly share code, notes, and snippets.

@drmalex07
drmalex07 / README-setup-tunnel-as-systemd-service.md
Last active May 4, 2024 15:04
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@djaiss
djaiss / progress_bar_migration_laravel.php
Last active May 4, 2024 15:03
Laravel: Use progress bars in migrations
<?php
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\ConsoleOutput;
class DoSomething extends Migration
{
public function up()
{
$output = new ConsoleOutput();
@vorce
vorce / jerry.swift
Last active May 4, 2024 15:02
Mouse move and click test thing for macos in swift
import Cocoa
import Foundation
// Move around and click automatically at random places in macos, kinda human like in a cheap way.
// Moves the mouse pointer to `moves` random locations on the screen and runs the `action` function at
// each point with the point as argument.
func mouseMoveWithAction(moves: Int, action: (CGPoint) -> Void = defaultAction) {
let screenSize = NSScreen.main?.visibleFrame.size
@bbengfort
bbengfort / locks.go
Created March 3, 2017 17:40
Synchronized, thread safe buffer using mutex embedding
package main
import (
"flag"
"fmt"
"log"
"sync"
"time"
)
@ExperimentalPagerApi
@Composable
fun WormHorizontalPagerIndicator(
pagerState: PagerState,
modifier: Modifier = Modifier,
activeColor: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current),
inactiveColor: Color = activeColor.copy(ContentAlpha.disabled),
indicatorWidth: Dp = 8.dp,
activeIndicatorWidth: Dp = 25.dp,
indicatorHeight: Dp = indicatorWidth,
@Daninet
Daninet / wav.js
Created July 2, 2022 13:57
Convert AudioBuffer's Float32Array to Wav file format
/** @param sampleRate {number} */
/** @param channelBuffers {Float32Array[]} */
function audioBufferToWav(sampleRate, channelBuffers) {
const totalSamples = channelBuffers[0].length * channelBuffers.length;
const buffer = new ArrayBuffer(44 + totalSamples * 2);
const view = new DataView(buffer);
const writeString = (view, offset, string) => {
for (let i = 0; i < string.length; i++) {
@ar1a
ar1a / comp.cfg
Created October 1, 2023 07:22
Dathost cs2 configs
// >>> DatHost Competitive Config 0.1 <<< //
// Reset from Practice to Competitive
sv_cheats "false" // Disable cheats
mp_ct_default_grenades "" // Spawn CTs without grenades
mp_t_default_grenades "" // Spawn Ts without grenades
sv_showimpacts "0" // Don't show bullet impacts
sv_falldamage_scale "1" // Enable fall damage
sv_full_alltalk "0" // Disable voice chat with anyone
@MattPD
MattPD / analysis.draft.md
Last active May 4, 2024 14:56
Program Analysis Resources (WIP draft)
@matteobertozzi
matteobertozzi / 1_otp.ts
Last active May 4, 2024 14:56
Generate Time Based OTP in Javascript/Typescript, Python, Java
async function generateOneTimePassword(rawKey: Uint8Array, counter: number): Promise<number> {
const data = new DataView(new ArrayBuffer(8));
data.setBigUint64(0, BigInt(Math.floor(counter)), false);
const algo = { name: 'HMAC', hash: 'SHA-1' };
const key = await crypto.subtle.importKey('raw', rawKey, algo, false, ['sign']);
const hmacHash = new Uint8Array(await crypto.subtle.sign(algo, key, data.buffer));
const offset = hmacHash[hmacHash.byteLength - 1] & 0x0f;
const hotp = (hmacHash[offset] & 0x7f) << 24
{ stdenv, autoPatchelfHook }:
stdenv.mkDerivation rec {
pname = "wasmcloud-binaries";
version = "1.0";
src = ./.; # Assuming the binaries are in the current directory
nativeBuildInputs = [ autoPatchelfHook ];