Skip to content

Instantly share code, notes, and snippets.

@xentec
xentec / cake.lua
Last active December 18, 2015 15:48
-- echo ' <this text>' | awesome-client
-- for ssh usage prepend 'export DISPLAY=:0;'
local n = require("naughty");
n.notify({preset = n.config.presets.critical,
title = "Oops, a birthday happened!",
text = "(dont shit your pants)"});
local t = timer({timeout=10});
local function dev()
n.notify({preset = { bg = "#ffaa00", fg = "#ffffff", timeout = 0 },
@xentec
xentec / glfw3.d
Last active December 22, 2015 07:19
GLFW 3.0 D Interface
/*************************************************************************
* GLFW 3.0 - www.glfw.org
* A library for OpenGL, window and input
*------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard
* Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
@xentec
xentec / il.d
Last active December 22, 2015 08:09
devIL 1.7.8 D Interface
//-----------------------------------------------------------------------------
//
// ImageLib Sources
// Copyright (C) 2000-2009 by Denton Woods
// Last modified: 03/07/2009
//
// Filename: il/il.d
//
// Description: The main include file for DevIL
//
@xentec
xentec / showdown.js
Last active December 23, 2015 05:39
showdown extension for math expressions in AsciiMath and TeX
//
// MathJax Extension
// $$ F = m * a $$ -> ` F = m \cdot a `
// $$$ F = m * a $$$ -> <script type="math/tex; mode=display"> F = m \cdot a </script>
//
//
// Dont forget to include
//
// <script type="text/javascript"
// src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML">
string humanByte(byte decimals = 2)(double bytes)
{
import std.string;
enum suffix = [ "", "K", "M", "G", "T", "P", "E"];
byte i;
while(bytes > 1024.0) {
bytes /= 1024.0;
i++;
import
std.array,
std.conv,
std.string;
version(Have_vibe_d) {
import vibe = vibe.inet.url;
}
/*
@xentec
xentec / camera.cpp
Last active August 29, 2015 14:27
Quaternion camera
const vec3 Camera::axisV = {0.f, 1.f, 0.f};
const vec3 Camera::axisF = {0.f, 0.f, 1.f};
mat4 Camera::getView(const vec3& pos, const quat& rot) const
{
vec3 up = rot * axisV;
vec3 forward = rot * axisF;
return glm::lookAt(pos, pos + forward, up);
}
<?php
/* PHP System Status
* ------------------------------------------
* Author: wutno (#/g/tv - Rizon)
* Last update: 1/4/2012 5:28AM -5GMT (USELESS BLOAT)
*
*
* GNU License Agreement
* ---------------------
* This program is free software; you can redistribute it and/or modify
@xentec
xentec / break-variant.d
Created December 30, 2015 15:30
std.variant breaking
void buildVar(DBusMessageIter *iter, Variant var, int sig)
{
import std.meta;
alias basic = AliasSeq!(byte,bool,short,ushort,int,uint,long,ulong,double,string);
foreach(T; basic) {
T* p = var.peek!T;
if(p) {
buildIter!T(iter, *p);
break;
@xentec
xentec / util.d
Last active February 9, 2016 14:47
/* Return the number of running processes of the system */
ulong getProcNum()
{
version(linux)
{
import std.file, std.algorithm, std.ascii;
return "/proc".dirEntries(SpanMode.shallow).count!(a => a.name.baseName.all!isDigit);
}
}