Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
a = 2667
b = 5334
c = 19
target = 200000
bestresidual = target
bestz = target / c
@theKlanc
theKlanc / tinyADC.h
Last active January 15, 2022 14:04
Header for reading from a tinyADC with an RP2040, should be relatively easy to port to other platforms. Schematic https://imgur.com/a/BCRmzeb
#pragma once
#include "pico/stdlib.h"
#include <optional>
namespace {
unsigned long pulseWidthMicros = 10;
unsigned long timelimitMicros = 4000000;
unsigned int getPulseLen(uint pin){
while(!gpio_get(pin)){}
@theKlanc
theKlanc / tinyADC.ino
Created January 11, 2022 23:22
Code to use an ATTiny as an ADC using https://github.com/MCUdude/MicroCore
const int pulsePin = 4;
const analog_pin_t readPin = A3;
//const unsigned pulseWidthMicros = 10000;
const unsigned pulseWidthMicros = 3000;
void setup() {
pinMode(pulsePin, OUTPUT);
digitalWrite(pulsePin, LOW);
pinMode(readPin, INPUT);
}
@theKlanc
theKlanc / autoexec.cfg
Created October 16, 2021 16:15
CSGO autoexec
fps_max 999
cl_crosshairgap -1.596189
cl_crosshairstyle 4
cl_crosshair_t 1
cl_crosshairthickness 0.5
bind o "toggle cl_crosshairsize 2.923049 9999"
bind i r_cleardecals
bind p "toggle r_drawclipbrushes 0 1 2"
host_writeconfig
@theKlanc
theKlanc / updateRecord.sh
Last active March 15, 2018 22:48
Script to update an A record on cloudflare using the REST API
#!/bin/bash
ip=`curl http://ipv4.icanhazip.com | tr -d '[:space:]'`
zoneID="ZONE ID GOES HERE"
domainID="DOMAIN ID GOES HERE"
domainName="YOUR (SUB)DOMAIN TO UPDATE HERE"
emailAddress="[email protected]"
rootDomain="YOUR DOMAIN (NO SUBDOMAIN)"
ttl="120"
APIKey="APIKEY GOES HERE"
command="curl -X PUT \"https://api.cloudflare.com/client/v4/zones/$zoneID/dns_records/$domainID\" -H \"X-Auth-Email: $emailAddress\" -H \"X-Auth-Key: $APIKey\" -H \"Content-Type: application/json\" --data '{\"type\":\"A\",\"name\":\"$domainName\",\"content\":\"$ip\",\"ttl\":$ttl,\"proxied\":false}'"
@theKlanc
theKlanc / dashButton.py
Last active November 28, 2017 21:44
python3 code for a dash button listener
#!/usr/bin/python3
import subprocess
import time
while True:
subprocess.call("sudo tcpdump ether host XX:XX:XX:XX:XX:XX -c 1 > /dev/null 2>&1",shell=True)
print("kek")
time.sleep(7)
@theKlanc
theKlanc / timeDilation.cpp
Created September 5, 2017 20:05
Calculates how fast you were moving relative to c to justify being late.
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
const double light_spd = 2.99792458e8;
double toSeconds(string temp) {
double temps = stoi(temp.substr(0,temp.length()-1));
@theKlanc
theKlanc / enCaneVolAlgo.cpp
Last active February 24, 2018 00:16
Given a sequence of single bytes written in hex, uses +-&|^ as operations between a subset of the first n-1 numbers that results in the nth number,. Fixed return propagation in recursive case. Lines 104 to 113 are for debugging purposes, delete if needed.
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <sstream>
#include <fstream>
#include <iomanip>
using namespace std;
class operacio {
public:
#include <iostream>
#include <string>
#include <cctype>
#include <Windows.h>
using namespace std;
void toClipboard(const std::string &s) {
OpenClipboard(0);
EmptyClipboard();
HGLOBAL hg = GlobalAlloc(GMEM_MOVEABLE, s.size());
@theKlanc
theKlanc / renamer.sh
Last active April 10, 2017 14:10
Renamer script (mainly for anime/tv series)
#!/bin/bash
function preguntar {
while IFS='\n' read -r line || [[ -n "$line" ]]; do
extension="${line##*.}"
filename=$(basename "$line")
filename="${filename%.*}"
IFS=$4
number="$(echo $filename | sed 's/ \+/ /g' | cut -d" " -f$1)"
newname=$number$5$filename"."$extension
if [ "$2" = true ] ; then