Skip to content

Instantly share code, notes, and snippets.

View airyland's full-sized avatar
☀️
Working from home

Airyland airyland

☀️
Working from home
View GitHub Profile
@airyland
airyland / console.js
Last active March 8, 2023 01:52
ChatGPT Bill Caculator
// https://platform.openai.com/account/usage
// Run code in the console to avoid bankruptcy
var $labels = document.querySelectorAll('.usage-table .expn-title .expn-icon')
$labels[0].click()
var $items = document.querySelectorAll('.expn.expanded .expn-content .expn-icon')
for (let i = 0; i < $items.length; i++) {
$items[i].click()

Hello

Hello

Hello

/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path')
@airyland
airyland / img2txt.js
Created September 26, 2013 15:59 — forked from justjavac/img2txt.js
var cv = document.getElementById('cv');
var c = cv.getContext('2d');
var txtDiv = document.getElementById('txt');
var fileBtn = document.getElementById("up-button");
var img = new Image();
img.src = 'a.jpg';
img.onload = init; // 图片加载完开始转换
fileBtn.onchange = getImg;
// 根据灰度生成相应字符

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<span></span>
<script>console.log('hello world');</script>

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Sun, 12 Aug 2012 10:35:24 GMT till Mon, 12 Aug 2013 10:35:24 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter((user) -&gt; user.followers &gt; 188)
@airyland
airyland / cookie.js
Created July 17, 2013 08:46
App设置cookie
@airyland
airyland / 前端打点.md
Last active June 23, 2017 07:00
前端错误监控

前端错误监控

注:目前是前端实验性质的工具。

开发环境和用户使用环境不一致,开发时无法对所有浏览器做测试。但是由用户来反馈错误过于被动。为了主动地收集错误并解决,在网页上加了一个JavaScript错误监控脚本。

window.onerror捕获页面上的JavaScript运行错误,并使用beacon的方式保存到seedit.duapp.com上。

window.onerror

function randomColor(){
return "rgb("+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+")";
}
function showBoxes(window) {
var rects = [];
function getRects(node){
var range = window.document.createRange();
range.setStartBefore(node);
range.setEndAfter(node);