Skip to content

Instantly share code, notes, and snippets.

@detunized
detunized / gist:1317940
Created October 26, 2011 21:29
Magnifying glass shader
// (c) 2011 detunized (http://detunized.net)
// Paste the shader below into http://www.iquilezles.org/apps/shadertoy/?p=deform
// Click and drag the mouse around
#ifdef GL_ES
precision highp float;
#endif
uniform vec2 resolution;
uniform vec4 mouse;
@detunized
detunized / globals.rb
Created January 16, 2012 12:24
List global Ruby variables and their values
global_variables.sort.each do |name|
puts "#{name}: #{eval "#{name}.inspect"}"
end
@detunized
detunized / output.txt
Created July 2, 2012 16:11
List all subsets of a given set
[[], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3], [4], [1, 4], [2, 4], [1, 2, 4], [3, 4], [1, 3, 4], [2, 3, 4], [1, 2, 3, 4]]
@detunized
detunized / main.m
Created October 15, 2012 08:42
Redirect stderr into a pipe, filter and then write to stdout (for NSLog filtering)
int main(int argc, char *argv[])
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void) {
size_t const BUFFER_SIZE = 2048;
// Create a pipe
int pipe_in_out[2];
if (pipe(pipe_in_out) == -1)
return;
@detunized
detunized / suspend-on-power-button.sh
Created October 19, 2012 09:28
Make Gnome Shell suspend on hardware power button without asking questions
gsettings set org.gnome.settings-daemon.plugins.power button-power suspend
// A solution for http://www.geeksforgeeks.org/archives/25739
//
// Given two numbers represented by two linked lists, write a function that
// returns sum list. The sum list is linked list representation of addition of
// two input numbers. It is not allowed to modify the lists. Also, not allowed
// to use explicit extra space (Hint: Use Recursion).
//
// Example:
//
// Input:
@detunized
detunized / dijkstra.cpp
Created November 7, 2012 22:55
Simple Dijkstra's algorithm implementation
#include <vector>
#include <limits>
#include <iostream>
struct Edge
{
Edge(size_t to, int cost)
: to(to - 1)
, cost(cost)
{}
@detunized
detunized / labyrinth.rb
Created December 19, 2012 16:18
Find path in a labyrinth
#!/usr/bin/env ruby
class Coord
attr_reader :x, :y
def initialize x, y
@x = x
@y = y
end
@detunized
detunized / check_hash_less.cpp
Last active December 11, 2015 06:08
Operator < detection
#include <iostream>
#include <string>
#include <boost/type_traits/has_less.hpp>
#define HAS_LESS(type) (boost::has_less<type>::value \
? #type ": has less" \
: #type ": doesn't have less")
#define CHECK(type) (std::cout << HAS_LESS(type) << "\n")
@detunized
detunized / embed-subtitles.sh
Created August 30, 2013 09:12
Embed subtitles into an .mp4 file
#!/bin/sh
ffmpeg -i input.mkv -c:v copy -c:a copy temporary-no-subtitles.mp4
mp4box temporary-no-subtitles.mp4 -add subtitles-in-utf8.srt -out output.mp4