Skip to content

Instantly share code, notes, and snippets.

# Is the file ending with a newline? Python Function
def ending_with_newline(filename):
last_byte = None
with open(filename, "rb") as f:
while True:
byte = f.read(1)
if not byte:
break
last_byte = byte
public class Camera {
float pos_x;
float pos_y;
float pos_z;
float rot_x;
float rot_y;
float rot_z;
class GearsKeyAdapter extends KeyAdapter {
public void keyPressed(KeyEvent e) {
int kc = e.getKeyCode();
if(KeyEvent.VK_LEFT == kc) {
view_roty -= 1;
} else if(KeyEvent.VK_RIGHT == kc) {
view_roty += 1;
} else if(KeyEvent.VK_UP == kc) {
view_rotx -= 1;
} else if(KeyEvent.VK_DOWN == kc) {
@ronnyworm
ronnyworm / GraphDrawer.java
Last active March 25, 2017 13:18
Draw a graph (similar to GeoGebra)
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.LayoutStyle;
@ronnyworm
ronnyworm / HelloJOGL2.java
Last active March 25, 2017 13:18
Simple JOGL Test (not my code!)
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.*;
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.glu.GLU;
public class HelloJOGL2 extends JFrame implements KeyListener{