Skip to content

Instantly share code, notes, and snippets.

View wedesoft's full-sized avatar

Jan Wedekind wedesoft

View GitHub Profile
(ns com.wangdera.slideshow
(:use [clojure.contrib.test-is])
(:import (java.io File)
(javax.imageio ImageIO)
(javax.swing JFrame JPanel Timer)
(java.awt Dimension Frame Color)
(java.awt.event ActionListener WindowAdapter)))
(def imagelist (atom []))
(def current-image (atom nil))
@danking
danking / gist:1068185
Created July 6, 2011 19:55
A very simple example showing how to use Racket's lexing and parsing utilities
#lang racket
(require parser-tools/lex
(prefix-in re- parser-tools/lex-sre)
parser-tools/yacc)
(provide (all-defined-out))
(define-tokens a (NUM VAR))
(define-empty-tokens b (+ - EOF LET IN))
(define-lex-trans number
(syntax-rules ()
@embs
embs / rubyWebServer.rb
Created March 21, 2012 02:28
This is a tiny ruby web server.
require 'socket'
webserver = TCPServer.new('127.0.0.1', 7777)
puts "Iniciando servidor."
while (session = webserver.accept)
session.print "HTTP/1.1 200/OK\r\nContent-type:text/html\r\n\r\n"
begin
@ignacysokolowski
ignacysokolowski / pulse_simple_play.py
Created October 29, 2012 11:20
Python: Play a WAV file with PulseAudio simple API
#!/usr/bin/env python
import ctypes
import wave
import sys
pa = ctypes.cdll.LoadLibrary('libpulse-simple.so.0')
PA_STREAM_PLAYBACK = 1
PA_SAMPLE_S16LE = 3
@perrygeo
perrygeo / mercator_scale.py
Last active February 17, 2023 08:10
Web Mercator Scale/Resolution Calculations
"""
Web Mercator Scale and Resolution Calculations
Python implementation of the formulas at http://msdn.microsoft.com/en-us/library/bb259689.aspx
"""
import math
def meters_per_pixel(zoom, lat):
"""
ground resolution = cos(latitude * pi/180) * earth circumference / map width
"""
@willurd
willurd / web-servers.md
Last active May 25, 2024 13:16
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@marianposaceanu
marianposaceanu / linux_fun.md
Last active January 29, 2023 20:31
How to have some fun using the terminal.

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!
@wedesoft
wedesoft / .gitignore
Last active December 31, 2015 13:09
Python Scheme integration (libguile)
*.so
*.o
*.html
.*.un~
.*.swp
@staltz
staltz / introrx.md
Last active May 26, 2024 06:18
The introduction to Reactive Programming you've been missing
@DomNomNom
DomNomNom / intersectAABB.glsl
Last active May 22, 2024 02:59
Ray-AABB (Axis Aligned Bounding Box) intersection.
// adapted from intersectCube in https://github.com/evanw/webgl-path-tracing/blob/master/webgl-path-tracing.js
// compute the near and far intersections of the cube (stored in the x and y components) using the slab method
// no intersection means vec.x > vec.y (really tNear > tFar)
vec2 intersectAABB(vec3 rayOrigin, vec3 rayDir, vec3 boxMin, vec3 boxMax) {
vec3 tMin = (boxMin - rayOrigin) / rayDir;
vec3 tMax = (boxMax - rayOrigin) / rayDir;
vec3 t1 = min(tMin, tMax);
vec3 t2 = max(tMin, tMax);
float tNear = max(max(t1.x, t1.y), t1.z);