Skip to content

Instantly share code, notes, and snippets.

View jeasinema's full-sized avatar
💭
I may be slow to respond.

Xiaojian Ma jeasinema

💭
I may be slow to respond.
View GitHub Profile
#include "keymap_common.h"
#include "led.h"
#include "action_layer.h"
/*
* HHKB Layout
*/
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: Default layer
* ,-----------------------------------------------------------.
# !/bin/bash
# $date: 09-16-16
# $purpose: basic configuration
# $author: jeasinema [jeasinema[at]gmail[dot]com]
CREATE_USER_NAME="jeasinema"
# Create account
echo "============= now create an account ============="
sudo useradd -s /usr/bin/fish -m $CREATE_USER_NAME
# !/bin/bash
# $date: 09-16-16
# $purpose: basic configuration
# $author: jeasinema [jeasinema[at]gmail[dot]com]
UNAME="jeasinema"
DOT_FILE="https://github.com/jeasinema/.dotfile.git"
DOT_NAME=".dotfile"
VIM_REPO_NAME="vim-config"
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
# File Name : train_hook.py
# Purpose :
# Creation Date : 14-12-2017
# Last Modified : 2017-12-14 Thu 00:59:06
# Created By : Jeasine Ma [jeasinema[at]gmail[dot]com]
import os
@jeasinema
jeasinema / colorize.py
Last active June 8, 2018 03:03 — forked from jimfleming/colorize.py
A utility function for TensorFlow that maps a grayscale image to a matplotlib colormap for use with TensorBoard image summaries.
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
# File Name : colorize.py
# Purpose :
# Creation Date : 21-12-2017
# Created By : Jeasine Ma [jeasinema[at]gmail[dot]com]
# ref: https://gist.github.com/jimfleming/c1adfdb0f526465c99409cc143dea97b
@jeasinema
jeasinema / bsdgames-osx.rb
Created January 1, 2018 02:13 — forked from jdmartin/bsdgames-osx.rb
A homebrew formula for installing bsdgames-osx (updated for macOS Sierra). For now, just plunk it into /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/bsdgames-osx.rb (or, put it in ~/.homebrew/Library/Formula/ and specify this path when installing) and run "brew install bsdgames-osx". Tested successfully with MacOS X 10.12.3.
require 'formula'
class BsdgamesOsx < Formula
desc 'The classic bsdgames of yore for Mac OS X and macOS.'
homepage 'https://github.com/ctdk/bsdgames-osx'
url 'https://github.com/ctdk/bsdgames-osx/archive/bsdgames-osx-2.19.3.tar.gz'
sha256 '699bb294f2c431b9729320f73c7fcd9dcf4226216c15137bb81f7da157bed2a9'
head 'https://github.com/ctdk/bsdgames-osx.git'
version '2.19.3'
depends_on "bsdmake" => ':build'
@jeasinema
jeasinema / tensorboard_logging.py
Created April 9, 2018 19:31
A simple python snippet for logging with tensorboard
"""Simple example on how to log scalars and images to tensorboard without tensor ops.
License: Copyleft
"""
__author__ = "Jeasine Ma"
import tensorflow as tf
from PIL import Image
import numpy as np
from io import BytesIO
@jeasinema
jeasinema / weight_init.py
Last active July 30, 2024 16:35
A simple script for parameter initialization for PyTorch
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import torch
import torch.nn as nn
import torch.nn.init as init
def weight_init(m):
'''
@jeasinema
jeasinema / bar.py
Created April 12, 2018 15:26
A customized progress bar, by @id9502
def bar(current, total, prefix="", suffix="", bar_sz=25, end_string=None):
'''
Usage:
bar(iter+1, epoch_amount, "Iters:{}/{}".format(iter, epoch_amount), end_string='')
'''
sp = ""
print("\x1b[2K\r", end='')
for i in range(bar_sz):
if current * bar_sz // total > i:
sp += '='
@jeasinema
jeasinema / spatial_softmax.py
Last active March 10, 2023 08:11
Spatial(Arg)Softmax for pytorch
import torch
import torch.nn.functional as F
from torch.nn.parameter import Parameter
import numpy as np
class SpatialSoftmax(torch.nn.Module):
def __init__(self, height, width, channel, temperature=None, data_format='NCHW'):
super(SpatialSoftmax, self).__init__()
self.data_format = data_format