Skip to content

Instantly share code, notes, and snippets.

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 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));
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();
View calculator.lex
%{
#include "calculator.tab.h"
using namespace std;
%}
%%
[ \t] ;
\+ { return PLUS; }
\- { return MINUS; }
\* { return MUL; }
\/ { return DIV; }
@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>
You can’t perform that action at this time.