Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlos
sebastiancarlos / grepdist.sh
Last active August 5, 2023 13:57
Grepdist - Print the number of matches in each 10% section of a file
#!/usr/bin/env bash
# All my gist code is licensed under the terms of the MIT license.
# GREPDIST
# Print the number of matches in each 10% section of the file
#
# Example with grep:
# $ grep -c 'Napoleon' war_and_peace.txt
# 576
@lem0n4de
lem0n4de / scraper.cpp
Created May 12, 2022 12:52
c++ qt 6 web scraping
#include "scraper.h"
#include "ui_scraper.h"
#include <QTimer>
#include <QWebEngineProfile>
#include <QWebEngineCookieStore>
#include <QNetworkCookie>
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
@startergo
startergo / extract-firmware.md
Last active May 6, 2024 12:25
Extract Firmware from OS X installer
  • Download the full installer:
softwareupdate --list-full-installers
Finding available software
Software Update found the following full installers:
* Title: macOS Ventura, Version: 13.1, Size: 11931164KiB, Build: 22C65
* Title: macOS Ventura, Version: 13.0.1, Size: 11866460KiB, Build: 22A400
* Title: macOS Ventura, Version: 13.0, Size: 11866804KiB, Build: 22A380
* Title: macOS Monterey, Version: 12.6.2, Size: 12104568KiB, Build: 21G320
* Title: macOS Monterey, Version: 12.6.1, Size: 12108491KiB, Build: 21G217
@dragos
dragos / scala-env.sh
Last active April 3, 2022 20:01
Simple bash functions to manage different Scala versions on the command line
#!/bin/bash -e
# where Scala tarballs are extracted
SCALA_BASE=$HOME/scala
# Usage:
#
# Install:
# . /path/to/scala-env.sh in your bash profile
#
@RafaelPalomar
RafaelPalomar / autoumount_udev_systemd.org
Last active May 20, 2023 22:40
Automount USB external drives with udev rules and systemd workaround #udev #automount #usb #systemd #gentoo

Automount USB external drives with udev rules and systemd workarounds

Generate /etc/udev/rules.d/11-media-by-label-auto-mount.rules with the following content

KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"  
# Import FS infos  
IMPORT{program}="/sbin/blkid -o udev -p %N"  
# Get a label if present, otherwise specify one  
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"  
@cerebrate
cerebrate / README.md
Last active December 2, 2023 08:17
Recompile your WSL2 kernel - support for snaps, apparmor, lxc, etc.

WARNING

THIS GIST IS EXTREMELY OBSOLETE. DO NOT FOLLOW THESE INSTRUCTIONS. SERIOUSLY.

IF YOU IGNORE THE ABOVE WARNING, YOU AGREE IN ADVANCE THAT YOU DIDN'T GET THESE INSTRUCTIONS FROM ME, THAT I WARNED YOU, AND THAT I RESERVE THE RIGHT TO POINT AND LAUGH MOCKINGLY IF AND WHEN SOMETHING BREAKS HORRIBLY.

I'll do a write-up of current custom-kernel procedures over on Random Bytes ( https://randombytes.substack.com/ ) one day soon.

NOTE

@Reiikz
Reiikz / check
Last active December 10, 2023 21:48 — forked from a-c-t-i-n-i-u-m/freenom.com.ddns.sh
Dynamic DNS support shell script for freenom.com
#!/bin/bash
GET_IP_URL="https://api.ipify.org/"
UPDATE_SCRIPT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )/update
LOGGER_SCRIPT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )/log
source $( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )/config
HOST_RESULT="$(host $freenom_domain_name 80.80.80.80)"
DNS_IP=$(echo $HOST_RESULT | cut -d' ' -f 12)
CURR_IP="$(curl -s $GET_IP_URL)"
@AveYo
AveYo / .. MediaCreationTool.bat ..md
Last active May 8, 2024 07:24
Universal MediaCreationTool wrapper for all MCT Windows 10 versions - MOVED TO github.com/AveYo/MediaCreationTool.bat
@brendanmaguire
brendanmaguire / CatsIOParallelApp.scala
Created March 27, 2018 10:57
Run cats.effect.IO's in parallel
import scala.concurrent.ExecutionContext.Implicits.global
import cats.effect.IO
import cats.implicits._
object CatsIOParallelApp extends App {
def printThreadId(msg: String) =
println(s"${Thread.currentThread.getId} : $msg")
def io(x: String) = IO {
@VictorTaelin
VictorTaelin / promise_monad.md
Last active May 10, 2024 04:22
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing