Skip to content

Instantly share code, notes, and snippets.

View Yoplitein's full-sized avatar
🔈
[screaming]

Steven Dwy Yoplitein

🔈
[screaming]
View GitHub Profile
@Yoplitein
Yoplitein / gist:6025802
Created July 18, 2013 00:33
Fetches a list of Steam workshop IDs from a collection.
(function($)
{
var results = [];
$("a div.workshopItemTitle").each(function(index, value)
{
results.push($(value).parent().attr("href").split("?id=")[1]);
});
alert(results.join("\n"));
@Yoplitein
Yoplitein / gist:6111519
Created July 30, 2013 09:22
Small jQuery plugin to center elements.
(function($)
{
$.fn._center = function(self, parent, dimension)
{
if(!dimension.vertical && !dimension.horizontal)
return; //won't do anything anyway
if(parent)
parent = self.parent();
else
AttrType[] find_attributes(AttrType, alias Thing)()
{
AttrType[] result;
foreach(attr; __traits(getAttributes, Thing))
static if(is(typeof(attr) == AttrType))
result ~= [attr];
return result;
}
@Yoplitein
Yoplitein / gist:c04237c74101f3395c98
Last active August 29, 2015 14:05
gl3n to gfm conversion functions
import gl3n.util: is_matrix, is_vector;
auto to_gfm(MatrixType)(MatrixType matrix)
if(is_matrix!MatrixType)
{
static import gfm.math;
enum matrixSize = matrix.cols * matrix.rows;
matrix.mt[matrixSize] data;
matrix.mt *ptr = matrix.value_ptr;
@Yoplitein
Yoplitein / gist:f4b671a2ec70c9e743fa
Created August 25, 2014 15:00
Dark theme for cgit
body {
background-color: #272822;
}
div#cgit {
padding: 0em;
margin: 0em;
font-family: sans-serif;
font-size: 10pt;
color: white;
@Yoplitein
Yoplitein / gist:bd07e5a59a9bbd5e4d90
Created August 29, 2014 23:08
string prompt function for tkd, similar to javascript's prompt function
string string_prompt(Window parent, string prompt, string initialValue = null)
{
string result;
auto window = new Window(parent, "Prompt");
auto label = new Label(window, prompt);
auto input = new Entry(window);
auto okButton = new Button(window, "OK");
auto cancelButton = new Button(window, "Cancel");
void close(CommandArgs _ = CommandArgs.init)
@Yoplitein
Yoplitein / gist:98eddf7e9f1f74e61b29
Created September 13, 2014 10:43
Simple script to alert you, via email (through cron,) of packages with upgrades on Arch
#!/bin/bash
cacheFile=~/bin/updates.cache
cacheFileNew=~/bin/updates-new.cache
function getignores()
{
#list ignored packages here, like so:
#echo "packagename"
#TODO: actually parse pacman.conf
@Yoplitein
Yoplitein / gist:3b07090caadff0d20f36
Last active August 29, 2015 14:06
D unittesting helper to ensure certain exceptions are thrown
void ensure_throws(ExceptionType = Exception)(void delegate() callable, string message = "")
{
import core.exception: AssertError;
try
{
callable();
assert(false, message);
}
catch(ExceptionType err) {}
@Yoplitein
Yoplitein / gist:8bc30b082d5c45fceb2c
Created October 6, 2014 15:26
Simple noise function in D
//adapted from http://stackoverflow.com/a/7262117
private real noise(long x, long y)
{
long initial = x + y * 57;
initial = (initial << 13) ^ initial;
real intermediate = (
1.0L - (
(
result * (
result ^^ 2 + 15731 + 789221
@Yoplitein
Yoplitein / genmimetypes-lighty.py
Last active June 6, 2017 00:58
Python script to generate a list of mimetype -> extension mappings for nginx/lighttpd
#!/usr/bin/env python2
mimeList = ""
mapping = {}
with open("/etc/mime.types", "r") as f:
mimeList = f.read().split("\n")
for entry in mimeList:
entry = entry.split("\t")