Skip to content

Instantly share code, notes, and snippets.

<?php
namespace webapp;
/**
* base Doctrine entity for convinent orm association
*/
class BaseEntity
{
protected $_properties;
@comfuture
comfuture / screen.css
Created May 9, 2011 13:21
selective screen width (i did not know it works or not)
#flashContent {
width: expression(document.body.clientWidth > 1080 ? '100%' : '1080px');
overflow: expression(document.body.clientWidth > 1080 ? 'hidden' : 'auto');
}
@media screen and (min-width: 1080px) {
#flashContent {
width: 100%;
overflow: hidden;
}
@comfuture
comfuture / recover.py
Created April 19, 2011 06:25
recover broken shiftjis filenames
#!/usr/bin/python
import os
import glob
import re
def recover(s, e='sjis'):
return re.sub(r'\\(...)', lambda m: chr(int(m.group(1), 8)), s).decode(e)
def rename(f):
@comfuture
comfuture / wput.py
Created April 17, 2011 14:01
put a file or url to amazon s3 service
#!/usr/bin/python
import mimetypes
import urllib
import os.path
import sys
import S3 # grep http://developer.amazonwebservices.com/connect/entry.jspa?externalID=134&categoryID=47
AWS_ACCESS_KEY_ID = '****'
AWS_SECRET_ACCESS_KEY = '****'
BUCKET_NAME = '****'
@comfuture
comfuture / ircian.js
Created April 13, 2011 08:38
say hello to ircian bot
exports.plugin = function(bot) {
bot.on('join', function(chan, nick) {
if (nick == 'ircian') {
bot.talk(chan, [[
nick + ':나가!',
nick + ':나가지마!',
nick + ':안녕',
nick + ':메롱'
]]);
}
@comfuture
comfuture / server.js
Created April 5, 2011 06:07
less complier service
var less = require('./less');
with (require('./nano')) {
get(/\/lessc\/(.*)/, function(match) {
try {
var _parsed = URL.parse(match[1], true);
var client = make_client(80, _parsed.host);
var less_req = client.request('GET', _parsed.pathname, {'host': _parsed.host});
less_req.addListener('response', function(less_resp) {
@comfuture
comfuture / brightnesscontrast.pbk
Created February 18, 2011 09:21
filter for brightness and contrast
<languageVersion : 1.0;>
kernel BrightContrast
< namespace : "jp.ncsoft.image.filters";
vendor : "maroo";
version : 1;
description : "adjust contrast and brightness";
>
{
@comfuture
comfuture / policy.json
Created February 15, 2011 11:08
s3 bucket policy - working
{
"Version": "2008-10-17",
"Id": "static.maroo.info",
"Statement": [
{
"Sid": "2- Allow referrers from my domain.",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
@comfuture
comfuture / gist:827368
Created February 15, 2011 10:29
amazon s3 policy by referrer example
{
"Version":"2011-02-15",
"Id":"only allowed referers",
"Statement":[
{
"Sid":"Allow get requests referred by maroo.info and apps.facebook.com",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:GetObject",
"Resource":"arn:aws:s3:::static.maroo.info/*",
@comfuture
comfuture / backup.sh
Created February 9, 2011 08:46
backup daily to remote host, and delete old backups smarter
#!/bin/bash
date=`date "+%Y-%m-%dT%H_%M_%S"`
HOME=/YOUR/LOCALHOME
SERVER=ID@HOST
DIR=backup
rsync -azP \
--bwlimit=500 \
--delete \
--delete-excluded \