Skip to content

Instantly share code, notes, and snippets.

class Profile(models.Model):
user = models.ForeignKey(User, unique=True, related_name="profile")
coatOfArms = models.CharField(default="", max_length=1000, blank=True)
about = models.TextField(default="", max_length=10000, blank=True)
specialCharge = models.CharField(default="", max_length=1000, blank=True)
@property
def safe_coa(self):
try:
return json.dumps(json.loads(self.coatOfArms))
except Exception as e:
@Zarkonnen
Zarkonnen / startproject.sh
Created February 27, 2014 12:19
Shell script to set up a django project folder structure.
#! /bin/sh
# Instructions: ./startproject.sh projectname appname
mkdir $1
cd $1
virtualenv .
source bin/activate
pip install django
git init $1
@Zarkonnen
Zarkonnen / integration.js
Created March 4, 2014 09:39
The JS object that would be attached to the document of select pages to allow communication with Sauce Connect.
{
/**
* Set any of the following settings by passing in a settings object.
*
* If the user has not previously approved setting settings for this account name and access key,
* they will be prompted to.
*
* The following settings keys are available:
* accountname
* accesskey
@Zarkonnen
Zarkonnen / index.html
Created March 4, 2014 13:21
Useful baseline index.html for Bootstrap.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
if (sauce.runall.requeststop) {
for (var i = 0; i < sauce.runall.runs.length; i++) {
if (!sauce.runall.runs[i].complete && sauce.runall.runs[i].playbackRun) { return false; }
}
} else {
for (var i = 0; i < sauce.runall.runs.length; i++) {
if (!sauce.runall.runs[i].complete) { return false; }
}
}
return true;
@Zarkonnen
Zarkonnen / flappy.html
Created March 12, 2014 12:50
Flappy dot! A HTML5 game loop demo.
<!DOCTYPE html>
<html>
<head>
<title>Flappy Dot</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<body>
A demonstration of a HTML5 game loop. I hereby release this into the public domain or its nearest equivalent.<br>
<canvas width="800" height="600" id="gameCanvas"></canvas>
@Zarkonnen
Zarkonnen / error.txt
Created March 15, 2014 08:18
Vigilante 2048 boot error on OS X 10.7
zarkonnens-macbook-pro:Downloads zar$ java -jar Vigilante2084.jar
Sat Mar 15 09:17:17 CET 2014 INFO:Slick Build #264
Sat Mar 15 09:17:17 CET 2014 INFO:LWJGL Version: 2.8.5
Sat Mar 15 09:17:17 CET 2014 INFO:OriginalDisplayMode: 1440 x 900 x 32 @0Hz
Sat Mar 15 09:17:17 CET 2014 INFO:TargetDisplayMode: 1024 x 600 x 0 @0Hz
JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
Sat Mar 15 09:17:18 CET 2014 ERROR:Could not get the JAWT interface
org.lwjgl.LWJGLException: Could not get the JAWT interface
@Zarkonnen
Zarkonnen / readfile.java
Created March 26, 2014 10:58
You can make things arbitrarily short using the magic of helper functions and some slight unicode abuse...
public static String ←(String path) {
return new String(Files.readAllBytes(Paths.get("duke.java")));
}
// Usage:
String f = ←("myfile.txt");

Redefining the civlike

  • scale at the building level with small tiles
  • each civ has an unique mechanic: goblins steal children, for example, while dwarves get an underlayer to use, and elves don't degrade the environment
  • armies are arrows with supply tails, not units
  • normal buildings autoplace but special ones do not
  • roads and trading routes autoplace
  • culture prevents bad stuff from happening
  • environmental degradation is relevant
/** Mutates l. */
public void addNumber(int n, List<Integer> l)
l.add(n);
}
/** Does not mutate l1 despite using a state-modifying function. */
public void getListOfFirstNumberIn(List<Integer> l1) {
ArrayList<Integer> l2 = new ArrayList<Integer>();
addNumber(l1.get(0), l2);
return l;2