Skip to content

Instantly share code, notes, and snippets.

View wangbinyq's full-sized avatar
🦀
Build Cool Things

wangb wangbinyq

🦀
Build Cool Things
  • Shanghai
View GitHub Profile
@kylestev
kylestev / JavaScript Injection
Created May 23, 2012 03:50
JavaScript injection into HTML documents using Fiddler
import Fiddler;
class Handlers {
static var injectJs = "<script>alert('I see you enjoy YouTube.')</script>";
static var hostList = new HostList("*.youtube.com");
static function OnBeforeResponse(oSession : Session) {
// Filter to only HTML documents and on the domains we want
if (hostList.ContainsHost(oSession.hostname) && oSession.oResponse.headers.ExistsAndContains("Content-Type", "text/html")) {
oSession.utilDecodeResponse();
@denji
denji / http-benchmark.md
Last active October 1, 2025 14:39
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)
@staltz
staltz / introrx.md
Last active October 26, 2025 03:06
The introduction to Reactive Programming you've been missing
@rattrayalex
rattrayalex / MessageStore_FluxBone.js
Last active June 19, 2020 09:40
Flux and Backbone
var ChatAppDispatcher = require('../dispatcher/ChatAppDispatcher');
var ChatConstants = require('../constants/ChatConstants');
var ChatMessageUtils = require('../utils/ChatMessageUtils');
var EventEmitter = require('events').EventEmitter;
var ThreadStore = require('../stores/ThreadStore');
var merge = require('react/lib/merge');
var ActionTypes = ChatConstants.ActionTypes;
var CHANGE_EVENT = 'change';
@wvengen
wvengen / extend.sh
Last active September 27, 2025 02:40
Extend non-HiDPI external display above HiDPI internal display
#!/bin/sh
# extend non-HiDPI external display on DP* above HiDPI internal display eDP*
# see also https://wiki.archlinux.org/index.php/HiDPI
# you may run into https://bugs.freedesktop.org/show_bug.cgi?id=39949
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/883319
EXT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^eDP | head -n 1`
INT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^DP | head -n 1`
ext_w=`xrandr | sed 's/^'"${EXT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
@wesbos
wesbos / tab-trigger.js
Created November 16, 2015 19:33
How to properly get a TAB trigger working with Emmet inside of JSX
{
"keys": ["tab"],
"command": "expand_abbreviation_by_tab",
// put comma-separated syntax selectors for which
// you want to expandEmmet abbreviations into "operand" key
// instead of SCOPE_SELECTOR.
// Examples: source.js, text.html - source
"context": [
{
@wangbinyq
wangbinyq / mvvm.js
Last active October 24, 2016 08:50
(function() {
'use strict'
;function defined(o) {
return o !== undefined && o !== null
}
;function Binding(vm, el, key, binder) {
this.vm = vm
this.el = el
@wangbinyq
wangbinyq / findClass.js
Created January 18, 2017 02:10
find how many html element have class or id
(() => {
const $ = document.querySelectorAll.bind(document)
const info = {}
const total = [0, 0]
$('*').forEach((el) => {
const nodeName = el.nodeName
const tagInfo = (info[nodeName] = info[nodeName] || [0, 0])
tagInfo[0] += 1
@stevedonovan
stevedonovan / shared.rs
Created April 14, 2017 13:49
An ergonomic way of saying Rc<RefCell>
use std::rc::Rc;
use std::cell::{RefCell,Ref, RefMut};
use std::ops::Deref;
use std::fmt;
#[derive(Clone)]
struct Shared<T> {
v: Rc<RefCell<T>>
}
@wangbinyq
wangbinyq / dom element position and rect attributes
Last active August 4, 2017 01:47
dom element position and rect attributes
# position:
// relative to the document
$(el).offset = {
top: rect.top + window.scrollY,
left: rect.left + window.scrollX
} where rect = el.getBoundingClientRect()
// relative to the offset parent
$(el).position = {