Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Doughty-Papassideris ddlsmurf

View GitHub Profile
@ddlsmurf
ddlsmurf / index.html
Last active May 22, 2021
Watchy BLE OTA client #watchy #tool
View index.html
<html>
<head>
<style>
.dragging {
background-color: rgb(236, 135, 135);
}
</style>
</head>
<body>
<h1>Watchy BLE firmware upload client</h1>
@ddlsmurf
ddlsmurf / wifi_update_client.c
Last active Aug 7, 2021
ESP32 https OTA #watchy #esp32
View wifi_update_client.c
#include <wifi_update_client.h>
#include <esp_log.h>
#include <esp32-hal.h>
#include <esp_https_ota.h>
static const char *LOG_TAG = "wifi_update_client";
const char *url = "https://raw.githubusercontent.com/sqfmi/Watchy/master/examples/WatchFaces/7_SEG/7_SEG.bin";
@ddlsmurf
ddlsmurf / pretty_json.coffee
Last active May 22, 2021
This is a very hastily cobbled together JSON prettifyer that doesn't bug me about input validity as long as unambiguous. Also it warns about a few validity issues (not all). #tool
View pretty_json.coffee
{ Transform } = require('stream')
EOL = "\n"
Utils =
spaces: (num) -> if num <= 0 then '' else (new Array(num + 1)).join(" ")
ljust: (str, len) -> str + Utils.spaces(len - str.length)
streamToString: (stream, cb) ->
len = 0
buffer = []
stream
.on('end', -> cb(null, Buffer.concat(buffer, len)))
@ddlsmurf
ddlsmurf / type.coffee
Last active May 22, 2021
More exhaustive version of typeof #snippet_js
View type.coffee
toString = Object::toString
hasOwnProperty = Object::hasOwnProperty
propertyIsEnumerable = Object::propertyIsEnumerable
toStringTags = date: '[object Date]'
Utils =
### @return `undefined|null|boolean|string|symbol|number|NaN|array|arguments|date|object|function` ###
type: (val) ->
switch type = typeof val
when 'undefined', 'string', 'boolean', 'symbol'
return type
@ddlsmurf
ddlsmurf / this_in_javascript.md
Last active May 22, 2021
what's `this` in javascript #tutorial
View this_in_javascript.md

this

Function declarations

There are two (mostly) equivalent ways to define a function:

function Add(a, b) { return a + b };

var Add = function(a, b) { return a + b };
View gist:3490e61ff090c36ec4ea
toString = Object::toString
hasOwnProperty = Object::hasOwnProperty
propertyIsEnumerable = Object::propertyIsEnumerable
### @return `undefined|null|boolean|string|symbol|number|NaN|array|arguments|date|object|function` ###
(val) ->
switch type = typeof val
when 'undefined', 'string', 'boolean', 'symbol'
return type
when 'number'
return (if Number.isNaN(val) || (val in [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]) then 'NaN' else type)
@ddlsmurf
ddlsmurf / align_cursors.py
Last active May 22, 2021
Simple sublime text 2 multiple cursor alignment command #tool
View align_cursors.py
import sublime, sublime_plugin, re
class AlignCursors(sublime_plugin.TextCommand):
def adjust_column_for_tabs(self, view, tab_size, region, rowcol):
line_text = view.substr(view.line(region))[:rowcol[1]]
return rowcol[1] + (line_text.count("\t") * (tab_size - 1))
def run(self, edit):
view = self.view
regions = view.sel()
right_most = 0
@ddlsmurf
ddlsmurf / console output
Last active May 22, 2021
Example for C users of how classes and virtual lookup tables can work. Proper memory and error management left out. #tutorial #oop
View console output
basic debug on object of type 'base', data: 0xdeadbeef
basic debug on object of type 'pointer', data: 0xdeadbeef
int debug (type 'int') value: '123'
No method 'sayHi' in 'int'
string debug (type 'string') value: 'hi guys'
Howdidledidoo 'string'
@ddlsmurf
ddlsmurf / data.json
Last active May 22, 2021
code exercise - render tree #exercise
View data.json
{"a":{"b":{"c":{"ca":{"caa":true}},"d":true},"e":{"f":true},"g":true},"h":true}
@ddlsmurf
ddlsmurf / MSC.hs
Last active May 22, 2021
MSCGen adaptation of dot plugin for gitit - http://www.mcternan.me.uk/mscgen #tool
View MSC.hs
module MSC (plugin) where
-- This plugin allows you to include a http://www.mcternan.me.uk/mscgen/ diagram
-- in a page like this:
--
-- ~~~ {.msc name="diagram1"}
-- msc {
-- # MSC for some fictional process
-- hscale = "1";
-- a,b,c;