Skip to content

Instantly share code, notes, and snippets.

@bennotti
bennotti / crypto_xml_a3.txt
Created November 22, 2022 13:14 — forked from abernardobr/crypto_xml_a3.txt
Example XML Crypto, using A3
var SignedXml = require('xml-crypto').SignedXml;
var FileKeyInfo = require('xml-crypto').FileKeyInfo;
LocalSchema.statics.sign = function(options, cb) {
var user = options.user;
if(user.orgId !== options.payload.orgId) {
return cb(HD.errors.unauthorizedAction, {});
}
@bennotti
bennotti / $Running a Private Ethereum Blockchain using Docker.markdown Setup and run a cluster of nodes to build a private Ethereum network in Docker environment

Running a Private Ethereum Blockchain using Docker

Put genesis.json, Dockerfile, docker-compose.yml and .env files together in the same folder. Then run the command.

docker-compose up
@bennotti
bennotti / PaymentSplitter.sol
Created June 27, 2022 14:30 — forked from Chmarusso/PaymentSplitter.sol
This smart contract will automatically divide the payment amount and push it to specified recipients.
pragma solidity ^0.8.15;
// SPDX-License-Identifier: MIT
contract PaymentSplitter {
address payable [] public recipients;
event TransferReceived(address _from, uint _amount);
constructor(address payable [] memory _addrs) {
for(uint i=0; i<_addrs.length; i++){
recipients.push(_addrs[i]);
@bennotti
bennotti / TimeUtils.cs
Created March 15, 2022 22:47 — forked from AntonyKapustin/TimeUtils.cs
CurrentTimeMillis() in C#
using System;
public class TimeUtils {
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long CurrentTimeMillis()
{
return (long) (DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
@bennotti
bennotti / web-servers.md
Created January 3, 2022 00:16 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@bennotti
bennotti / README.md
Created December 5, 2021 13:53 — forked from henrebotha/README.md
How to set up a TypeORM playground

How to set up a TypeORM playground

This guide is intended for people who'd like to experiment with TypeORM in a hands-on fashion. I find this especially helpful when attempting to construct complex queries.

Prerequisites

You need Yarn and Docker installed.

Process

/* PAGINATION WITH SORTING AND PAGING */
const page = 1; // input page, min value 1
const limit = 2; // input limit min value 1
/* INPUT ARRAY */
const array = [
{ Editable: true, Name: "Daniel Test", Site: "SE100"},
{ Editable: true, Name: "Test new", Site: "SE100"},
{ Editable: false, Name: "Test", Site: "SE100"},
];
@bennotti
bennotti / gist:2735ac7ebcf73a375e845a03b27a0f06
Created September 25, 2021 00:02 — forked from pironim/gist:2f578c60afb67f156136
git pre-commit hook to check branch name
#!/bin/bash
#
# Pre-commit hooks
# Check branch name
BRANCH_NAME_LENGTH=`git rev-parse --abbrev-ref HEAD | grep -E '^t[0-9]{2,16}\_.*_[A-Za-z]{2,2}$' | wc -c`
if [ ${BRANCH_NAME_LENGTH} -eq 0 ] ; then
echo -e '\E[37;44m'"\033[1mERROR\033[0m in pre-commit hook: vim /export/web/.git/hooks/pre-commit"
echo "Branch name should be like t00000_blah_blah_CA - brand is two letters"
@bennotti
bennotti / post-merge
Created September 24, 2021 21:14 — forked from jeffsrepoaccount/post-merge
Git post merge hook for auto-tagging release/hotfix branches based off of branch name
#!/usr/bin/env bash
###############################################################################
#
# Automatically detects a merge on to master from a gitflow-style release
# branch, e.g. release-1.1.1-alpha. If the merged branch matches, the major,
# minor and patch versions are determined and a new release tag is created
# locally. If remote origin exists, this tag will automatically be pushed.
#
# In addition to creating a tag, the release branch will automatically be
# merged into the develop branch. If the branch has already been merged this
@bennotti
bennotti / semantic-commit-messages.md
Created September 1, 2021 20:54 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example