Skip to content

Instantly share code, notes, and snippets.

View firedfox's full-sized avatar
🎯
Focusing

Daniel Wang firedfox

🎯
Focusing
  • Weimob
  • Shanghai, China
  • 12:31 (UTC +08:00)
View GitHub Profile
@firedfox
firedfox / onDOMContentLoaded.js
Created April 24, 2012 02:12
phantomjs onDOMContentLoaded
const PHANTOM_FUNCTION_PREFIX = '/* PHANTOM_FUNCTION */';
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
if (msg.indexOf(PHANTOM_FUNCTION_PREFIX) === 0) {
eval('(' + msg + ')()');
} else {
console.log(msg);
}
@firedfox
firedfox / web3-test.js
Last active October 8, 2021 11:32
web3 test
const Web3 = require('web3');
const web3 = new Web3('https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161');
const myWalletAddress = '0x8bD4DD33e7a479409d8bb8c1eA33BCf6f5625391';
const artBlocksBroker = {
address: '0xE52A2A7B8dACe2ff8cdC64EabB605821A393474D',
abi: [{"inputs":[{"internalType":"address","name":"_profitReceiver","type":"address"},{"internalType":"uint256","name":"_artBlocksBrokerFeeBips","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"uint256","name":"_artBlocksProjectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_priceInWeiEach","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_quantity","type":"uint256"},{"indexed":false,"internalType":"string","name":"_action","type":"string"},{"indexed":false,"internalType":"uint256","name":"_optionalTokenId","type":"uint256"}],"name":"Action"
@firedfox
firedfox / ga.js
Created June 28, 2016 10:16
ga.js v4.9.1
/**
* 代码翻译:周培公
* 电子邮件:peigong@foxmail.com
* 腾讯微博:http://t.qq.com/lanxmail
* 新浪微博:http://weibo.com/1766654653
* 个人主页:http://hi.baidu.com/lanxmail
* 代码地址:http://www.google-analytics.com/ga.js
* 文档地址:http://code.google.com/intl/zh-CN/apis/analytics/
* @fileoverview Google Analytics(分析)客户端javascript代码。
*/
@firedfox
firedfox / gist:2037411
Created March 14, 2012 15:49
check google ads with phantomjs
var page = require('webpage').create();
page.settings.loadImages = false;
page.onConsoleMessage = function(msg) { console.log(msg); };
var pageUrl = 'http://www.bloggersentral.com/2010/08/how-put-add-adsense-on-blogger.html';
var num = 0;
var max = 2;
page.onLoadFinished = function() {
var text = page.evaluate(function() {
@firedfox
firedfox / getUUID.js
Created July 11, 2018 06:10
generate UUID
/**
* 获取一个随机的uint8
*
* @return {number} 随机数
*/
const getRandomUint8 = () =>
(typeof crypto !== 'undefined' && crypto.getRandomValues
? crypto.getRandomValues(new Uint8Array(1))[0]
: Math.floor(Math.random() * 0xff));
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>demo</title>
</head>
<body>
<h3>用户的输入</h3>
<form id="demo-form">
<label>姓名 <input name="name" type="text"></label>
@firedfox
firedfox / git-change-author.sh
Created May 10, 2018 13:10
修改git提交记录中的用户名和邮箱
#!/bin/bash
git filter-branch --env-filter '
WRONG_NAME="your wrong name"
WRONG_EMAIL="your wrong email"
NEW_NAME="your new name"
NEW_EMAIL="your new email"
if [ "$GIT_COMMITTER_NAME" = "$WRONG_NAME" -o "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
@firedfox
firedfox / webpack.config.js
Created April 28, 2018 02:48
webpack config
/**
* @file webpack配置文件
* @author wangyang02
*/
const webpack = require('webpack');
module.exports = {
entry: __dirname + '/src/index.js',
output: {
/**
* @file rollup配置文件
* @author wangyang02
*/
import babel from 'rollup-plugin-babel';
export default [{
input: 'src/index.js',
plugins: [
const http = require('http');
const PORT = 3000;
const server = http.createServer((req, res) => {
if (req.method !== 'POST') {
return res.end('');
}
console.log('\nheader:');