Skip to content

Instantly share code, notes, and snippets.

Avatar
🤺
Programming

José Aguirre josejaguirre

🤺
Programming
View GitHub Profile
@tomsihap
tomsihap / gist:e703b9b063ecc101f5a4fc0b01a514c9
Created Dec 23, 2018
Install NVM in Ubuntu 18.04 with ZSH
View gist:e703b9b063ecc101f5a4fc0b01a514c9
# Find the latest version on https://github.com/creationix/nvm#install-script
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
# Add in your ~/.zshrc the following:
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
$ source ~/.zshrc
@samanshahmohamadi
samanshahmohamadi / sawtooth-default-multi.yaml
Created Oct 16, 2018
Hyperledger Sawtooth configuration to setup a network with multiple validators.
View sawtooth-default-multi.yaml
# Copyright 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
View awslambda.bootstrap.py
# -*- coding: utf-8 -*-
# /var/runtime/awslambda/bootstrap.py
"""
aws_lambda.bootstrap.py
Amazon Lambda
Copyright (c) 2013 Amazon. All rights reserved.
Lambda runtime implemention
"""
@nakov
nakov / secp256k1-example.js
Last active Jul 18, 2022
ECDSA in JavaScript: secp256k1-based sign / verify / recoverPubKey
View secp256k1-example.js
let elliptic = require('elliptic');
let sha3 = require('js-sha3');
let ec = new elliptic.ec('secp256k1');
// let keyPair = ec.genKeyPair();
let keyPair = ec.keyFromPrivate("97ddae0f3a25b92268175400149d65d6887b9cefaf28ea2c078e05cdc15a3c0a");
let privKey = keyPair.getPrivate("hex");
let pubKey = keyPair.getPublic();
console.log(`Private key: ${privKey}`);
console.log("Public key :", pubKey.encode("hex").substr(2));
@althonos
althonos / setup.cfg
Last active Jul 18, 2022
A `setup.cfg` template for my Python projects
View setup.cfg
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c
[metadata]
name = {name}
version = file: {name}/_version.txt
author = Martin Larralde
author_email = martin.larralde@embl.de
url = https://github.com/althonos/{name}
description = {description}
long_description = file: README.md
@rluts
rluts / token_auth.py
Last active Jul 11, 2022
Token authorization middleware for Django Channels 2
View token_auth.py
from channels.auth import AuthMiddlewareStack
from rest_framework.authtoken.models import Token
from django.contrib.auth.models import AnonymousUser
from django.db import close_old_connections
class TokenAuthMiddleware:
"""
Token authorization middleware for Django Channels 2
"""
View README.md

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);
@n1ru4l
n1ru4l / index.js
Created Aug 7, 2017
Fetch blob and convert to base64
View index.js
export const fetchAsBlob = url => fetch(url)
.then(response => response.blob());
export const convertBlobToBase64 = blob => new Promise((resolve, reject) => {
const reader = new FileReader;
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result);
};
reader.readAsDataURL(blob);
@codephillip
codephillip / CustomListCreateApi.py
Created Aug 2, 2017
ListCreateAPIView in django rest framework with different serializer for the GET and POST
View CustomListCreateApi.py
from rest_framework import generics, status
from rest_framework.response import Response
from rack.models import RackItem
from rack.serializers import RackItemSerializer, NewRackItemSerializer
class ListCreateRackItem(generics.ListCreateAPIView):
model = RackItem
@davidwhitman
davidwhitman / Preferences.kt
Last active Jul 21, 2022
Android SharedPreferences helper class for Kotlin. Easy-to-use delegated properties, automatic database creation, and listening for property changes.
View Preferences.kt
import android.content.Context
import android.content.SharedPreferences
import kotlin.reflect.KProperty
/**
* Represents a single [SharedPreferences] file.
*
* Usage:
*
* ```kotlin