Skip to content

Instantly share code, notes, and snippets.

#include <wiringPi.h>
#include <iostream>
#include <unistd.h>
// Define GPIO pins connected to the RGB LED
#define RED_PIN 0 // GPIO 17
#define GREEN_PIN 2 // GPIO 27
#define BLUE_PIN 3 // GPIO 22
// Function to initialize PWM on the RGB pins
import RPi.GPIO as GPIO
import time
# Set GPIO mode to BCM
GPIO.setmode(GPIO.BCM)
# Define GPIO pins connected to the RGB LED
RED_PIN = 17
GREEN_PIN = 27
BLUE_PIN = 22
@andrewrk
andrewrk / build.zig
Last active January 4, 2025 22:17
zig project with the main function being in C
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
@geobabbler
geobabbler / scrape_photos.py
Created July 19, 2024 11:01
Script to download sample images from Wikimedia Commons
import requests
from bs4 import BeautifulSoup
import os
qry = "glacier" #wikimedia commons query
# Define the search URL
search_url = f"https://commons.wikimedia.org/w/index.php?search={qry}&title=Special:MediaSearch&go=Go&type=image"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
@trumad
trumad / arcHistoryToFirefox.md
Last active January 4, 2025 22:13
Import Arc history in Firefox

No good reason why this had to be so tricky:

  • Install Export Chrome History extension in Arc
  • Export history to JSON. Choosing the forever option does actually export ALL the history in Arc
  • Install History Export for firefox
  • Optional: Export Firefox history, to see what the json looks like
  • Make the Arc history match what firefox expects. I used this javascript to convert it:
arcHistory.map(item =&gt; {
@milesrichardson
milesrichardson / open-vlc-m3u8-url-with-http.md
Created July 10, 2024 21:50
How to use VLC to watch m3u8 playlist at URL with custom HTTP referrer and user agent

Imagine this: it's Sunday afternoon at 1pm, and you want to watch some live content. But you don't have a TV subscription. So you do a little Googling, and eventually you find yourself on a sketchy website where you can watch the content you're looking for. But while the website has a video player, it's surrounded by advertisements, and probably a cryptominer too. You don't want this website eating your CPU for 2 hours while you're watching your favorite Sunday afternoon content.

Wouldn't it be nice if you could watch that video in VLC instead? Then you can close the sketchy website and still watch your content. It's like having your cake and taking a bite of it too!

Here's how you do it:

  1. Capture the m3u8 request in dev tools. Open the site (or just the iframe, if possible) in DevTools and click "play." Search the network tab for m3u8 and grab the first request.

  2. Run VLC with command line flags to set the User Agent and Referrer. From the request body, you need to copy the requested URL,

An guide how to activate Windows 11 Pro for free

Why?

Because you will get some more features like an Bitlocker and host your device as an External Desktop which can be accessed through the internet

Am i also able to switch from any other edition to Pro?

The answer is yes! You can switch from almost any edition to Pro completely for free!

Note for users with unactivated Pro edition

People which already have Pro, but not activated, can skip to this step.

Getting started

What you first need to do is open CMD (Command Prompt) as Administrator using this keyboard key:

@vasanthk
vasanthk / System Design.md
Last active January 4, 2025 22:11
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@SyedaMahamFahim
SyedaMahamFahim / gmail_api.py
Created December 13, 2024 14:24
How to create a sub label with Gmail REST API
from email.mime.text import MIMEText
import base64
from googleapiclient.errors import HttpError
from email_editor.gmail_service import get_gmail_service
def send_gmail(body, subject, to_email, is_label, parent_label, child_label):
service = get_gmail_service()
@seansu4you87
seansu4you87 / geektools-multi-monitor.md
Last active January 4, 2025 22:04
GeekTools Multi Monitor Reposition

Geektools with Varying Monitor Setups

While I love my Geeklets, I had a pretty hard time to set them up consistently across varying monitor setups (home, work, on the go,...). The bad news first: There is no built in mechanism (as of 01/2013) to take care of this problem. Still there are good news: With some minor tinkering, you can automagically position your Geeklets across multiple setups.

The initial step is to add your Geeklets - you can totally ignore the positioning for the moment.

Which Geeklets Am I Running?