Skip to content

Instantly share code, notes, and snippets.

View tylorr's full-sized avatar

Tylor Reynolds tylorr

View GitHub Profile
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";gcc -o "$x" "$0")&&exec "$x" "$@"
main(){float A,B,P,Q,X,Y,d;int i,D=80,n=3120;for(X=-2.,Y=-1.5,d=6./D;B=2*A
*B+Y,A=P-Q+X,n;((P=A*A)+(Q=B*B)>4||++i>D)&&putchar(*((n--%D?X+=d/2,i<D?i%11
:11:(X=-2.0,Y+=d,12))+"Mandelbrot! \n"))&&(A=B=P=Q=i=0));}
template <typename T>
class stack_array {
public:
__attribute__((always_inline)) stack_array(size_t length)
: ptr_{new (static_cast<T *>(alloca(sizeof(T) * length))) T[length]},
length_{length} {}
~stack_array() {
for (size_t i = 0; i < length_; ++i) {
ptr_[i].~T();
use std::io;
use std::fmt;
extern crate ndarray;
use ndarray::{ArrayView2, aview2};
use Block::*;
static I_BLOCKS: [[[Block; 4]; 4]; 4] = [
[[E, E, E, E],
#!/bin/bash
while [[ $# > 0 ]]
do
key="$1"
case $key in
-o|-out)
OUT=1
shift
@tylorr
tylorr / plug.sh
Last active January 18, 2017 08:20
Get remote github for each directory and convert to plug.vim format for usage in .vimrc
# produces: Plug 'user/repo'
for d in ./*/ ; do (cd "$d" && git config --get remote.origin.url | sed -r "s@.*github\.com[:/](.+/.+)\.git@Plug '\1'@"); done | sort
@tylorr
tylorr / thread_local_bug.cpp
Created November 21, 2015 20:36
Combination of thread_local, inline, and std::t19937 causes thead_number to sporadically become 0
#include <random>
inline auto &prng_engine() {
thread_local std::random_device rd{};
thread_local std::mt19937 engine{rd()};
return engine;
}
int main() {
thread_local int32_t thead_number = 1;
@tylorr
tylorr / template.cpp
Last active October 18, 2015 05:38
candidate template ignored: failed template argument deduction
// clang++ -std=c++14 template.cpp
template<typename ...Args>
using Function = void(*)(Args *...);
template<typename ...Args>
void DoThing(Function<Args...> func) { }
void IntFunction(int *i) { }
//Un-minified code for bookmarklet that filters orca jobs located in the bay area
(function() {
var url = 'https://orcahq.com/jobs?location=California%2C+USA&tags=Engineering';
if (decodeURIComponent(window.location.href) !== decodeURIComponent(url)) {
window.open(url);
return;
}
var cities = [
'San Francisco',
module.exports = function(maxSpoilsPerChannel) {
return function(data, spoils) {
var channelId = data.channel_id,
channelName = data.channel_name,
originalText = data.text.trim();
var result = {
username: data.user_name,
channel: '',
text: ''
@tylorr
tylorr / LightprobeDecode.cs
Last active August 29, 2015 14:09
Decode light probe coefficients
using UnityEngine;
using System.Collections;
public class LightprobDecode : MonoBehaviour {
public Renderer ReferenceRenderer;
public Transform DirLightTransform;
void Awake () {