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.*; | |
import javax.script.*; | |
public class ScriptRunner extends JFrame{ | |
public static void main(String[] args){ | |
new ScriptRunner(); | |
} |
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 javax.script.*; | |
public class ScriptEngineQuery{ | |
public static void main(String[] args){ | |
ScriptEngineManager manager = new ScriptEngineManager(); | |
for(ScriptEngineFactory factory : manager.getEngineFactories()){ | |
System.out.println("Engine: " + factory.getEngineName()); |
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 javax.script.*; | |
public class ScriptInterfaceCast{ | |
public static void main(String[] args) throws Exception{ | |
ScriptEngineManager manager = new ScriptEngineManager(); | |
ScriptEngine rhino = manager.getEngineByName("javascript"); | |
String script | |
= "function JSRunnable(){\n" | |
+ " this.run = function(){\n" |
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.util.HashMap; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Scanner; | |
import java.util.concurrent.Callable; | |
import java.util.concurrent.CompletionService; | |
import java.util.concurrent.ExecutionException; | |
import java.util.concurrent.ExecutorCompletionService; | |
import java.util.concurrent.ExecutorService; |
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 | |
from pprint import pprint | |
from collections import deque | |
#resistors = [10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82] | |
resistors = [82, 68, 56, 47, 39, 33, 27, 22, 18, 15, 12, 10] | |
decades = {} | |
# generate and cache decade lists on demand |
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 | |
from math import ceil | |
def base_area(n, width, length, height): | |
return n * ( 2 * width * height + 2 * length * height + length * width) | |
def run_case(in_it): | |
n, width, length, height, area, m = next(in_it).split() | |
n = int(n) | |
width = int(width) |
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
def main(): | |
pass | |
if __name__ == '__main__': | |
import doctest | |
failure_count, test_count = doctest.testmod() | |
if failure_count == 0: | |
main() |
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 pygame | |
import atexit | |
pygame.init() | |
atexit.register(pygame.quit) | |
size = width, height = 500,500 | |
black = 0, 0, 0 | |
white = 0xff, 0xff, 0xff |
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 operator | |
import math | |
class Vec3d(object): | |
"""3d vector class, supports vector and scalar operators, | |
and also provides a bunch of high level functions. | |
reproduced from the vec2d class on the pygame wiki site. |
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 pygame | |
from pygame.locals import * | |
#http://ezide.com/games/writing-games.html | |
DIRECTION_UP = 0 | |
DIRECTION_DOWN = 1 | |
DIRECTION_LEFT = 2 | |
DIRECTION_RIGHT = 3 |
OlderNewer