Skip to content

Instantly share code, notes, and snippets.

View AbigailBuccaneer's full-sized avatar

AbigailBuccaneer AbigailBuccaneer

View GitHub Profile
$ touch libfoo.c
$ echo "int main(void) { return 0; }" > foo.c
$ cat SConstruct
env = Environment()
lib = env.Library('libfoo', 'libfoo.c')
program = env.Program('foo', LIBS=[lib])
$ scons --tree=all
scons: Reading SConscript files ...
def glob_recursive(path, pattern, exclude=None):
import SCons.Node.FS
globbed = Dir(path).glob(pattern, exclude=exclude)
sources = []
for source in globbed:
if isinstance(source, SCons.Node.FS.Dir):
childpath = os.path.join(path, os.path.basename(source.path))
sources += glob_recursive(childpath, pattern, exclude=exclude)
else:
sources += [source]
@AbigailBuccaneer
AbigailBuccaneer / SConstruct
Last active January 22, 2016 16:01
SConstruct won't find implicit dependencies on files which don't yet exist
env = Environment()
# preprocess compiler.in to compiler
compiler = env.Command('compiler', 'compiler.in', 'cp $SOURCE $TARGET')
env['compiler'] = File(compiler)[0].abspath
# and then use that to compile foo.in
target = env.Command('foo', 'foo.in', '$compiler < $SOURCE > $TARGET')
Default(target)
import os.path
import re
import subprocess
import SCons.Action
from SCons.Tool import cc
def detect_version(env, clang):
clang = env.subst(clang)
if not clang:
@AbigailBuccaneer
AbigailBuccaneer / test.cc
Last active November 18, 2015 17:02
std::istream::ignore is inconsistent with regards to eof()
#include <iostream>
#include <sstream>
#include <fstream>
using namespace std;
int main(int argc, char** argv) {
string s("ab");
{
istringstream stream(s);
stream.ignore(1); stream.ignore(1);
@AbigailBuccaneer
AbigailBuccaneer / gist:1704860
Created January 30, 2012 15:02
Using CSO in an Eclipse project

Using CSO in an Eclipse project

  1. If you haven't already done so, install Eclipse. You can do this from your * nix repositories, or from [the Eclipse download page][eclipse-download]. The Scala IDE for Eclipse claims that either Eclipse IDE for Java Developers or Eclipse Classic will suffice.
  2. Install the Scala distribution. Once again, if possible grab this from your repositories, if not then from [the Scala download page][scala-download]. I'd recommend the IzPack installer; it seems to work on all systems I've used it on.
  3. Install the Scala IDE for Eclipse. Head to [the Scala IDE for Eclipse download page][scala-ide-download] and follow the instructions to install it for Scala 2.9.x.
  4. Download and extract CSO. Head to [Bernard Sufrin's CSO files][cso-download] and download cso.jar, and cso-sources-scala2.9.0.tgz. Choose somewhere to put them - if you're root and on * nix, /usr/share/java is a good place. Put cso.jar in there, and extract the src/ folder from the sou
@AbigailBuccaneer
AbigailBuccaneer / PreprocessingLexer.java
Created July 12, 2015 18:48
PreprocessingLexer.java
package glslplugin.lang.scanner;
import com.intellij.lang.ForeignLeafType;
import com.intellij.lang.TokenWrapper;
import com.intellij.lexer.Lexer;
import com.intellij.lexer.LookAheadLexer;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.containers.ImmutableUserMap;
import org.jetbrains.annotations.NotNull;
static void GLMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void*)
{
std::cout << message << std::endl;
}
static void SetupMessageCallback {
if (!ogl_ext_KHR_debug) return;
glDebugMessageCallback(GLMessageCallback, nullptr);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
#!/bin/sh
start=$(pwd)
while read line; do
dirname=$(dirname "$line")
basename=$(basename "$line")
cd "$dirname"
lowercase=$(echo "$basename" | tr '[A-Z]' '[a-z]')
@AbigailBuccaneer
AbigailBuccaneer / make.sh
Created March 20, 2015 17:46
Create a Debian package for p4v
set -e # terminate on any error
[ -f p4v.tgz ] || wget http://www.perforce.com/downloads/perforce/r14.3/bin.linux26x86_64/p4v.tgz
mkdir -p opt && tar xf p4v.tgz -C opt
mkdir -p usr/bin
for f in p4admin p4merge p4v p4vc; do
[ -x "usr/bin/$f" ] || ln -s "../../opt/p4v-2014.3.1007540/bin/$f" "usr/bin/$f"
done