Skip to content

Instantly share code, notes, and snippets.

View quantumsheep's full-sized avatar
🐑
S H E E P

Nathanael Demacon quantumsheep

🐑
S H E E P
View GitHub Profile
variable "scaleway_project_id" {
type = string
description = "Scaleway project ID"
}
variable "scaleway_secret_key" {
type = string
sensitive = true
}
#include <Dns.h>
#include <PubSubClient.h>
#include <WiFi.h>
#define CLIENT_ID "clientid"
#define TOPIC_IN "topicin"
#define TOPIC_OUT "topicout"
WiFiClient wifiClient;
PubSubClient mqttClient(wifiClient);
@quantumsheep
quantumsheep / llvm-type-equality.cpp
Last active April 20, 2020 11:00
Compare LLVM IR Types. Implementation based on cmpTypes function from llvm/lib/Transforms/Utils/FunctionComparator.cpp.
#include <llvm/IR/DerivedTypes.h>
#include <llvm/Transforms/Utils/FunctionComparator.h>
bool equals(const llvm::Type *left, const llvm::Type *right)
{
auto left_ptr = llvm::dyn_cast<llvm::PointerType>(left);
auto right_ptr = llvm::dyn_cast<llvm::PointerType>(right);
if (left == right)
return true;
(function () {
const interval = {
min: 15000,
max: 30000,
}
function add_random() {
const peoples = document.querySelectorAll("button[id^=ember]:not(.artdeco-button--muted)")
const i = Math.floor(Math.random() * peoples.length)
@quantumsheep
quantumsheep / vodeclic-bot.user.js
Last active April 18, 2019 08:36
TamperMonkey Vodeclic Bot
// ==UserScript==
// @name Vodeclic bot
// @version 0.5
// @description Bot for vodeclic
// @author QuantumSheep
// @include *://*.vodeclic.com/*/formation/*
// @include *://*.vodeclic.com/*/course/*
// ==/UserScript==
(function() {
@quantumsheep
quantumsheep / setscreen.sh
Created February 7, 2019 14:43
Add 1920x1080 resolution with xrandr in VMWare (Virtual1 monitor)
xrandr --newmode "1920x1080" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode Virtual1 1920x1080
xrandr --output Virtual1 --mode 1920x1080
@quantumsheep
quantumsheep / flen.c
Created December 6, 2018 09:17
Calculate a file length. The file need to be in `rb` mode (reading and binary mode)
#include <stdio.h>
int flen(FILE *f)
{
int len;
int origin = ftell(f);
fseek(f, 0, SEEK_END);
len = ftell(f);
/**
* @param {number} start
* @param {number} end
* @returns {number[]}
*/
function range(start, end) {
if (start > end) return [];
return [...Array(end - start + 1).keys()].map(i => i + start);
}

Keybase proof

I hereby claim:

  • I am quantumsheep on github.
  • I am quantumsheep (https://keybase.io/quantumsheep) on keybase.
  • I have a public key ASDhoA1jmGOWPj7gwYyIqMaNDsM9zFgl2GqhdfEP89xEEQo

To claim this, I am signing this object:

@quantumsheep
quantumsheep / progress_bar.js
Created November 14, 2018 10:49
Progress bar generator function
/**
*
* @param {number} percents / 100
* @param {number} length
* @param {object} phases
* @param {string} phases.filled
* @param {string} phases.empty
* @param {string} phases.partial
*/
function progress_bar(percents, length = 10, phases = { filled: '█', empty: '░', partial: '▓' }) {