Skip to content

Instantly share code, notes, and snippets.

View winniehell's full-sized avatar
🤯
I set my status

Winnie winniehell

🤯
I set my status
View GitHub Profile
@winniehell
winniehell / dtn_fix.java
Created July 10, 2012 02:22
DTN sending fix
final AutoCloseInputStream stream = new AutoCloseInputStream(pData);
try {
final FileChannel channel = stream.getChannel();
final MappedByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
session.send(SERVER_EID, 100,
Charset.defaultCharset().decode(buf).toString());
}
finally {
stream.close();
@winniehell
winniehell / django.py
Last active October 11, 2015 01:28
Inheritance and default value in Django models
class Base(models.Model):
myfield = models.PositiveIntegerField()
class Meta:
abstract = True
class Dummy(Base):
pass
@winniehell
winniehell / test_sweep_line_2.py
Created November 4, 2012 19:56
Test code for CGAL bindings of the Sweep_line_2 module
from CGAL.CGAL_Kernel import Point_2, Segment_2
from CGAL.CGAL_Sweep_line_2 import \
compute_intersection_points, \
compute_subcurves, \
do_curves_intersect,\
test_segment_range
segments = [
Segment_2(Point_2(0, 0), Point_2(10, 10)),
BASE_DIR=$PWD
echo "create SVN repositories"
for i in {1..2}; do
svnadmin create $BASE_DIR/svn-repo$i
svn checkout file://$BASE_DIR/svn-repo$i $BASE_DIR/svn-client$i
mkdir $BASE_DIR/svn-client$i/{trunk,branches,tags}
echo "file $i" > $BASE_DIR/svn-client$i/trunk/file$i.txt
@winniehell
winniehell / bad.java
Last active August 29, 2015 14:10
inline comments
public static int[] process(int[] inp, String oop) {
// initialize a new array with zeroes to use in error case <-- WRONG!
// this will be returned if the operator is not known <-- WRONG!
int[] oue = new int[] { Integer.MAX_VALUE, Integer.MAX_VALUE };
// set placeholder variable for plus operator
// this will be used to compare the input operator in the for loop below
String opp = "+";
// set placeholder variable for minus operator
// this will be used to compare the input operator in the for loop below
String opm = "-";
@winniehell
winniehell / setup.md
Last active August 29, 2015 14:11
Setting up Grunt + Bower + Bootstrap
$ nvm use 0.10
$ npm init
$ npm install grunt --save-dev
$ npm install grunt-contrib-cssmin --save-dev
$ npm install grunt-contrib-sass --save-dev
$ npm install grunt-contrib-uglify --save-dev
$ npm install grunt-wiredep --save-dev

# edit Gruntfile.js
@winniehell
winniehell / find.py
Created January 5, 2015 18:38
Find all python classes within the current package
import importlib
import inspect
import pkgutil
package = importlib.import_module(__package__)
for loader, module_name, is_pkg in pkgutil.iter_modules(package.__path__):
if not is_pkg:
module = importlib.import_module(__package__+'.'+module_name)
for name, obj in inspect.getmembers(module):
if inspect.isclass(obj):
var jsen = require('jsen');
function validateAndOutput(schema, title, data) {
var validate = jsen(schema);
var result = validate(data);
if (result) {
console.log('Valid: ' + title + ' = ' + JSON.stringify(data));
} else {
console.log('Invalid: ' + title + ' = ' + JSON.stringify(data));
@winniehell
winniehell / d3.v2.js
Last active March 8, 2016 23:44 — forked from ZJONSSON/index.html
Simple transitioning slides with SVG and D3
(function() {
function d3_class(ctor, properties) {
try {
for (var key in properties) {
Object.defineProperty(ctor.prototype, key, {
value: properties[key],
enumerable: false
});
}
} catch (e) {
@winniehell
winniehell / index.html
Last active March 9, 2016 17:48
SVG: Grow and Shrink and Colors
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Grow and Shrink</title>
</head>
<body>
<svg width="100%" height="100%">
<animate id="shrink"