Skip to content

Instantly share code, notes, and snippets.

View Anderson-Juhasc's full-sized avatar

Anderson Juhasc Anderson-Juhasc

View GitHub Profile
@Anderson-Juhasc
Anderson-Juhasc / bech32.js
Created February 23, 2023 19:31
bitcoinjs-lib and Elliptic.js to generate a bech32 address
const bitcoin = require('bitcoinjs-lib');
const EC = require('elliptic').ec;
const ec = new EC('secp256k1');
// Generate a random private key
const privateKey = ec.genKeyPair().getPrivate('hex');
// Convert the private key to a BitcoinJS keypair
const keyPair = bitcoin.ECPair.fromPrivateKey(Buffer.from(privateKey, 'hex'));
@Anderson-Juhasc
Anderson-Juhasc / index.js
Last active December 10, 2022 09:27
Taproot(p2tr) with BIP38
const { ECPairFactory } = require('ecpair')
const bitcoin = require('bitcoinjs-lib')
const ecurve = require('ecurve')
const secp256k1 = ecurve.getCurveByName('secp256k1')
const schnorr = require('bip-schnorr')
const { bech32, bech32m } = require('bech32')
const bip38 = require('bip38')
const wif = require('wif')
@Anderson-Juhasc
Anderson-Juhasc / constants.js
Last active May 11, 2021 13:21
dogecoin js
module.exports = {
NETWORKS: {
dogecoin: {
messagePrefix: '\x19Dogecoin Signed Message:\n',
bip32: {
public: 0x02facafd,
private: 0x02fac398
},
pubKeyHash: 0x1e,
scriptHash: 0x16,
@Anderson-Juhasc
Anderson-Juhasc / bip84.js
Last active January 2, 2020 18:09
BIP84 - Derives segwit + bech32 addresses from zpub and vpub in javascript: https://www.npmjs.com/package/bip84
const bjs = require('bitcoinjs-lib')
, b58 = require('bs58check')
function BIP84(pub) {
// mainnet
this.pub_types = [
'04b24746', // zpub
'02aa7ed3', // Zpub
]
const isImage = (name, msg, req) => {
let proof = typeof req.files[name] !== "undefined" ? req.files[name] : undefined;
if (!proof) {
throw new Error(msg)
}
switch (proof.type) {
case 'image/jpeg':
return 'image/jpeg';
$breakpoints: "palm" "(max-width: 480px)", "lap" "(min-width: 481px)", "portable" "(max-width: 1023px)", "desk" "(min-width: 1024px)", "desk-wide" "(min-width: 1200px)" !default
=media-query($media-query)
$breakpoint-found: false
@each $breakpoint in $breakpoints
$name: nth($breakpoint, 1)
$declaration: nth($breakpoint, 2)
@if $media-query == $name and $declaration
$breakpoint-found: true
@media only screen and #{$declaration}
const find = ( Model ) => ( query, sort = {} ) =>
Model.find({}).or( query ).sort( sort ).exec()
const findOne = ( Model ) => ( query, populate = '' ) =>
Model.findOne( query ).populate( populate ).exec()
const count = ( Model ) => ( query ) =>
Model.count( query ).exec()
const save = ( Model ) =>
@Anderson-Juhasc
Anderson-Juhasc / bancocripto.txt
Created March 19, 2018 18:07
bancocripto tasks
- Textos, imagens e css da landing page
- Página de contato
- Página de Termos
- Criar página no g+
- Upload de fotos em perfil
- Validar todos os formulários
- Módulo de envio de emails
-
function carregarLocalizacao(dest) {
navigator.geolocation.getCurrentPosition(showpos, error, options);
function showpos(position) {
var lat = position.coords.latitude
, lng = position.coords.longitude;
console.log(lat + " " + lng);
location.href = 'https://maps.google.com/maps?saddr=' + lat + ',' + lng + '&daddr=' + dest;