Skip to content

Instantly share code, notes, and snippets.

View cstrap's full-sized avatar
🐍

Christian Strappazzon cstrap

🐍
View GitHub Profile
@cstrap
cstrap / json_field.py
Created November 8, 2010 16:51 — forked from paltman/json_field.py
Serialize JSON object into a model object and retrieve a python dictionary on load
from django.db import models
from django.utils import simplejson as json
from django.conf import settings
from datetime import datetime
import time
class JSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, datetime):
return obj.strftime('%Y-%m-%d %H:%M:%S')
@cstrap
cstrap / QrCodeCreator.py
Created February 10, 2011 17:02
Command line QrCode creation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
from pygooglechart import QRChart
class QrCodeCreator(object):
def __init__(self):
self.parser = argparse.ArgumentParser(description='QrCode Creation')
@cstrap
cstrap / MyISAM2InnoDB.sh
Created July 21, 2011 17:39
MySQL convert tables from MyISAM to InnoDB
#!/bin/bash
MUSER="$1"
MPASS="$2"
MDB="$3"
HOST="$4"
# Detect paths
MYSQL=$(which mysql)
AWK=$(which awk)
GREP=$(which grep)
@cstrap
cstrap / zapDbTable.sh
Created July 21, 2011 17:43
MySQL zap all database tables
#!/bin/bash
MUSER="$1"
MPASS="$2"
MDB="$3"
HOST="$4"
# Detect paths
MYSQL=$(which mysql)
AWK=$(which awk)
GREP=$(which grep)
@cstrap
cstrap / SearchResultSnippetTag.java
Created October 26, 2011 08:06
Patch search result snippettag, magnolia-cms
// @author cstrap PATCH: unescape string and complete first and last snippets's words
/**
* This file Copyright (c) 2003-2011 Magnolia International
* Ltd. (http://www.magnolia-cms.com). All rights reserved.
*
*
* This file is dual-licensed under both the Magnolia
* Network Agreement and the GNU General Public License.
* You may elect to use one or the other of these licenses.
@cstrap
cstrap / pymodoro.py
Created May 9, 2012 16:25 — forked from vrde/pymodoro.py
simple pomodoro implementation with pynotify
import pynotify
from time import sleep
def mins_to_secs(ms):
return map(lambda x: x * 60, ms)
class Pymodoro(object):
POMODORO_TIME = 25 * 60
POMODORO_CHECKPOINTS = mins_to_secs([25, 15, 10, 5, 3, 1]) + range(10)
@cstrap
cstrap / flaskapp.py
Created June 9, 2012 16:34 — forked from kennethreitz/flaskapp.py
My typical flask app base
# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_heroku import Heroku
from flask_sslify import SSLify
from raven.contrib.flask import Sentry
from flask.ext.celery import Celery
@cstrap
cstrap / tableview.m
Created October 15, 2012 17:11
Example of working tableview with async images
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CGSize newSize = CGSizeMake(70, 70);
Story *currentStory = [[storyParser stories] objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
@cstrap
cstrap / flaskapp_init.py
Created November 9, 2012 17:56 — forked from uolter/flaskapp_init.py
flask application basic setup
#!/usr/local/bin/python
from optparse import OptionParser
import os
PATH_SEPARATOR = os.sep
html_page = "<!DOCTYPE html>\n" \
" <html>\n" \
var currentWin = Ti.UI.currentWindow;
// below example would require variable declarations for Name, Description, image, Lat, Longitude
// Docs:
// http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.Annotation-object
// http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.MapView-object
//
// CREATE MAP VIEW
//