Skip to content

Instantly share code, notes, and snippets.

View mudkipme's full-sized avatar

Mudkip mudkipme

View GitHub Profile
const typeTextMap = {
normal: '一般',
fire: '火',
water: '水',
grass: '草',
electric: '電',
fighting: '格鬥',
flying: '飛行',
poison: '毒',
bug: '蟲',

XXXX

/Share  +-XXX  +-YYY

@mudkipme
mudkipme / app-base.js
Created August 13, 2013 16:35
Extend Marionette.Application for async initialization
define([
'underscore'
,'marionette'
], function(_, Marionette){
var $ = Marionette.$;
// Extend Marionette.Application for async initialization
var AppBase = Marionette.Application.extend({
constructor: function(options){
<?php
header('Content-Length: 0');
$key = array();
$base = urldecode($_SERVER['REQUEST_URI']);
$base_ori = $_SERVER['REQUEST_URI'];
$key[] = $base;
$key[] = $base.'zh';
$key[] = $base.'zh-hans';
$key[] = $base.'zh-hant';
if (strpos($base, '/wiki/') !== FALSE) {
<?php
header('Content-Length: 0');
$url = 'http://static.52poke.com/purge'.$_SERVER['REQUEST_URI'];
@file_get_contents($url);
file_put_contents(
'/home/52poke/logs/wiki-imagepurge.log',
'Purge '.$url.' '.date(DATE_ATOM)."\n",
FILE_APPEND
);
@mudkipme
mudkipme / monitor_progress.js
Last active December 18, 2015 06:08
Monitors mutiple services on 52Poké server.
var exec = require('child_process').exec,
fs = require('fs'),
async = require('async');
var services = [ 'php-fpm', 'nginx', 'mysqld', ['mongod', 'mongodb'], ['redis-server', 'redis'] ];
var logFile = '/home/52poke/logs/monitor.log';
var actions = [];
var addLog = function(str){
fs.appendFileSync(logFile, new Date().toString()+ str + '\n');
@mudkipme
mudkipme / monitor_memcached.js
Last active December 17, 2015 08:59
Monitors memcached on 52Poké server, restart memcached when it's using too much CPU resource.
var exec = require('child_process').exec,
fs = require('fs');
var errorCount = 0;
function getCPU(callback){
exec('top -b -n 1 -p `pgrep memcached`', function(error, stdout, stderr){
var lines = stdout ? stdout.split('\n') : [''],
str = lines[lines.length - 1].substring(47, 52);