This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A callback function that is called when a value changes. | |
* @callback SubscriptionCallback | |
* @param {any} value The new value. | |
* @returns {void} | |
*/ | |
type SubscriptionCallback<T = any> = (value: T) => void; | |
/** | |
* A simple client-side storage class that uses localStorage to store values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Find all Vue components that match the given matcher and return them in an array. | |
* @param parent The parent component to search. | |
* @param matcher The matcher to use. | |
* @returns An array of components that match the given matcher. | |
*/ | |
export const findVueChildComponents = (parent: any, matcher: RegExp | String | undefined) => { | |
const found: any[] = []; | |
const root = parent.$.subTree; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const h = (tag, attrs, ...children) => { | |
const elm = document.createElement(tag) | |
for (let key in attrs) { | |
if (key.slice(0, 2) == 'on') { | |
const evtName = key.slice(2) | |
const cb = attrs[key] | |
if (cb == null) continue // we can use null or undefnied to suppress | |
elm.addEventListener(evtName, cb) | |
} else if (['disabled', 'autocomplete', 'selected', 'checked'].indexOf(key) > -1) { | |
if (attrs[key]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type TokenType = 'KEYWORD' | 'IDENTIFIER' | 'NUMBER' | 'STRING' | 'OPERATOR' | 'DELIMITER' | 'EOF' | 'UNKNOWN' | 'PROCEDURE' | 'FUNCTION' | 'CONSTANT' | 'RECORD'; | |
class Token { | |
constructor(public type: TokenType, public value: string, public position: number, public line: number, public column: number) {} | |
} | |
class Lexer { | |
private pos: number = 0; | |
private line: number = 1; | |
private column: number = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In Belgium there is a possibility to have a prepaid smart meter for electricity. Fluvius has an app and webpage where you can see the details. | |
I wanted to incorporate this api into a dashboard for a client, so for this purpose i tried to fetch the data myself. Use this on you own risk! | |
I contacted fluvius to ask if i could access their api for this purpose, but i didnt get an answer. So im sharing it here for anyone else who likes to do the same. | |
GET /prepaid/api/prepaid-contracts HTTP/1.1 | |
Host: mijn.fluvius.be | |
X-Fluv-Prepaid-Identification-Code: <UNIQUE-PREPAID-CODE> | |
X-Fluv-Prepaid-Postal-Code: <ZIPCODE> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate a color based on letters. | |
export const generateColor = (letters) => { | |
// Generate a simple hash from a string | |
const getHashOfString = (str) => { | |
let hash = 0; | |
for (let i = 0; i < str.length; i++) { | |
hash = str.charCodeAt(i) + ((hash << 5) - hash); | |
} | |
hash = Math.abs(hash); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const parseDFM = (text) => { | |
let result = null; | |
// Replace all returns with newlines | |
text = text.replace(/\r\n/g, '\n'); | |
text = text.replace(/\r/g, '\n'); | |
// Split into lines | |
const lines = text.split('\n'); | |
let currentComponent = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit untHTTPManager; | |
interface | |
uses | |
System.Classes, System.SysUtils, System.Generics.Collections, System.Threading, IdHTTP, IdSSLOpenSSL, | |
Winapi.Windows, Winapi.Messages; | |
type | |
THTTPThreadManager = class; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This generator does not generate valid keys for any software, its merely a demonstration of | |
how to create a simple license key registration and validation system. You could store the | |
generated license keys on the server, and add online-validation when the user wants to use | |
the entered key to register your application. | |
** DO NOT ** use these as is in your production code (DUHH!) | |
*/ | |
// Master key is the sum of the license key characters. This sum is the same for every key. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Terminal colors and style | |
*/ | |
const Color = { | |
Reset: "\x1b[0m", | |
Bright: "\x1b[1m", | |
Dim: "\x1b[2m", | |
Underscore: "\x1b[4m", | |
Blink: "\x1b[5m", | |
Reverse: "\x1b[7m", |
NewerOlder