Skip to content

Instantly share code, notes, and snippets.

View GerBawn's full-sized avatar

GerBawn GerBawn

  • shenzhen, guangzhou
View GitHub Profile
@GerBawn
GerBawn / cloudSettings
Created October 21, 2021 08:06
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-10-21T08:06:52.713Z","extensionVersion":"v3.4.3"}
@GerBawn
GerBawn / parse.js
Created March 5, 2021 12:40
可序列化函数的序列化方法
const arrayFunctionRegExp = /^\s*\([\w\s,]*\)\s*=>/; //箭头函数
const commonFunctionRegExp = /^\s*function\s*\(/; //普通的以function xxx()定义的函数
function serialize(obj) {
return JSON.stringify(obj, (key, value) => {
if (typeof value === "function") {
let str = value + "";
if (!commonFunctionRegExp.test(str) && !arrayFunctionRegExp.test(str)) {
str = `function ${str}`;
}
@GerBawn
GerBawn / cloudSettings
Last active December 30, 2020 02:01
个人Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-12-30T02:01:17.791Z","extensionVersion":"v3.4.3"}
@GerBawn
GerBawn / redis_6379
Created May 24, 2018 06:31
redis init script
#!/bin/sh
#Configurations injected by install_server below....
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_6379.pid
CONF="/etc/redis/6379.conf"
REDISPORT="6379"
###############
# SysV Init Information
function copyDir($src, $dst)
{
if (!is_dir($src)) {
throw new Exception('src must is a directory.');
}
$absoluteSrcPath = realpath($src);
$absoluteDstPath = realpath($dst);
$dirname = basename($absoluteSrcPath);
@GerBawn
GerBawn / myReady.js
Created November 3, 2015 13:16
模拟domReady
/**
* Created by ling on 2015/11/3.
*/
var myReady = function(fn){
if(document.addEventListener){
document.addEventListener('DOMContentLoaded', fn, false);
}else{
IEContentLoaded(fn);
}
@GerBawn
GerBawn / array_function.php
Last active September 23, 2015 08:27
数组辅助函数
<?php
/**
* 不支持大小写,但速度较快
*/
function array_change_key_case_recursive($arr, $case){
return array_map(function($item){
if(is_array($item))
return array_change_key_case_recursive($item, $case);
}, array_change_key_case($arr, $case));
}
@GerBawn
GerBawn / mcrypt.php
Created September 23, 2015 01:32
des加密
<?php
/**
* Created by PhpStorm.
* User: tew
* Date: 2015/9/23
* Time: 9:32
*/
class mcrypt{
public static $key = '7fdc4b8e';
public static function encode($text){
@GerBawn
GerBawn / download.php
Created August 20, 2015 03:36
php提供文件下载
<?php
$file = "/tmp/dummy.tar.gz";
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
header("Content-Length: ". filesize($file));
readfile($file);
?>
@GerBawn
GerBawn / downloadFile.php
Created August 13, 2015 01:35
download something from Internet
<?php
function downloadFile($url, $saveName){
set_time_limit(0);
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);