This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import math | |
class Point: | |
def __init__(self, x=0, y=0): | |
self.x = x | |
self.y = y | |
def __repr__(self): | |
return 'Point({0.x}, {0.y})'.format(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
Perlin noise generator based on pseudocode from | |
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm | |
''' | |
import math | |
def linear_interp(a, b, x): | |
return a * (1 - x) + b * x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Signal handler example. Debugger starts with Ctrl-C: | |
import signal | |
def int_handler(signal, frame): | |
import pdb | |
pdb.set_trace(frame) | |
signal.signal(signal.SIGINT, int_handler) | |
# Put that at the top of your script and you can start debugging your script at any | |
# point by type Ctrl-C. Resume programe execution by typing exit at the Pdb prompt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.awt.event.*; | |
import javax.swing.*; | |
public class ImageViewer implements KeyListener{ | |
private JFrame frame; | |
private ImageIcon image; | |
private ImageIcon origImage; | |
private JLabel imageLabel; | |
private String[] files; | |
private int index; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> // cout | |
#include <algorithm> // transform | |
#include <vector> // vector | |
using namespace std; | |
void print (int i) { cout << ' ' << i; } | |
struct c_unique { | |
int current; | |
// constructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<sstream> | |
int main(int argc, char** argv){ | |
union mytypes_t { | |
int i; | |
float f; | |
} mytypes; | |
int in_i = 5; | |
float in_f = 5.0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.swing.SwingBuilder | |
import java.awt.BorderLayout as BL | |
import javax.swing.JFrame | |
import javax.swing.ImageIcon | |
import java.awt.Color | |
import java.awt.Graphics2D | |
import java.awt.image.BufferedImage | |
import javax.imageio.ImageIO | |
import javax.swing.SwingUtilities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Color | |
import java.awt.Graphics2D | |
import java.awt.image.BufferedImage | |
import javax.imageio.ImageIO | |
Red = new Color(255, 0, 0) | |
Green = new Color(0, 255, 0) | |
Blue = new Color(0, 0, 255) | |
Orange = new Color(255, 165, 0) | |
Yellow = new Color(255, 255, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.swing.SwingBuilder | |
import java.awt.BorderLayout as BL | |
import javax.swing.JFrame | |
final int COUNT = 20 | |
xs = [] | |
ys = [] | |
ops = [] | |
results = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.annotation.tailrec | |
abstract class Suit { val value: Int } | |
case object Clubs extends Suit { val value = 0 } | |
case object Diamonds extends Suit { val value = 1 } | |
case object Hearts extends Suit { val value = 2 } | |
case object Spades extends Suit { val value = 3 } | |
abstract class Rank { val value: Int } |