Skip to content

Instantly share code, notes, and snippets.

View goocarlos's full-sized avatar

Luyu Zhang goocarlos

View GitHub Profile
@goocarlos
goocarlos / THE PMARCA GUIDE TO STARTUPS.md
Created July 9, 2023 12:20 — forked from xyb/THE PMARCA GUIDE TO STARTUPS.md
Marc Andreessen 的创业指导
import os
import re
import time
from colorama import Fore, Style
"""
该程序可以找到所有项目中包含所有 Python 文件中的中文注释
This program can find all Chinese comments in all Python files in the project
Author: goocarlos<goocarlos@gmail.com>
@goocarlos
goocarlos / folderSize.swift
Created January 14, 2015 14:30
folderSize Swift Implementation
class func folderSize(folderPath:String) -> UInt{
// @see http://stackoverflow.com/questions/2188469/calculate-the-size-of-a-folder
let filesArray:[String] = NSFileManager.defaultManager().subpathsOfDirectoryAtPath(folderPath, error: nil)! as [String]
var fileSize:UInt = 0
for fileName in filesArray{
let filePath = folderPath.stringByAppendingPathComponent(fileName)
let fileDictionary:NSDictionary = NSFileManager.defaultManager().attributesOfItemAtPath(filePath, error: nil)!
<?php
/**
* 生成一个 $l 位的 62 进制随机字符串, 其第一位字符不为数字
* @author Luyu Zhang<goocarlos@gmail.com>
*/
function mt_rand_base62($l) {
$c = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
for ($s = '', $cl = strlen($c)-1, $i = 0; $i < $l; $s .= $c[mt_rand(0, $cl)], ++$i);
@goocarlos
goocarlos / MY_Input.php
Created August 17, 2013 08:38
扩展 Input 库解决 Codeigniter 在中国的 IP 地址问题
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* 扩展的 Input 库
* @author Luyu<luyu.zhang@autotiming.com>
*/
class MY_Input extends CI_Input
{
function __construct()
@goocarlos
goocarlos / lucky_draw_from_pool.php
Created May 22, 2013 08:37
每天生成 N 个中奖机会到奖池,从奖池进行抽奖,代码数据库操作部分依赖 Codeigniter。
<?php
//CREATE TABLE IF NOT EXISTS `pool` (
//`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
//`active_time` datetime NOT NULL COMMENT '活动时间',
//`used_time` datetime DEFAULT NULL COMMENT '被使用时间',
//`status` tinyint(4) NOT NULL,
//PRIMARY KEY (`id`),
//KEY `active_time_status` (`active_time`,`status`)
//) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;