Skip to content

Instantly share code, notes, and snippets.

View Leechael's full-sized avatar
🐹
Working from home

Leechael Leechael

🐹
Working from home
View GitHub Profile
<?php
use Symfony\Component\HttpFoundation\File\UploadedFile;
class SmokeTestingController extends \BaseController
{
public function upload()
{
$iniMax = strtolower(ini_get('upload_max_filesize'));
@Leechael
Leechael / foo.swift
Created June 3, 2014 07:19
Property as method and overriding in Swift (impossible for method)
import Cocoa
class A {
var foo : () -> String
var baz : Int
init () {
func _foo () -> String {
return "halo"
}
@Leechael
Leechael / gulpfile.js
Created July 14, 2014 09:31
gulpfile.js for browserify + backbone.js + ractive.js, with watchify
var path = require("path");
var gulp = require("gulp");
var less = require("gulp-less");
var notify = require("gulp-notify");
var rename = require("gulp-rename");
var minifyCSS = require("gulp-minify-css");
var uglify = require("gulp-uglifyjs");
var livereload = require("gulp-livereload");
var source = require("vinyl-source-stream");
#!/bin/bash
# virtualenv-auto-activate.bash
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.bash
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.
@Leechael
Leechael / main.rs
Created September 23, 2015 09:41
Simple log parser in Rust-Lang
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::path::Path;
struct Hit {
ip: String,
datetime: String,
@Leechael
Leechael / WeiboController.php
Created January 25, 2011 05:23
The weibo oauth processing controller with li3_oauth.
<?php
namespace app\controllers;
use lithium\net\http\Router;
use lithium\storage\Session;
use li3_oauth\models\Consumer;
class WeiboController extends \lithium\action\Controller {
@Leechael
Leechael / wget_slides.sh
Created February 13, 2011 07:25
Download all pdf/ppt/pptx/zip/doc/odp files in page
# --------------------------------------------------------------------------------------
# Download all pdf/ppt/pptx/zip/doc/odp files in page.
#
# Usage:
# xxx@xxx:~$ wget_slides http://velocityconf.com/velocity2010/public/schedule/proceedings
# Download all velocity 2010 slides.
# --------------------------------------------------------------------------------------
function wget_slides () {
curl -sX GET "$1" | grep -or 'http:\/\/[^\"]\+\.\(pdf\|pptx\?\|zip\|doc\|odp\)' | awk '{print "\""$0"\""}' | xargs wget
for f in `curl -s http://www.qconbeijing.com/schedule.html | grep -oe '\"[^\"]\+\.\(pdf\|rar\|zip\|ppt\|pptx\|odt\|doc\|docs\)' | cut -d\" -f2`; do wget http://www.qconbeijing.com/$f; done
@Leechael
Leechael / Entity.php
Created March 11, 2012 12:39 — forked from clexmond/Entity.php
Implementing custom getters and setters in Lithium
<?php
namespace path\to\lib;
use BadMethodCallException;
use lithium\core\Libraries;
use lithium\util\Inflector;
/**
* This class can extend either \lithium\data\entity\Record or \lithium\data\entity\Document
@Leechael
Leechael / build-ruby.sh
Created August 26, 2012 12:32
Build Ruby 1.9.3-p194 deb package
#!/usr/bin/env bash
# ----------------------------------------------------------------------------
#
# Test under 64-bit Debian Squeeze
#
# Thanks follow up posts:
#
# - Ruby 1.8.2 and Checkinstall 1.6.0:
# http://checkinstall.izto.org/cklist/msg00770.html