Skip to content

Instantly share code, notes, and snippets.

View mrkschan's full-sized avatar
😀

KS Chan mrkschan

😀
View GitHub Profile
import pymongo, gridfs
conn = pymongo.Connection('localhost')
fs = gridfs.GridFS(conn.test)
fid = fs.put('hello', filename='1st')
fid
# ObjectId('4beb91f78caf495b3e000000')
fid2 = fs.put('hello 2', filename='2nd', _id=fid)
fid2
# ObjectId('4beb91f78caf495b3e000000')
fs.list()
public void onStatus(StatusEvent e) {
final RobotStatus s = e.getStatus();
others = peer.getOthers();
62c62
< self._config_section = "engine/Table/%s" % self._name.replace(' ','_')
---
> self._config_section = "engine/Table/%s" % self._name
83c83
< # self._cursor: the caret position in preedit phrases
---
> # self._cursor: the caret position in preedit phrases
103,106c103,107
< self._chinese_mode = self._config.get_value (
def count_down(self, counting=3):
''' called before manauton '''
label = 'Prepare to speak: '
for i in xrange(counting):
label += str(counting - i) + '... '
threading.Thread(target=self.hint_label.set_text, args=(label,)).start()
time.sleep(1)
public void gotoCoordinate(int x, int y)
{
// using Pythagoras' theorem to get the distance to travel
int goto_distance = (int) Math.sqrt(
(double) (x - robotX) * (x - robotX)
import robocode.util.Utils;
import robocode.JuniorRobot;
public class Example extends JuniorRobot {
public void random_movement()
{
public void run() {
if (others < 1) { // see http://robocode.cs.cityu.edu.hk/javadoc/robocode/JuniorRobot.html#others
// won
setColors( ... );
}
:
:
@mrkschan
mrkschan / pre-commit
Created June 16, 2011 06:38
a pre-commit hook for git to remove trailing whitespace
#!/bin/sh
#
# A git hook script to find and fix trailing whitespace
# in your commits. Bypass it with the --no-verify option
# to git-commit
# Ref - http://is.gd/PerowD
#
if git rev-parse --verify HEAD >/dev/null 2>&1
then
class Tag(models.Model):
"""
A tag.
"""
name = models.CharField(_('name'), max_length=50, unique=True, db_index=True)
objects = TagManager()
class Meta:
ordering = ('name',)
@mrkschan
mrkschan / gist:1223565
Created September 17, 2011 02:44
CiviCRM Patch for Amazon SES
Index: civicrm-4.0.4/CRM/Mailing/BAO/Mailing.php
diff --git a/civicrm-4.0.4/CRM/Mailing/BAO/Mailing.php b/civicrm-4.0.4/CRM/Mailing/BAO/Mailing.php
index 2ee9ac79f89bed1232858c75b8c6a180a3335c91..f926712922a4d3ec6c38ad16d495f12d6db76945 100644
--- a/civicrm-4.0.4/CRM/Mailing/BAO/Mailing.php
+++ b/civicrm-4.0.4/CRM/Mailing/BAO/Mailing.php
@@ -1130,7 +1130,6 @@ AND civicrm_mailing.id = civicrm_mailing_job.mailing_id";
$headers['To'] = "$toName <$toEmail>";
- $headers['Precedence'] = 'bulk';