This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ deepcopy.lua | |
Deep-copy function for Lua - v0.2 | |
============================== | |
- Does not overflow the stack. | |
- Maintains cyclic-references | |
- Copies metatables | |
- Maintains common upvalues between copied functions (for Lua 5.2 only) | |
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main(void) { | |
// the center of the texture | |
vec2 center = vec2(iResolution.x/2.0,iResolution.y/2.0); | |
// current pixel location | |
vec2 loc = gl_FragCoord.xy; | |
// how far we are from the center | |
float radius=length(loc-center); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// = Requirements: freetype 2.5, libpng, libicu, libz, libzip2 | |
// = How to compile: | |
// % export CXXFLAGS=`pkg-config --cflags freetype2 libpng` | |
// % export LDFLAGS=`pkg-config --libs freetype2 libpng` | |
// % clang++ -o clfontpng -static $(CXXFLAGS) clfontpng.cc $(LDFLAGS) \ | |
// -licuuc -lz -lbz2 | |
#include <cassert> | |
#include <cctype> | |
#include <iostream> | |
#include <memory> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- copy.lua | |
-- | |
-- Lua functions of varying complexity to deep copy tables. | |
-- | |
-- 1. The Problem. | |
-- | |
-- Here's an example to see why deep copies are useful. Let's | |
-- say function f receives a table parameter t, and it wants to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//compiled gcc fonttest.c -o fonttest -lfontconfig | |
//Sample output: /usr/share/fonts/steam-fonts/arial.ttf | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <fontconfig/fontconfig.h> | |
int main() | |
{ | |
FcConfig* config = FcInitLoadConfigAndFonts(); | |
//make pattern from font name | |
FcPattern* pat = FcNameParse((const FcChar8*)"Arial"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var cookieParser = require('cookie-parser'); | |
var session = require('express-session'); | |
var flash = require('express-flash'); | |
var handlebars = require('express-handlebars') | |
var app = express(); | |
var sessionStore = new session.MemoryStore; | |
// View Engines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// returns 1.0 if inside circle | |
float disk(vec2 r, vec2 center, float radius) { | |
return 1.0 - smoothstep( radius-0.005, radius+0.005, length(r-center)); | |
} | |
// returns 1.0 if inside the disk | |
float rectangle(vec2 r, vec2 bottomLeft, vec2 topRight) { | |
float ret; | |
float d = 0.005; | |
ret = smoothstep(bottomLeft.x-d, bottomLeft.x+d, r.x); | |
ret *= smoothstep(bottomLeft.y-d, bottomLeft.y+d, r.y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set(LIBFOO_TAR_HEADERS | |
"${CMAKE_CURRENT_BINARY_DIR}/include/foo/foo.h" | |
"${CMAKE_CURRENT_BINARY_DIR}/include/foo/foo_utils.h" | |
) | |
add_custom_command(OUTPUT ${LIBFOO_TAR_HEADERS} | |
COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/libfoo/foo.tar" | |
COMMAND ${CMAKE_COMMAND} -E touch ${LIBFOO_TAR_HEADERS} | |
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/foo" | |
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/libfoo/foo.tar" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import re | |
import sys | |
def removeComments(text): | |
""" remove c-style comments. | |
text: blob of text with comments (can include newlines) | |
returns: text with comments removed | |
""" | |
pattern = r""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# gh-dl-release! It works! | |
# | |
# This script downloads an asset from latest or specific Github release of a | |
# private repo. Feel free to extract more of the variables into command line | |
# parameters. | |
# | |
# PREREQUISITES | |
# |
OlderNewer