Skip to content

Instantly share code, notes, and snippets.

@AnthoniG
AnthoniG / DAG_MySQL.sql
Created October 23, 2022 04:07 — forked from xib/DAG_MySQL.sql
Direct Acyclic Directed Graph in MySQL database
-- Based on the original articel at http://www.codeproject.com/Articles/22824/A-Model-to-Represent-Directed-Acyclic-Graphs-DAG-o
-- Here is a port to MySQL
-- Edge table
DROP TABLE IF EXISTS `Edge`;
CREATE TABLE IF NOT EXISTS `Edge` (
`id` int(11) NOT NULL,
`entry_edge_id` int(11) DEFAULT NULL COMMENT 'The ID of the incoming edge to the start vertex that is the creation reason for this implied edge; direct edges contain the same value as the Id column',
`direct_edge_id` int(11) DEFAULT NULL COMMENT 'The ID of the direct edge that caused the creation of this implied edge; direct edges contain the same value as the Id column',
`exit_edge_id` int(11) DEFAULT NULL COMMENT 'The ID of the outgoing edge from the end vertex that is the creation reason for this implied edge; direct edges contain the same value as the Id column',
@AnthoniG
AnthoniG / encryption.js
Created September 29, 2022 07:30 — forked from anned20/encryption.js
Encrypting files with NodeJS
const crypto = require('crypto');
const algorithm = 'aes-256-ctr';
let key = 'MySuperSecretKey';
key = crypto.createHash('sha256').update(String(key)).digest('base64').substr(0, 32);
const encrypt = (buffer) => {
// Create an initialization vector
const iv = crypto.randomBytes(16);
// Create a new cipher using the algorithm, key, and iv
const cipher = crypto.createCipheriv(algorithm, key, iv);
@AnthoniG
AnthoniG / encrypt-decrypt_in_node.js
Created September 6, 2022 11:51 — forked from siwalikm/encrypt-decrypt_in_node.js
Encryption and decryption with Nodejs crypto
var crypto = require('crypto'),
algo = 'aes-256-cbc',
key = 'super123secretKey!';
function encrypt(text){
var cipher = crypto.createCipher(algo,key)
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
@AnthoniG
AnthoniG / aes-256-cbc.js
Created September 6, 2022 11:51 — forked from siwalikm/aes-256-cbc.js
AES-256-CBC implementation in nodeJS with built-in Crypto library
'use strict';
const crypto = require('crypto');
const ENC_KEY = "bf3c199c2470cb477d907b1e0917c17b"; // set random encryption key
const IV = "5183666c72eec9e4"; // set random initialisation vector
// ENC_KEY and IV can be generated as crypto.randomBytes(32).toString('hex');
const phrase = "who let the dogs out";
var encrypt = ((val) => {
import 'package:flutter/widgets.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
// adapted from https://stackoverflow.com/a/54173729/67655
class ExpandableSection extends HookWidget {
const ExpandableSection({
Key key,
this.expanded = false,
this.child,
@AnthoniG
AnthoniG / main.dart
Created August 3, 2022 07:52 — forked from AdamJonsson/main.dart
An example how different widget can be used to expand and collapse content in Flutter
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Expanding Demo',
theme: ThemeData(
@AnthoniG
AnthoniG / browser-colors.ts
Created July 21, 2022 07:47
browser-colors
{
"aliceblue",
"antiquewhite",
"aqua",
"aquamarine",
"azure",
"beige",
"bisque",
"black",
"blanchedalmond",
@AnthoniG
AnthoniG / gtk4_template.py
Created July 19, 2022 04:57
python GTK4 app template
# Load Gtk
import gi
gi.require_version('Gtk', '4.0')
from gi.repository import Gtk
# When the application is launched…
def on_activate(app):
# … create a new window…
win = Gtk.ApplicationWindow(application=app)
# … with a button in it…
#!/usr/bin/env python3
# Python imports
import sys
# GTK imports
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gio
from gi.repository import Gtk
@AnthoniG
AnthoniG / app.py
Created July 18, 2022 14:26 — forked from carlos-jenkins/app.py
How to programatically add new menu items to menu item in PyGObject.
"""
Hierarchy is:
- GtkMenuBar
- GtkMenuItem
- GtkMenu
- GtkMenuItem
- GtkImageMenuItem
- GtkCheckMenuItem
- GtkRadioMenuItem
- GtkSeparatorMenuItem