Skip to content

Instantly share code, notes, and snippets.

View CyberShadow's full-sized avatar

Vladimir Panteleev CyberShadow

View GitHub Profile
@CyberShadow
CyberShadow / test.d
Created October 18, 2010 00:06
binary search benchmarks
import std.range;
import std.random;
import std.stdio;
int[1000] a;
void main()
{
foreach (ref n; a)
n = rand()%1000;
@CyberShadow
CyberShadow / rdmd.d
Created May 26, 2011 21:16
DustMite output - after
import std.algorithm, std.array, std.typetuple;
int main()
{
const
root =[];
replace(root, ".", "-");
}
@CyberShadow
CyberShadow / rdmd.d
Created May 26, 2011 21:16
DustMite output - before
// Written in the D programming language.
import std.algorithm, std.c.stdlib, std.datetime, std.exception,
std.file, std.getopt,
std.md5, std.path, std.process, std.regexp,
std.stdio, std.string, std.array, std.typetuple;
private bool chatty, buildOnly, dryRun, force;
private string exe, compiler = "dmd";
import std.stdio, std.string, std.exception;
void main(string[] args)
{
enforce(args.length==3, "Two files please");
auto f1 = File(args[1]), f2 = File(args[2]);
while (!f1.eof() && !f2.eof())
{
auto l1 = f1.readln(), l2 = f2.readln();
@CyberShadow
CyberShadow / gist:1189548
Created September 2, 2011 19:10
pre-commit hook
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, make this file executable.
# This is slightly modified from Andrew Morton's Perfect Patch.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
FILE *f;
char *cc, cmdline[1024];
if (argc != 3)
return fprintf(stderr, "Usage: %s header.h VALUE\n", argv[0]);
@CyberShadow
CyberShadow / hvalue.d
Created September 8, 2011 20:30
hvalue - show an integer constant from a C header file
// rm hvalue* ; wget --no-check-certificate https://raw.github.com/gist/1204580/hvalue.d ; dmd hvalue.d
import std.stdio, std.file, std.process, std.exception;
void cleanup()
{
try
foreach (fn; listDir("", "hvalue-test*"))
remove(fn);
catch {}
@CyberShadow
CyberShadow / namegen.d
Created November 24, 2011 01:51 — forked from bhelyer/namegen.d
void main()
{
import std.random, std.stdio, std.range, std.algorithm, std.string;
array(map!q{std.stdio.writeln(capitalize(array(map!q{cast(char)["aeiou", "bcdfghjklmnpqrstvwxyz"][a][std.random.uniform(0, $)]}([[1,0,1,1,0,1], [0,1,1,0,1,0]][std.random.uniform(0, $)][0..std.random.uniform(5, 7)])))), 42}(iota(12)));
}
@CyberShadow
CyberShadow / namegen.d
Created November 24, 2011 01:51 — forked from bhelyer/namegen.d
module namegen;
import std.ascii;
import std.random;
import std.utf;
void main()
{
import std.stdio;

Currently, we only only have SDL 1.2 support.

SDL 1.2 apparently does most rendering in software. This is fine for most of our use cases, except smooth resizing. Smooth resizing a large image in software is not fast enough for e.g. a fluid zoom animation. Smooth resizing is also useful at zoom levels <1 - nearest-neighbor-downscaled images are quite ugly, and realtime software downscaling, even at powers of two, is not feasable on older hardware at high resolutions. Other perks that 3D acceleration provides is rotation - equally slow in software, but fast in hardware.

All of these are not available when using only SDL.