Skip to content

Instantly share code, notes, and snippets.

@remram44
remram44 / TextLoader.java
Created March 4, 2012 21:33
UTF-8 decoder with fallback
package common;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
/**
* A UTF-8 decoder, that fallbacks to Latin-1.
*
@remram44
remram44 / test.py
Created May 21, 2012 00:24
Sliding collisions circle/rectangle
import pygame, math, sys
from pygame.locals import *
#from pygame.math import Vector2
class Vector2(object):
def __init__(self, x, y):
self.x = x
self.y = y
pygame.init()
@remram44
remram44 / audio.c
Created May 26, 2012 19:59
Very simple synthetizer with SDL_audio
#include <SDL/SDL.h>
#include <stdio.h>
#include <math.h>
#define NUM_NOTES 37
float notes[NUM_NOTES] = {0};
float freqs[NUM_NOTES] = {0};
int volume = 32;
@remram44
remram44 / threads.py
Created June 5, 2012 21:04
Swing from Jython - threading issues
import threading
from javax.swing import JFrame, JButton
from java.awt.event import ActionListener, WindowAdapter
class Frame(JFrame, ActionListener):
def __init__(self):
print "constructing! thread is %s" % threading.currentThread()
button = JButton("Hello")
button.setActionCommand('button')
@remram44
remram44 / convert_files.py
Created July 8, 2012 18:00
Conversion avec respect d'arborescence
#!/usr/bin/python
# convert_files.py -- simple script to convert multiple files in parallel
# July 8th, 2012
#
# 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.
#
# Permission is granted to anyone to use this software for any purpose,
import sys
from PyQt4 import QtCore, QtGui
class MyDraggableWidget(QtGui.QLabel):
def __init__(self):
QtGui.QLabel.__init__(self)
self.setText("DRAG ME")
@remram44
remram44 / README
Last active August 6, 2017 08:48
Cygwin wrapper for Windows
Cygwin wrapper for Windows
These files are used to expose the "sh" binary to your regular Windows console.
Installation:
* Put sh.bat somewhere in your PATH (example: C:\Windows)
* Put sh_wrapper.sh where sh.bat will find it
(default: C:\cygwin\bin\sh_wrapper.sh)
If you don't use these paths, you will have to adapt the filenames in those
@remram44
remram44 / build.bat
Last active December 11, 2015 18:38
Mouse sensitivity changer
gcc set_mouse.c -o set_mouse.exe
gcc set_mouse.c -o set_trackpad.exe -DSENSITIVITY=20
#include <stdio.h>
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
int main(void)
{
puts("ex" TOSTRING(__LINE__));
return 0;
}
def file_is_binary(filename):
with open(filename) as fp:
return chr(0) in iter(fp.read(8000))