Skip to content

Instantly share code, notes, and snippets.

View yesmeck's full-sized avatar
:octocat:
<img src="x" onerror="alert(1)" />

Wei Zhu yesmeck

:octocat:
<img src="x" onerror="alert(1)" />
View GitHub Profile
@yesmeck
yesmeck / bundle.js
Last active September 21, 2017 03:57
redundant __webpack_require__
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
@yesmeck
yesmeck / memcached.rb
Created December 17, 2012 04:02
List all keys in memcached
#!/usr/bin/env ruby
require 'net/telnet'
cache_dump_limit = 100
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3)
slab_ids = []
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c|
matches = c.scan(/STAT items:(\d+):/)
slab_ids = matches.flatten.uniq
end
@yesmeck
yesmeck / detect-port
Created June 5, 2017 08:57
detect which command using port
#!/bin/sh
port=$1
pid=`lsof -i :${port} -P -t -sTCP:LISTEN`
dir=`lsof -p ${pid} | awk '$4=="cwd" {print $9}'`
cmd=`ps -o command -p ${pid} | sed -n 2p`
echo "${cmd} in ${dir}"
@yesmeck
yesmeck / tor_note.txt
Last active April 23, 2017 21:32
Tor note
# 更换身份
> telnet localhost 9051
AUTHENTICATE
SETCONF ExitNodes={us}
SETCONF StrictNodes=1
SIGNAL NEWNYM
QUIT
Or
@yesmeck
yesmeck / role_constraint.rb
Created October 19, 2013 19:21
Rails 4 user role constraint
# app/constraints/role_constraint.rb
class RoleConstraint
def initialize(*roles)
@roles = roles.map { |r| r.to_s }
end
def matches?(request)
@roles.include? request.env['warden'].user(:user).try(:role)
end
end
@yesmeck
yesmeck / fixit.sh
Last active March 9, 2017 03:19
Fix your js project!
#!/bin/sh
COLOR_GREEN='\033[0;32m'
echo "${COLOR_GREEN}Remove node_modules."
rm -rf node_modules
echo "${COLOR_GREEN}Remove yarn.lock."
rm -f yarn.lock
if command -v ayarn > /dev/null 2>&1; then
echo "${COLOR_GREEN}Install node_modules use ayarn."
@yesmeck
yesmeck / table-hover-edit.js
Last active November 7, 2016 11:43
Table hover edit
import { Table, Icon, Popover, Input } from 'antd';
class EditableTable extends React.Component {
constructor(props) {
super(props);
this.columns = [{
title: '应用名称',
dataIndex: 'appName',
key: 'appName',
@yesmeck
yesmeck / esnextbin.md
Created August 4, 2016 13:59
esnextbin sketch
@yesmeck
yesmeck / esnextbin.md
Created August 2, 2016 14:13
esnextbin sketch
@yesmeck
yesmeck / index.js
Created August 2, 2016 09:40
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
const React = require('react')
const tuku = require('tuku')
const router = require('tuku/router')