Skip to content

Instantly share code, notes, and snippets.

View michalmonday's full-sized avatar

Michal Borowski michalmonday

  • Colchester, UK
View GitHub Profile
@jlesech
jlesech / assert.ino
Created July 11, 2012 11:55
How to use assertions with Arduino.
#define __ASSERT_USE_STDERR
#include <assert.h>
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
@syazawa
syazawa / FileLocking.java
Created March 3, 2015 06:59
Example of inter-process and inter-thread file locking in Java
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileLock;
// The class demonstrates how to get an exclusive file lock that prevents other threads and processes / JVMs from
// obtaining a lock on the same file. To do this, you need to synchronize a block on a file and acquire FileLock. See
// comments below for more details. Run this class in multiple JVMs and see each thread of each JVM acquires a lock in
// an orderly fasion.
public class FileLocking extends Thread
@benjbaron
benjbaron / QGraphicsSceneTest.cpp
Last active April 22, 2022 03:13
Qt QGraphicsScene click, select, move, resize, delete QGraphicsItems
#include <QtGui>
#include <QGraphicsRectItem>
#include <QGraphicsView>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
class CustomItem : public QGraphicsEllipseItem
{
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event)
@iminurnamez
iminurnamez / state_engine.py
Last active June 12, 2024 15:49
Simple state engine example
#This code is licensed as CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/legalcode).
import sys
import pygame as pg
class Game(object):
"""
A single instance of this class is responsible for
managing which individual game state is active
@spacehuhn
spacehuhn / arduino_flash_esp8266.md
Last active January 16, 2024 18:14
Flash ESP8266 over an Arduino

How to flash your ESP8266 without a USB-Serial adapter but with an Arduino.

First be sure everything is connected correcly:

Arduino ESP82666
TX RX
RX TX
GND GND
GND GPIO-15

Demo:

Spoiler warning

Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag... just make sure you close <details> afterward.

console.log("I'm a code block!");
@AhnMo
AhnMo / http_client_get.cc
Last active September 17, 2024 17:14
Wininet HTTP Client Example
#include <windows.h>
#include <wininet.h>
#include <stdio.h>
#pragma comment (lib, "Wininet.lib")
int main(int argc, char *argv[]) {
HINTERNET hSession = InternetOpen(
L"Mozilla/5.0", // User-Agent
@spacehuhn
spacehuhn / deauthall.md
Last active September 19, 2020 21:53
Deauth-All-Button

Disclaimer

Applying and using the following modifications are up to your responsibility.
I provide this example for you to better understand the code and how such an automatic attack-all could work.
It doesn't mean it will work, I won't provide you with further assistence, or keep this up-to-date.
These modifications make it easy to attack devices you wouldn't want to attack, keep that in mind!
You may easily violate law by using such an attack in public space.


@Zodt
Zodt / Program.cs
Last active October 3, 2022 05:32
C# Enumerate like in python through Extensions class
// C#9
using System;
using System.Collections.Generic;
foreach (var (value, index) in 5..10)
{
Console.WriteLine($"Value = {value.ToString()}, Index = {index.ToString()}");
}
public static class RangeExtensions
@ritiek
ritiek / ffmpeg_stdin.py
Last active April 9, 2024 19:06
Using FFmpeg to read input via stdin in Python
# pip install pytube3
import pytube
import urllib.request
import subprocess
content = pytube.YouTube("https://www.youtube.com/watch?v=YQHsXMglC9A")
streams = content.streams.filter(only_audio=True).order_by("abr").desc()
response = urllib.request.urlopen(streams[0].url)