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
/** | |
* This sample demonstrates how to return the results | |
* of a CASE statement in a short way without wrapping | |
* it into BEGIN/END, declaring and setting variables | |
* and returning the result at the end. | |
* | |
* Author: Jan Beilicke <dev@jotbe-fx.de> | |
* Date: 2011-07-06 | |
*/ | |
DROP FUNCTION IF EXISTS caseTestShort; |
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
/** | |
* This script has been tested in MySQL 5.1.37. | |
* It might work with other SQL-DBMS as well. | |
*/ | |
DROP FUNCTION IF EXISTS getSqlDate; | |
DELIMITER // | |
CREATE FUNCTION getSqlDate(str VARCHAR(10)) | |
RETURNS VARCHAR(10) DETERMINISTIC | |
CASE |
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 python | |
"""This script checks the Last-Modified header of a remote file. | |
It will use Growl to notify the user, when the field differs from a specified comparison time. | |
""" | |
__author__ = 'Jan Beilicke' | |
__date__ = '2011-07-24' | |
import sys |
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
function callAjax(u, d, t) { | |
jQuery.ajax({ | |
contentType: "application/x-www-form-urlencoded; charset=UTF-8", | |
dataType: "html", | |
type: "POST", | |
url: u, | |
data: d, | |
success: function(msg) { | |
if(t) { | |
if(t === ':eval') { |
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
# Sample usage: | |
# $ gawk -F, -v coli=9 -v colc=10 -f calc_totals.awk < file.csv | |
BEGIN{ | |
# Separator for the output | |
sep = "," | |
# coli is the position of the imps column. | |
# It is passed as an arg, eg. -v coli=9 | |
if (coli > 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
>>> # Will only return the two requested fields | |
>>> db(db.page.name=='delft').select(db.page.name, db.page.title).first() | |
<Row {'name': 'delft', 'title': 'Delft'}> | |
>>> # Adding the primary key 'id' will return the requested fields BUT all objects and functions too | |
>>> db(db.page.name=='delft').select(db.page.id, db.page.name, db.page.title).first() | |
<Row {'comment': <gluon.dal.Set object at 0x102ca8d50>, 'name': 'delft', 'title': 'Delft', 'update_record': <function <lambda> at 0x102cbc488>, 'page_archive': <gluon.dal.Set object at 0x102ca8c90>, 'document': <gluon.dal.Set object at 0x102cba4d0>, 'id': 3, 'delete_record': <function <lambda> at 0x102cbc578>}> | |
>>> # Using as_dict() will only return the requested fields | |
>>> db(db.page.name=='delft').select(db.page.id, db.page.name, db.page.title).first().as_dict() |
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
# Model: | |
# | |
#db.define_table('page', | |
# Field('name', unique=True), | |
# Field('title'), | |
# Field('body', 'text'), | |
# Field('created_on', 'datetime', default=request.now, update=request.now), | |
# Field('created_by', db.auth_user, default=auth.user_id), | |
# Field('change_note', length=200), | |
# format='%(title)s') |
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
#!/bin/env python | |
""" | |
9.15 Value Iteration 3 | |
============================== | |
We got the following world:: | |
+--+-----+-----+-----+-----+ | |
| | 1 | 2 | 3 | 4 | | |
+--+-----+-----+-----+-----+ |
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
#!/bin/env python | |
"""Chapter 16.21 Linear filter | |
We got the following matrix :math:`I` of a grayscale image from video 16.20:: | |
255 7 3 | |
212 240 4 | |
218 216 230 | |
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
#!/bin/env python | |
""" | |
Optional NLP Programming Task - Part One (Rotation Cipher) | |
========================================================== | |
""" | |
__author__ = 'Jan Beilicke <dev +at+ jotbe-fx +dot+ de>' | |
__date__ = '2011-12-19' | |
if __name__ == '__main__': |
OlderNewer