Skip to content

Instantly share code, notes, and snippets.

Avatar
🕶️
busy, busy

Mike Bijon mbijon

🕶️
busy, busy
View GitHub Profile
@j-adamczyk
j-adamczyk / kmeans_with_faiss.py
Last active Nov 7, 2020
K-Means clustring with faiss library
View kmeans_with_faiss.py
import faiss
import numpy as np
class FaissKMeans:
def __init__(self, n_clusters=8, n_init=10, max_iter=300):
self.n_clusters = n_clusters
self.n_init = n_init
self.max_iter = max_iter
self.kmeans = None
View polynomial_regression.py
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 21 18:59:49 2018
@author: Nhan Tran
"""
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
@mbijon
mbijon / rbenv-ubuntu.sh
Created Feb 7, 2020 — forked from rahul286/rbenv-ubuntu.sh
rbenv ubuntu server cheatsheet
View rbenv-ubuntu.sh
## ubuntu server with bash shell
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
## verify
type rbenv
@skitaoka
skitaoka / adabound.py
Created Mar 27, 2019
AdaBound AMSBound for Keras
View adabound.py
# coding: utf-8
"""
Based on Luo et al. (2019). Adaptive Gradient Methods with Dynamic Bound of Learning Rate. In Proc. of ICLR 2019.
"""
from tensorflow import keras
class AdaBound(keras.optimizers.Optimizer):
def __init__(self, lr=0.001, beta1=0.9, beta2=0.999, final_lr=0.1, gamma=1e-3, epsilon=None, weight_decay=0, amsbound=False, **kwargs):
super(AdaBound, self).__init__(**kwargs)
with keras.backend.name_scope(self.__class__.__name__):
@johnhw
johnhw / umap_sparse.py
Last active Nov 25, 2020
1 million prime UMAP layout
View umap_sparse.py
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@duhaime
duhaime / measure_img_similarity.py
Last active Nov 14, 2020
Compare image similarity in Python using Structural Similarity, Pixel Comparisons, Wasserstein Distance (Earth Mover's Distance), and SIFT
View measure_img_similarity.py
import warnings
from skimage.measure import compare_ssim
from skimage.transform import resize
from scipy.stats import wasserstein_distance
from scipy.misc import imsave
from scipy.ndimage import imread
import numpy as np
import cv2
##
@jiggneshhgohel
jiggneshhgohel / doorkeeper_config.md
Last active Jun 28, 2020
Doorkeeper (with JWT token) Server and Client applications configuration, references etc
View doorkeeper_config.md

Provider(aka Server)-side configuration, routes, controllers etc

Rails 5.0.0.1

Doorkeeper 4.2.6

Devise 4.2.0

Gemfile

@mbijon
mbijon / gist:2ddf2bfecd58e4921c1350f495261a80
Created Jun 20, 2017
Ruby AES Encryption using OpenSSL
View gist:2ddf2bfecd58e4921c1350f495261a80
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
View optional-polyfill.js
var scripts = ['app.a700a9a3e91a84de5dc0.js']; // script for all users
var newBrowser = (
'fetch' in window &&
'Promise' in window &&
'assign' in Object &&
'keys' in Object
);
if (!newBrowser) {
@mbijon
mbijon / juggernaut_channels.rb
Created Dec 22, 2016 — forked from maccman/juggernaut_channels.rb
Sinatra Server Side Event streaming with private channels.
View juggernaut_channels.rb
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
You can’t perform that action at this time.