Skip to content

Instantly share code, notes, and snippets.

View noppoMan's full-sized avatar
🏠
Working from home

Yuki Takei noppoMan

🏠
Working from home
View GitHub Profile
@noppoMan
noppoMan / nparray2tex.py
Last active February 21, 2021 07:05
Convenient conversion code from numpy to tex
import numpy as np
def np_array_to_tex(A):
if A.ndim != 2:
raise Exception("ndim should be 2")
B = np.asarray(A)
rows = list(map(lambda row: " & ".join(map(str, row)), B))
return "\n".join([
from matplotlib import pyplot as plt
import sympy as sym
from IPython.display import display, Math
x, n, m = sym.symbols('x, n, m')
expn = sym.sin(x)**2
f = lambda n: sym.expand_trig(expn)/n
F = lambda f: sym.Integral(f, (x, 0, 2))
@noppoMan
noppoMan / Shaders.metal
Last active May 30, 2020 19:35
A Sample code for computing sigmoid function with Metal
// This is Metal Shading Language Specification file.
// More Detail: https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
#include <metal_stdlib>
using namespace metal;
kernel void sigmoid(const device float *inVector [[ buffer(0) ]],
device float *outVector [[ buffer(1) ]],
uint id [[ thread_position_in_grid ]]) {
// This calculates sigmoid for _one_ position (=id) in a vector per call on the GPU
@noppoMan
noppoMan / BackBone.Stream.js
Last active April 15, 2016 10:22
The idea for protocol based storage/store system for Backbone.
// Protocol
function BackBoneStreamType(stream){
this.stream = stream; // Ex... XMLHTTP, Local/Session Storage
}
BackBoneStreamType.prototype.recieve = function(callback){}
BackBoneStreamType.prototype.send = function(callback){}
BackBoneStreamType.prototype.close = function(callback){}
@noppoMan
noppoMan / WebViewWithNSURLConnectionDelegateSampleController.swift
Created January 18, 2015 18:39
Very Small Sample Code for UIWebView With NSURLConnectionDelegate and Basic Authorizaion
//
// WebViewWithNSURLConnectionDelegateSampleController.swift
// SwiftSamples
//
// Created by Yuki Takei on 1/18/15.
// Copyright (c) 2015 noppoman. All rights reserved.
//
import Foundation
import UIKit
@noppoMan
noppoMan / atom-remote-sync-compiled-with-ssh_private_key_identifer.js
Created May 13, 2014 04:26
This is applied modification to use -i option at ssh connection for compiled source(~/.atom/compile-cache/coffee/*) of atom remote-sync package.
(function() {
var MessagePanelView, PlainMessageView, SSHConnection, ScpTransport, mkdirp, path, _ref;
_ref = require("atom-message-panel"), MessagePanelView = _ref.MessagePanelView, PlainMessageView = _ref.PlainMessageView;
SSHConnection = require("ssh2");
mkdirp = require("mkdirp");
path = require("path");