Skip to content

Instantly share code, notes, and snippets.

View TangMonk's full-sized avatar
🏠
Working from home

David Wu TangMonk

🏠
Working from home
  • Tuols
  • China Chengdu
  • 11:45 (UTC -12:00)
View GitHub Profile
@mpapis
mpapis / example.log
Created June 1, 2012 11:32 — forked from szajbus/log_filter.sh
Filter requests to Rails application by IP address
Started GET "/" for 220.181.108.76 at 2012-06-01 06:28:48 +0000
Processing by PostsController#index as HTML
Rendered posts/index.html.erb within layouts/application (2.0ms)
Completed 200 OK in 4ms (Views: 3.4ms | ActiveRecord: 0.2ms)
@emilstahl
emilstahl / udid.sh
Created January 17, 2016 09:22
Get iOS device UDID in terminal
system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'
@dergraf
dergraf / vernemq_grafana.json
Created October 16, 2015 14:38
VerneMQ Grafana Single Node Dashboard
{
"id": 1,
"title": "VerneMQ",
"originalTitle": "VerneMQ",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"sharedCrosshair": false,
@danwit
danwit / node_acl_example.js
Created April 26, 2014 00:22
Authorization with node_acl + mongo + express
/**
* Simple node_acl example with mongoDB and expressjs
*
* Usage:
* 1. Start this as server
* 2. Play with the resoures
*
* Show all permissions (as JSON)
* http://localhost:3500/info
*
@WizardOfOgz
WizardOfOgz / gist:1012107
Created June 7, 2011 12:13
Save Base64-encoded images with Paperclip
class Avatar < ActiveRecord::Base
attr_accessor :content_type, :original_filename, :image_data
before_save :decode_base64_image
has_attached_file :image,
PAPERCLIP_CONFIG.merge(
:styles => {
:thumb => '32x32#',
:medium => '64x64#',
@grillermo
grillermo / .vimrc
Created March 6, 2015 17:50
Ctrlp using ag the silver searcher
"" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" " ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
@redism
redism / client.js
Created April 25, 2014 09:41
Simple socket.io server performance test
/**
* A simple socket.io client for performance benchmark
*
* Created by redism on 2014. 4. 22..
*/
var SocketIO = require('socket.io-client'),
argv = require('optimist').argv;
var n = argv.n || 10;
@GiaoGiaoCat
GiaoGiaoCat / wechat-useragent.js
Created March 6, 2015 03:59
微信内置浏览器UserAgent的判断
// 检测浏览器的 User Agent 应该是非常简单的事情
// 微信在 Android 下的 User Agent
mozilla/5.0 (linux; u; android 4.1.2; zh-cn; mi-one plus build/jzo54k) applewebkit/534.30 (khtml, like gecko) version/4.0 mobile safari/534.30 micromessenger/5.0.1.352
// 微信在 iPhone 下的 User Agent
mozilla/5.0 (iphone; cpu iphone os 5_1_1 like mac os x) applewebkit/534.46 (khtml, like gecko) mobile/9b206 micromessenger/5.0
// 通过javascript判断
// 很容易看出来,微信的 User Agent 都有‘micromessenger’字符串标示,我们判断是否含有这些字符串就OK了
function isWeixinBrowser(){
@jeanlescure
jeanlescure / headless-chrome-ec2.md
Last active September 2, 2023 07:43
How to setup an EC2 instance to run Chrome Headless for usage with Puppeteer

Chrome Headless on EC2

For puppeteer usage

How to setup an EC2 instance to run Chrome Headless for usage with Puppeteer

1. Spin up ubuntu EC2 instance and ssh into it

ssh ubuntu@ec2-3-21-123-234.compute-1.amazonaws.com
@pnc
pnc / observer.md
Last active September 9, 2023 23:32
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host