Skip to content

Instantly share code, notes, and snippets.

@dogfuntom
dogfuntom / BoundsInt.cs
Last active January 31, 2023 09:59
Cast ray in voxel space (i.e. 3d-grid) #Unity
namespace UnityEngine
{
using System;
using System.Runtime.InteropServices;
using UnityEngine.Assertions.Must;
[StructLayout(LayoutKind.Auto)]
internal struct BoundsInt
{
private Vector3i _min;
@ashwin
ashwin / depth_type_cvmat.cpp
Created August 27, 2015 04:46
Useful functions to get the depth or type of a cv::Mat
std::string GetMatDepth(const cv::Mat& mat)
{
const int depth = mat.depth();
switch (depth)
{
case CV_8U: return "CV_8U";
case CV_8S: return "CV_8S";
case CV_16U: return "CV_16U";
case CV_16S: return "CV_16S";
@karpathy
karpathy / min-char-rnn.py
Last active June 7, 2024 14:41
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@hkmix
hkmix / comments.vim
Created June 30, 2015 01:25
Vim theme for only colours, adapted from industry.vim
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "comments"
" First set Normal to regular white on black text colors:
hi Normal ctermfg=LightGray ctermbg=Black guifg=#dddddd guibg=Black
@elieux
elieux / gist:fd63e62fda6a05778004
Created May 5, 2015 23:29
SCons MSYS2/mingw platform patch
--- /usr/lib/python2.7/site-packages/SCons/Platform/msys.py.orig 2014-11-04 23:23:28.000000000 +0100
+++ /usr/lib/python2.7/site-packages/SCons/Platform/msys.py 2015-05-06 01:27:32.333448600 +0200
@@ -39,6 +39,12 @@
posix.generate(env)
env['ENV']['PATH'] = os.getenv('PATH')
+ import_env = [ 'SystemDrive', 'SystemRoot', 'TEMP', 'TMP' ]
+ for var in import_env:
+ v = os.environ.get(var)
+ if v:
@jgrahamc
jgrahamc / parallel
Last active November 19, 2019 22:38
all: | parallel ; @echo $(JOB_COUNT)
parallel: .parallel ; @$(eval JOB_COUNT := $(shell sort -n $< | tail -n 1))
.parallel: FORCE ; @$(MAKE) --no-print-directory par 2>/dev/null >$@ || true
FORCE:
to_n = $(words $2) $(if $(filter-out $1,$(words x $2)),$(call to_n,$1,x $2))
PAR_COUNT :=
par: $(addprefix par-,$(call to_n,32))
@kevinkreiser
kevinkreiser / logging.hpp
Last active April 17, 2024 13:25
Thread-safe logging singleton c++11
#ifndef __LOGGING_HPP__
#define __LOGGING_HPP__
/*
Test this with something like:
g++ -std=c++11 -x c++ -pthread -DLOGGING_LEVEL_ALL -DTEST_LOGGING logging.hpp -o logging_test
./logging_test
*/
#include <string>
@dlebech
dlebech / Gerrit comment formatting
Last active January 17, 2024 10:34
Comment formatting in Gerrit
The documentation for Gerrit when it comes to formatting comments is quite lacking. Here is short list created by trial and error and looking at the source code in:
./gerrit-gwtexpui/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
Lists:
* List item 1
* List item 2
- List item 1
- List item 2
@dstebila
dstebila / hex2bin.sh
Last active December 9, 2022 03:46
Shell script to convert hex file to binary, stripping out any comments
#!/bin/bash
# Read either the first argument or from stdin (http://stackoverflow.com/questions/6980090/bash-read-from-file-or-stdin)
cat "${1:-/dev/stdin}" | \
# Strip out comments starting with #
sed -E 's/#.*$//' | \
# Strip out comments starting with //
sed -E 's/\/\/.*$//' | \
# Strip out multi-line comments /* ... */
perl -0777 -pe 's{/\*.*?\*/}{}gs' | \
@eliben
eliben / cuda.h
Created October 6, 2014 22:11
Minimal CUDA support header for parsing with Clang
/* Minimal declarations for CUDA support. Testing purposes only. */
#define __constant__ __attribute__((constant))
#define __device__ __attribute__((device))
#define __global__ extern "C" __attribute__((global))
#define __host__ __attribute__((host))
#define __shared__ __attribute__((shared))
#define __launch_bounds__(...) __attribute__((launch_bounds(__VA_ARGS__)))
#define __forceinline__ __attribute__((always_inline))