Skip to content

Instantly share code, notes, and snippets.

View cicorias's full-sized avatar

Shawn Cicoria cicorias

View GitHub Profile
@cicorias
cicorias / freeze_example.py
Created September 27, 2020 18:03 — forked from L0SG/freeze_example.py
PyTorch example: freezing a part of the net (including fine-tuning)
import torch
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
import torch.optim as optim
# toy feed-forward net
class Net(nn.Module):
def __init__(self):
@cicorias
cicorias / union_find.py
Created July 14, 2020 00:15 — forked from artkpv/union_find.py
Union-Find in Python (weighted, path compression, connected components)
class UnionFind:
"""Weighted quick-union with path compression and connected components.
The original Java implementation is introduced at
https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf
>>> uf = UnionFind(10)
>>> for (p, q) in [(3, 4), (4, 9), (8, 0), (2, 3), (5, 6), (5, 9),
... (7, 3), (4, 8), (6, 1)]:
... uf.union(p, q)
@cicorias
cicorias / .zshrc
Created June 29, 2020 21:26
dotfiles zshrc with theme on IX
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/cicorias/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
@cicorias
cicorias / base.html
Last active June 17, 2020 22:49
Djange base.html
{% load static %}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>
{% block title %}
{% endblock %}
git config --unset core.filemode
git config --global core.filemode false
@cicorias
cicorias / fm-unshit.sh
Created June 17, 2020 13:18
filemode shit old mode 100644 new mode 100755
git config --unset core.filemode
git config --global core.filemode false
@cicorias
cicorias / p.py
Created June 3, 2020 22:48
using choice fields
from django.db import models
class BakedGood(models.Model):
name = models.CharField(max_length=64)
desc = models.CharField(max_length=256)
good_type = models.TextChoices('type', 'BAGEL BREAD COOKIE CAKE PRETZEL')
sTypes = models.CharField(blank=True, choices=good_type.choices, max_length=20)
price = models.DecimalField(max_digits=6, decimal_places=2)
recipe = models.TextField()

OpenSSL Playground

Verify downloaded file
➜  openssl dgst -sha256 openssl-1.1.1.tar.gz
SHA256(openssl-1.1.1.tar.gz)= 2836875a0f89c03d0fdf483941512613a50cfb421d6fd94b9f41d7279d586a3d
➜  cat openssl-1.1.1.tar.gz.sha256
2836875a0f89c03d0fdf483941512613a50cfb421d6fd94b9f41d7279d586a3d
RSA Public Key pad and encrypt
@cicorias
cicorias / auth0-verify.js
Created May 25, 2020 19:50 — forked from westmark/auth0-verify.js
Auth0 JWT Verification
/**
The MIT License (MIT)
Copyright (c) 2017 Fredrik Westmark
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@cicorias
cicorias / token-generator.js
Created May 23, 2020 10:42 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');