Skip to content

Instantly share code, notes, and snippets.

@jagt
jagt / vvv.cc
Created March 9, 2014 07:23
c++11 examples again
#include <iostream>
#include <exception>
#include <algorithm>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
class Vector {
@jagt
jagt / fenv.lua
Created March 28, 2014 16:32
lua5.1 setfenv test.
-- lua51 setfenv tests
function setenv1()
-- 1 is the calling function
setfenv(1, {foo='1', print=_G.print})
print(foo) -- prints 1
end
setenv1()
@jagt
jagt / iter.lua
Created March 30, 2014 03:49
iterator example. notice the stateless one, which pairs()/ipairs() all do this.
function upto(x)
local k = 0
return function()
if k < x then
local ret = k
k = k+1
return ret
end
end
end
@jagt
jagt / jmp.c
Created March 31, 2014 15:48
setjmp/longjmp and volatile
#include <setjmp.h>
#include <stdio.h>
jmp_buf buf;
void jmper() {
// only variables marked as volatile can be seen as reiable
// written after jmp, as they are written to ram
volatile int local = 1;
if (!setjmp(buf)) {
printf("pre set: %d\n", local); // 1
@jagt
jagt / superlua.c
Created April 13, 2014 07:56
small lua ext for playing around.
// small lua ext for playing around.
#include <stdio.h>
#include <stdlib.h>
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#define err(msg) do {fprintf(stderr, "error: %s\n", (msg)); exit(1);} while (0)
int super_bind(lua_State *L) {
return 0;
@jagt
jagt / cnv.c
Created September 30, 2014 07:27
print int as float for memory edit
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
int i;
float f;
if (argc < 2)
{
puts("usage: cnv 1065353216\n");
/*
* Compile UnityScripts in "<ProjectRoot>/<ScriptsDirName>" into DLL, Windows and Editor Only
*
*/
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
using System.Collections.Generic;
// Unlit alpha-blended shader with MainColor
// - no lighting
// - no lightmap support
// - with holes
Shader "Unlit/Transparent With Holes" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Radius ("Hole Radius", Float) = 50.0
_CutOff1 ("Cut Off Ratio, ranges from [0, 1", Float) = 0.6
// Unlit alpha-blended shader.
// - no lighting
// - no lightmap support
// - no per-material color
// - accepts a masking texture of the scale of screen
Shader "Unlit/Transparent With Mask" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_MaskTex ("Mask Tex", 2D) = "white" {}
Shader "Custom/yar" {
Properties {
_ColorLow ("Color Low", COLOR) = (1,1,1,1)
_ColorHigh ("Color High", COLOR) = (1,1,1,1)
_yPosLow ("Y Pos Low", Float) = 0
_yPosHigh ("Y Pos High", Float) = 10
_GradientStrength ("Graident Strength", Float) = 1
_EmissiveStrengh ("Emissive Strengh ", Float) = 1
_ColorX ("Color X", COLOR) = (1,1,1,1)
_ColorY ("Color Y", COLOR) = (1,1,1,1)