Skip to content

Instantly share code, notes, and snippets.

from itertools import cycle
for i in cycle((0, 1, 2,)):
print i
escape_value += 1
if escape_value >= 10:
break
@jrsa
jrsa / .vimrc
Last active October 14, 2018 01:33
set nocompatible
filetype plugin indent on
syntax on
set hidden "????
"set number "line numbers
set wildmenu "completion
set ruler
set shiftwidth=4
set -g default-terminal "screen-256color"
set -g status-bg black
set -g status-fg white
set-window-option -g window-status-fg white
# active window title colors
set-window-option -g window-status-current-fg black
set-window-option -g window-status-current-bg white
user=> (->> [1 3 5] cycle (take 1) (reduce +))
1
user=> (->> [1 3 5] cycle (take 10) (reduce +))
28
user=> (->> [1 3 5] cycle (take 100) (reduce +))
298
user=> (->> [1 3 5] cycle (take 1000) (reduce +))
2998
user=> (->> [1 3 5] cycle (take 10000) (reduce +))
29998
import sublime_plugin
from time import time
class InsertEpochTimeCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, self.view.sel()[0].begin(), str(int(time())))
;; 'wrap' any function to print the arguments
;; with the intention of visualizing what happens
;; when you pass a function to reduce
;; first version
(defn wrap [f & args]
(println args)
(apply f args))
(wrap + 4 5)
@jrsa
jrsa / PostEffect.shader
Created February 3, 2018 22:42
color shifting displacement feedback process implemented as a unity3d postprocessing shader
Shader "Jars/PostEffect"
{
HLSLINCLUDE
#include "../PostProcessing/Shaders/StdLib.hlsl"
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
float _Blend;
float4 Frag(VaryingsDefault i) : SV_Target
vec2 poltocar( vec2 pol ) {
return vec2( pol.x * cos(pol.y), pol.x * sin(pol.y) );
}
// CMapChunk::Create, macOS build 12340
do {
subchunks_ = *subchunks;
remainingDataBytes = remainingSubchunkBytes - 8;
currentChunkData_ = subchunks + 8;
if (*subchunks == 'MCNR') {
this->pMcnrData = currentChunkData_;
*(subchunks + 4) = 448;
}
@jrsa
jrsa / rings.cc
Last active November 25, 2017 02:52
"Hello World' for Mutable Instruments Rings module
// Copyright 2015 Olivier Gillet.
//
// Author: Olivier Gillet (ol.gillet@gmail.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions: