Skip to content

Instantly share code, notes, and snippets.

View jimfleming's full-sized avatar

Jim Fleming jimfleming

View GitHub Profile
@jimfleming
jimfleming / GrabScreenSwatch.cs
Created December 7, 2014 06:50
Uses an internal Unity3D utility function to grab chunks of the screen for blurring.
public static class GrabScreenSwatch {
public static Texture GrabScreenSwatch(Rect rect) {
int width = (int)rect.width;
int height = (int)rect.height;
int x = (int)rect.x;
int y = (int)rect.y;
Vector2 position = new Vector2(x, y);
Color[] pixels = UnityEditorInternal.InternalEditorUtility.ReadScreenPixel(position, width, height);
@jimfleming
jimfleming / Blur.shader
Last active May 3, 2017 04:49
A simple separable blur shader with tint pass.
Shader "Hidden/Blur" {
Properties {
_MainTex ("", 2D) = "white" {}
_BlurSize ("", Range(0.0, 1.0)) = 1.0
_Tint ("", Color) = (0.0, 0.0, 0.0, 0.0)
_Tinting ("", Range(0.0, 1.0)) = 0.64
}
SubShader {
extern crate test;
use test::Bencher;
use std::fmt::{Show, Formatter, Result};
use std::iter::AdditiveIterator;
enum Node<T> {
Cons(T, Box<Node<T>>),
Nil
diff --git a/tests/rewrite.js b/tests/rewrite.js
index e6c85a0..5a6db87 100644
--- a/tests/rewrite.js
+++ b/tests/rewrite.js
@@ -8,6 +8,33 @@ var libPath = process.env.JSFMT_COV ? 'lib-cov' : 'lib';
var jsfmt = require('../' + libPath + '/index');
describe('jsfmt.rewrite', function() {
+
+ it('should test multiline BlockStatement rewrite' ,function() {
--- a/Users/jfleming/Documents/jsfmt/examples/styleGuide.js
+++ b/var/folders/xc/lj44vzbd7bgf72wxhktr0f240000gp/T/tmp-66660d8xy3n4.tmp
@@ -28,8 +28,8 @@
var anotherFun = function(a, b, c) {
// TODO: Should wrap to one line or indent properly
return a == "a" ||
- b == "b" ||
- c == "c";
+ b == "b" ||
+ c == "c";
@jimfleming
jimfleming / UndoStack.cs
Created June 7, 2014 23:40
Handles collapsing multiple undo operations. Definitely works in Unity 4.5. Haven't tested previous versions.
using UnityEditor;
using UnityEngine;
using System;
using System.Collections;
/*
Usage:
using (new UndoStack("Batch Changes")) {
// Make some changes using RecordObject or whatever...
diff --git a/examples/reduce.js b/examples/reduce.js
deleted file mode 100644
index ed4cee9..0000000
--- a/examples/reduce.js
+++ /dev/null
@@ -1,4 +0,0 @@
var values = [1, 2, 3, 4];
_.reduce(values, function(sum, value) {
 return sum + value;
}, 0);
@jimfleming
jimfleming / jsfmt-sublime.py
Created May 12, 2014 22:49
Very basic jsfmt integration for Sublime Text 3
import subprocess
import sublime, sublime_plugin
import os
PLUGIN_FOLDER = os.path.dirname(os.path.realpath(__file__))
SCRIPT_PATH = PLUGIN_FOLDER + '/node_modules/jsfmt/run.js'
NODE_PATH = '/usr/local/bin/node'
class FormatJavascript(sublime_plugin.TextCommand):
def run(self, edit):
@jimfleming
jimfleming / blend.shader
Last active December 28, 2015 10:59
Moving blobs used as interpolation values between two images.
#define INTENSITY 6.5
float blob(vec2 uv, vec2 speed, float time) {
// Compute a moving point
vec2 point = vec2(
sin(speed.x * time),
cos(speed.y * time)
);
float d = 1.0 / distance(uv, point) / INTENSITY;
def unfreezeTransformations(selection):
originalCenter = cmds.getAttr('%s.center' % selection)[0]
cmds.move(originalCenter[0] * -1, originalCenter[1] * -1, originalCenter[2] * -1, selection, absolute=True)
cmds.makeIdentity(selection, apply=True, translate=1, rotate=1, scale=1, normal=0)
cmds.move(originalCenter[0], originalCenter[1], originalCenter[2], selection, absolute=True)