Skip to content

Instantly share code, notes, and snippets.

View tomconte's full-sized avatar
💻
Working from home

Thomas Conté tomconte

💻
Working from home
View GitHub Profile
@tomconte
tomconte / containerd-certificate-ds.yaml
Last active February 14, 2024 11:02
This is a Kubernetes DaemonSet definition that will install a custom certificate on the nodes and restart containerd. This is useful if your private registry is protected using a self-signed certificate. Not tested in production.
apiVersion: v1
kind: ConfigMap
metadata:
name: trusted-ca
namespace: kube-system
data:
ca.crt: |+
-----BEGIN CERTIFICATE-----
MIIFkTCCA3mgAwIBAgIUCXaMcLg8teiGZ7o0dIQRIOdHEA8wDQYJKoZIhvcNAQEL
BQAweDELMAkGA1UEBhMCRlIxDDAKBgNVBAgMA04vQTEMMAoGA1UEBwwDTi9BMSAw
@tomconte
tomconte / snapshot_utility.py
Created July 23, 2014 16:25
Sample Python script to manage Azure Blob Storage snapshots: list snapshots, take a snapshot, delete a snapshot, copy a snapshot to a new Blob.
#!/usr/bin/python
from azure.storage import BlobService
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("container", help="the blob container")
parser.add_argument("blob", help="the blob name")
parser.add_argument("-s", "--snapshot", help="take a new snapshot", action="store_true")
parser.add_argument("-d", "--delete", help="delete a snapshot")
@tomconte
tomconte / upload_azure_blob_sas.js
Created September 24, 2014 08:13
Upload a Blob to Azure Storage using Shared Access Signatures (SAS) in Node.JS
var fs = require('fs');
var https = require('https');
var blob_host = 'tconeu.blob.core.windows.net';
var blob_container = 'tessel-uploads';
// Use any tool to generate a Shared Access Key e.g. Azure Management Studio
var blob_sas = '?sr=c&sv=2014-02-14&si=tessel&sig=xxxxRv%2xxxxUTd8xxxxMKc0xxxxi%2Fxxxxw6VsxxxxGjdJxxxx';
var blob_name = 'test.jpg';
@tomconte
tomconte / web3-solc-contract-compile-deploy.js
Created December 13, 2016 09:32
Compiling and deploying an Ethereum Smart Contract, using solc and web3.
const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');
// Connect to local Ethereum node
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
// Compile the source code
const input = fs.readFileSync('Token.sol');
const output = solc.compile(input.toString(), 1);
@tomconte
tomconte / send_iot-hub_paho_mqtt.py
Created May 12, 2016 09:32
This is a simple example showing how to use the [Paho MQTT Python client](https://eclipse.org/paho/clients/python/) to send data to Azure IoT Hub. You need to assemble the rights credentials and configure TLS and the MQTT protocol version appropriately.
#!/usr/bin/python
import paho.mqtt.publish as publish
import paho.mqtt.client as mqtt
import ssl
auth = {
'username':"ciscohackhub.azure-devices.net/lora1",
'password':"SharedAccessSignature sr=ciscohackhub.azure-devices.net%2Fdevices%2Flora1&sig=xxxx&se=1463048772"
}
@tomconte
tomconte / compile-deploy-sign.js
Created January 3, 2017 14:25
Shows how to compile and deploy a Smart Contract using client-side transaction signature, i.e. does not require the account to be unlocked in the Ethereum node.
const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');
const Tx = require('ethereumjs-tx')
// Private key to use to sign the transactions
// To decrypt your private key, use e.g. https://www.myetherwallet.com/#view-wallet-info
// You will find your private key file in e.g. .ethereum/keystore or .parity/keys
// In this example the key should correspond to the web3.eth.coinbase address
var privateKey = new Buffer('088c110b6861b6c6c57461370d661301b29a7570d59cb83c6b4f19ec4b47f642', 'hex')
@tomconte
tomconte / genc64clut.py
Created September 16, 2012 18:32
Generate a Color Look Up Table (CLUT) for the Commodore 64 palette, using the Python Image Library (PIL)
#!/usr/local/bin/python
import math
import Image
# C64 color palette
COLOR_BLACK = (0, 0, 0)
COLOR_WHITE = (255, 255, 255)
COLOR_RED = (104, 55, 43)
@tomconte
tomconte / function.json
Created September 26, 2016 14:49
Node.JS Azure Function to resize images, using the pure JavaScript Jimp library. A Blob Trigger is used to detect incoming files, and a Blob Output binding is used to write the scaled image.
{
"bindings": [
{
"name": "inputBlob",
"type": "blobTrigger",
"dataType": "binary",
"direction": "in",
"path": "images-in/{name}",
"connection": "function821251a1b074_STORAGE"
},
@tomconte
tomconte / truffle-config.js
Last active July 14, 2019 03:38
Example Truffle 3.0 configuration file to allow deploying contracts to an Azure "Bletchley" Ethereum consortium network. Based on the Truffle docs for Infura (http://truffleframework.com/tutorials/using-infura-custom-provider).
var bip39 = require("bip39");
var ethwallet = require('ethereumjs-wallet');
var ProviderEngine = require("web3-provider-engine");
var WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js');
var Web3Subprovider = require("web3-provider-engine/subproviders/web3.js");
var Web3 = require("web3");
// Insert raw hex private key here, e.g. using MyEtherWallet
var wallet = ethwallet.fromPrivateKey(Buffer.from('abcdef', 'hex'));
@tomconte
tomconte / bag_to_images.py
Created June 18, 2019 12:26 — forked from wngreene/bag_to_images.py
Extract images from a rosbag.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2016 Massachusetts Institute of Technology
"""Extract images from a rosbag.
"""
import os
import argparse