Skip to content

Instantly share code, notes, and snippets.

Rafal Rusin rafalrusin

Block or report user

Report or block rafalrusin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View affine
var u:Point2D = a.findBoundaryPoint(b.position, a.position);
var v:Point2D = b.findBoundaryPoint(a.position, b.position);
var l:Float = Math.sqrt(pointsLenSqr(u, v));
content = [
Path {
transforms: [
Affine {
mxx: (v.x-u.x)/l
@rafalrusin
rafalrusin / model.xml
Created Mar 22, 2011
UI Refresh based on Model items
View model.xml
<netflow.model.Model id="1">
<nodes id="2">
<netflow.model.MShape id="3">
<flow>10.0</flow>
<capacity>10.0</capacity>
<name>node-1</name>
<type>SOURCE</type>
<x>171.0</x>
<y>142.0</y>
</netflow.model.MShape>
@rafalrusin
rafalrusin / iterating.java
Created Jun 12, 2011
GIS data visualization
View iterating.java
File file = new File("110m_cultural\\110m_admin_0_countries.shp");
FileDataStore store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureSource featureSource = store.getFeatureSource();
SimpleFeatureCollection c = featureSource.getFeatures();
SimpleFeatureIterator featuresIterator = c.features();
Coordinate[] coords;
Geometry polygon;
Point centroid;
Bounds bounds;
while (featuresIterator.hasNext()) {
View calculator.lex
%{
#include "calculator.tab.h"
using namespace std;
%}
%%
[ \t] ;
\+ { return PLUS; }
\- { return MINUS; }
\* { return MUL; }
\/ { return DIV; }
View drawTree.java
private void drawTree(RBNode n, float x1, float x2, float y1, float y2) {
if (n != null) {
if (n.left != null) {
drawConnection((x1 + x2)/2.0f, y1, (x2 - x1)*1.f/4.0f + x1, y2);
}
if (n.right != null) {
drawConnection((x1 + x2)/2.0f, y1, (x2 - x1)*3.f/4.0f + x1, y2);
}
drawNode("" + n.value, n.isBlack, (x1 + x2)/2.0f, y1);
drawTree(n.left, (x2 - x1)*0.f/4.0f + x1, (x2 - x1)*2.f/4.0f + x1, y2, y2 + (y2-y1));
@rafalrusin
rafalrusin / fbtest.c
Created Dec 15, 2011
Linux Frame Buffer Test
View fbtest.c
#include <linux/fb.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>
View filtering.java
private boolean filter(String sSearch, List<Object> list) {
if (sSearch.equals("")) {
return true;
}
return list.toString().contains(sSearch);
}
...
List<List<Object>> filteredList = new ArrayList<List<Object>>();
for (int i = 0; i < myList.size(); i++) {
View ShutdownOutput.java
private static void transferStreams(Socket socket) throws IOException,
InterruptedException {
InputStream input1 = System.in;
OutputStream output1 = socket.getOutputStream();
InputStream input2 = socket.getInputStream();
PrintStream output2 = System.out;
Thread thread1 = new Thread(new StreamTransferer(input1, output1));
Thread thread2 = new Thread(new StreamTransferer(input2, output2));
thread1.start();
thread2.start();
You can’t perform that action at this time.