Skip to content

Instantly share code, notes, and snippets.

View sleepdefic1t's full-sized avatar

₴Ⱡ33₱ sleepdefic1t

View GitHub Profile
@sleepdefic1t
sleepdefic1t / gist:9b9a712da907123ad6122490b2198558
Created September 14, 2018 08:37
unsigned long long with base to String
std::string toString(unsigned long long n, uint8_t base)
{
unsigned char buf[16 * sizeof(long)]; // Assumes 8-bit chars.
unsigned long long i = 0;
if (n == 0) { return "0"; };
while (n > 0) {
buf[i++] = n % base;
n /= base;
}
@sleepdefic1t
sleepdefic1t / erase_esp8266.md
Last active January 30, 2019 08:52
Erase ESP8266

./esptool --port /dev/cu.SLAB_USBtoUART erase_flash

#include <iostream>
#include <random>
int rand01()
{
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, 1);
return dis(gen);
}
@sleepdefic1t
sleepdefic1t / arduino2html.py
Created November 26, 2017 15:29
Converts raw HTML to an Arduino compatible HTML-string | cp from https://github.com/FanaHOVA/HTML2Arduino
def raw2arduino():
i = open("raw.html", 'r')
o = open("arduino.html", 'a')
for line in i.readlines():
o.write('client.println("')
o.write(line.strip("\n"))
o.write('");\n')
i.close()
o.close()
print "Done!"

Keybase proof

I hereby claim:

  • I am sleepdefic1t on github.
  • I am sleepdeficit (https://keybase.io/sleepdeficit) on keybase.
  • I have a public key ASCeOrZ37AdH_Ssay4CWojsLeRGRf7unR4RnAghHFKHduQo

To claim this, I am signing this object:

function update() {
SpreadsheetApp.getActiveSheet().getRange("F6").setValue(Math.random());
}
function getHeight(rand) {
try {
var response = UrlFetchApp.fetch("https://api.arkcoin.net/api/blocks/getHeight");
if(response.getResponseCode() === 200) {
var json = JSON.parse(response.getContentText());
@sleepdefic1t
sleepdefic1t / RPI_TIME_UPDATE
Created October 29, 2017 16:24
One-line command to update Raspberry Pi system-time. Obviously, you must be connected to the web.
// one-line time-update
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"