Skip to content

Instantly share code, notes, and snippets.

// paste this into web console
codes = $("code");
contents = Array.from(codes).map(i => i.textContent); //.filter(i => i.includes("@"));
uniqs = contents.filter((v, i, a) => a.indexOf(v) === i);
copy(uniqs.join('\n')); // save array to clipboard
@onionmk2
onionmk2 / pixologic.css
Created July 31, 2018 03:13
stylus for pixologic
.entry-content > ul > li {
margin: 0 0 0 36px;
}
.entry-content > ul {
list-style-type: circle;
}
.entry-content > ol {
list-style-type: decimal;
}
h2 {
@onionmk2
onionmk2 / use_cudaMallocManaged.cu
Last active January 8, 2018 11:21
use_cudaMallocManaged.cu
#include <cuda_runtime.h>
#include <iostream>
#include <device_launch_parameters.h>
#include "cuda_error_detector.h"
#include <vector>
#ifdef __CUDACC__
#define KERNEL_ARGS2(numerOfBlocks, threadsPerBlock) <<< numerOfBlocks, threadsPerBlock >>>
#define KERNEL_ARGS3(numerOfBlocks, threadsPerBlock, sh_mem) <<< numerOfBlocks, threadsPerBlock, sh_mem >>>
@onionmk2
onionmk2 / KERNEL_ARGS.cu
Created January 6, 2018 09:16
kill cuda intellisense error. original: https://stackoverflow.com/a/27992604/6430832
#ifdef __CUDACC__
#define KERNEL_ARGS2(numerOfBlocks, threadsPerBlock) <<< numerOfBlocks, threadsPerBlock >>>
#define KERNEL_ARGS3(numerOfBlocks, threadsPerBlock, sh_mem) <<< numerOfBlocks, threadsPerBlock, sh_mem >>>
#define KERNEL_ARGS4(numerOfBlocks, threadsPerBlock, sh_mem, stream) <<< numerOfBlocks, threadsPerBlock, sh_mem, stream >>>
#else
#define KERNEL_ARGS2(numerOfBlocks, threadsPerBlock)
#define KERNEL_ARGS3(numerOfBlocks, threadsPerBlock, sh_mem)
#define KERNEL_ARGS4(numerOfBlocks, threadsPerBlock, sh_mem, stream)
#endif
@onionmk2
onionmk2 / get_global_id.cu
Last active January 5, 2018 02:12 — forked from athiakos/cuda cheat sheet
cuda のid計算がよくわからないので、まとめてみる。
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
namespace comment_thread_id
{
/*
blockIdx.x == n
blockIdx.y == 1
blockIdx.z == 1
// 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__ )
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 March 1, 2019 07:19
save youtube caption.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",
});
Shader "TextureSampler" {
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Pass
{
CGPROGRAM
void Main()
{
Func<float, float> fx = x =>
{
return x * x - 612;
};
Func<float, float> primeFx = x =>
{
return 2 * x;