Skip to content

Instantly share code, notes, and snippets.

onionmk2

Block or report user

Report or block onionmk2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View CudaErrorDetector.h
// Define this to turn on error checking
// original https://codeyarns.com/2011/03/02/how-to-do-error-checking-in-cuda/
#ifndef CUDA_ERROR_DETECTOR_H
#define CUDA_ERROR_DETECTOR_H
#define CUDA_ERROR_CHECK
#define CudaSafeCall(err) CUDA_ERROR_DETECTOR::__cudaSafeCall(__FUNCTION__, err, __FILE__, __LINE__ ) // __FUNCTION__ https://stackoverflow.com/questions/679021/how-to-find-the-name-of-the-current-function-at-runtime
#define CudaCheckError() CUDA_ERROR_DETECTOR::__cudaCheckError(__FUNCTION__, __FILE__, __LINE__ )
View tensor.py
from sympy.tensor.tensor import TensorIndexType, tensor_indices, tensorhead, TensorManager
Lorentz = TensorIndexType('Lorentz')
i0, i1, i2, i3, i4 = tensor_indices('i0:5', Lorentz)
A = tensorhead('A', [Lorentz], [[1]])
G = tensorhead('G', [Lorentz], [[1]], 'Gcomm')
GH = tensorhead('GH', [Lorentz], [[1]], 'GHcomm')
TensorManager.set_comm('Gcomm', 'GHcomm', 0)
(GH(i1) * G(i0)).canon_bp()
@onionmk2
onionmk2 / save youtube cap.js
Last active Mar 1, 2019
save youtube caption.js
View save youtube cap.js
const divs = document.querySelectorAll(".cue.style-scope.ytd-transcript-body-renderer");
const array = Array.from(divs);
const texts = array.map(t => t.textContent.trim()+"\n");
const fileName = document.title;
const file = new File(texts, fileName, {
type: "text/plain",
});
View TextureSampler.shader
Shader "TextureSampler" {
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Pass
{
CGPROGRAM
View Newton's method.cs
void Main()
{
Func<float, float> fx = x =>
{
return x * x - 612;
};
Func<float, float> primeFx = x =>
{
return 2 * x;
@onionmk2
onionmk2 / Unity Black .js
Last active Oct 19, 2017
[docs.unity3d & local] Unity Black - a dark theme with JS/C# syntax highlighting
View Unity Black .js
// ==UserScript==
// @name [docs.unity3d & local] Unity Black - a dark theme with JS/C# syntax highlighting
// @namespace https://greasyfork.org/en/users/10118-drhouse
// @version 1.1
// @description A beautiful dark theme with syntax highlighting (4 color schemes, JS & C#) that improves visual code samples and lowers screen glare.
// @include http://docs.unity3d.com/*
// @include https://docs.unity3d.com/*
// @include file://*Editor/Data/Documentation/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js
@onionmk2
onionmk2 / RGBCube_cginc.cginc
Created Oct 10, 2017
use cginc to write hlsl with VisualStudioHLSLTools
View RGBCube_cginc.cginc
// RGBCube.shader
Shader "RGBCube" {
SubShader{
Pass{
CGPROGRAM
#include "Assets\RBGCube\RGBCube_cginc.cginc"
#pragma vertex vert
#pragma fragment frag
ENDCG
}
@onionmk2
onionmk2 / gist:bece8ea5f5d2ac19df2ec655fe66edd4
Last active Oct 10, 2017
save a transcript of KhanAcademy's video
View gist:bece8ea5f5d2ac19df2ec655fe66edd4
const spans = $("ul[itemprop=transcript] li span[class='']");
const array = Array.from(spans);
const texts = array.map(t => t.textContent.replace(/\n/, '') + '\n');
const fileName = $("h1")[0].textContent;
const file = new File(texts, fileName, {
type: "text/plain",
});
const a = document.createElement("a");
@onionmk2
onionmk2 / abs.py
Created Aug 13, 2017
絶対値の方程式をsympyで
View abs.py
# http://www7b.biglobe.ne.jp/~h-kuroda/pdf/text_calculus.pdf 1.1(1)を解く
import numpy as np
from sympy import *
# real = trueがないと死ぬ。
# https://stackoverflow.com/questions/33188668/how-to-solve-absolute-value-equations-using-sympy
x = symbols("x", real=True)
f = np.absolute(x + 2) - 4
roots = solve(f, x)
@onionmk2
onionmk2 / eig.py
Last active Aug 11, 2017
固有値と固有ベクトル
View eig.py
import numpy as np
from numpy import linalg as LA # Linear algebra の意味。
A = np.array([
[3, -2],
[1, 0]
])
# LA.eig(A) は、「Aの固有値eigenvalues とAの固有ベクトルeigenvectors」を返す。
## なお、pythonは複数値を返せる関数が作れる。 https://hydrocul.github.io/wiki/programming_languages_diff/tuple/return-tuple.html
You can’t perform that action at this time.