Skip to content

Instantly share code, notes, and snippets.

@zgorizzo69
zgorizzo69 / hex-pem-hex-secp256k1-pub-priv-key-encoding-and-decoding.js
Last active August 29, 2023 03:00
from a priv key in hex to pem encoding and decoding back to hex for both public and private key using EC secp256k1
const jose = require("jose");
const ethers = require("ethers");
const {
JWE, // JSON Web Encryption (JWE)
JWK, // JSON Web Key (JWK)
JWKS, // JSON Web Key Set (JWKS)
JWS, // JSON Web Signature (JWS)
JWT, // JSON Web Token (JWT)
@zgorizzo69
zgorizzo69 / ca-crt-config-map.yaml
Created April 2, 2020 22:44
drone-vault extension kubernetes resources from our blog.cogarius.com
apiVersion: v1
kind: ConfigMap
metadata:
name: ca-crt
namespace: drone
data:
kubca.crt: |
-----BEGIN CERTIFICATE-----
MIICMzCCAZygAwIBAgIJALiPnVsvq8dsMA0GCSqGSIb3DQEBBQUAMFMxCzAJBgNV
BAYTAlVTMQwwCgYDVQQIEwNmb28xDDAKBgNVBAcTA2ZvbzEMMAoGA1UEChMDZm9v
@zgorizzo69
zgorizzo69 / drone-runner-kube-values.yaml
Created April 2, 2020 21:10
drone server and drone runner for kubernetes chart values example for blog.cogarius.com
image:
repository: drone/drone-runner-kube
tag: 1.0.0-beta.1
pullPolicy: IfNotPresent
## If you need to pull images from a private Docker image repository, pass in the name
## of a Kubernetes Secret that contains the needed secret. For more details, see:
## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
##
imagePullSecrets: []
@zgorizzo69
zgorizzo69 / Drone CI-grafana dashboard.json
Created March 25, 2020 12:47
grafana dashboard for Drone.io Drone CI with kubernetes runner
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@zgorizzo69
zgorizzo69 / reservation_zos.sh
Last active June 3, 2019 14:11
error while reserving zos on testnet branch development_installer
JSX> res = w.capacity.reserve_zos_vm('[email protected]','t1000.example','ac1f6b457338',2)
1
Mon 03 14:09:13 BCDB.py - 428 - bcdb:bcdb : load model:
jumpscale.threefold_directory.client
Mon 03 14:09:13 BCDB.py - 428 - bcdb:bcdb : load model:
jumpscale.gedis.client
Mon 03 14:09:13 GedisClient.py - 138 - j.clients.gedis:gedisclient : redisclient
: notary.grid.tf:5000
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
@zgorizzo69
zgorizzo69 / gaia.storage.service.js
Last active November 16, 2018 12:10
gaia blockstack storage service example
import { Injectable } from '@angular/core';
import * as blockstack from 'blockstack';
import { Observable, from, of } from 'rxjs';
import { tap, map, catchError } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class StorageService {
@zgorizzo69
zgorizzo69 / authresponsetoken.js
Last active November 14, 2018 19:48
blockstack publickey inside authresponsetoken
{
header: {
alg: "ES256K"
typ: "JWT"
},
payload: {
core_token: null,
email: null,
exp: 1544801401,
hubUrl: "https://hub.blockstack.org",
@zgorizzo69
zgorizzo69 / search.js
Created November 14, 2018 18:23
blockstack search and lookup
private searchUrl = 'https://core.blockstack.org/v1/search';
public searchContacts(queryValue: string): Observable<ContactSearchResult[]> {
if (!queryValue || queryValue.trim().length < 1) {
return of(new Array<ContactSearchResult>());
}
return this.http.get<BlockstackSearchResponse>(this.searchUrl, { params: { query: queryValue.trim() } })
.pipe(
map((r: BlockstackSearchResponse) => {
return r.results.map(i => this.mapToSearchResult(i));
})
@zgorizzo69
zgorizzo69 / authentication.js
Last active November 14, 2018 18:15
blockstack authentication
/*
Every app that uses multi-player storage must add itself to the user's profile.json file.
The Blockstack Browser will handle this part automatically when the publish_data scope is requested during authentication.
to read a another user file, you just need to call getFile with the appropriate options:
const options = { username: username, decrypt: false, zoneFileLookupURL: 'https://core.blockstack.org/v1/names/'}
getFile(statusFileName, options)
*/
signIn() {
const origin = window.location.origin;
var CryptoJS = require("crypto-js");
const zonefile = '$ORIGIN jude.id\n$TTL 3600\n_https._tcp URI 10 1 \"https://raw.githubusercontent.com/jcnelson/profile/master/jude.id\"\n_https._tcp URI 10 1 \"https://www.cs.princeton.edu/~jcnelson/jude.id\"\n';
const zonefilehash = cryptoJS.RIPEMD160(cryptoJS.SHA256(this.zonefile));
console.log(zonefilehash);