Skip to content

Instantly share code, notes, and snippets.

View jeasonstudio's full-sized avatar
:octocat:
Focusing

Jeason jeasonstudio

:octocat:
Focusing
View GitHub Profile
@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(){
@colemanw
colemanw / font-awesome-mime-type-icons.php
Last active March 11, 2024 04:21 — forked from guedressel/font-awesome-mime-type-icons.php
Font Awesome File Icons: Mapping MIME Types to correct icon classes
<?php
/**
* Get font awesome file icon class for specific MIME Type
* @see https://gist.github.com/guedressel/0daa170c0fde65ce5551
*
*/
function ($mime_type) {
// List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml
$icon_classes = array(
@jeasonstudio
jeasonstudio / colorFormat.go
Created February 10, 2017 07:48
ColorFormat RGBA to Hexadecimal
package main
import (
"fmt"
"image"
"image/color"
)
func ColorFormat(color color.Color) string {
thisR, thisG, thisB, _ := color.RGBA()
@jeasonstudio
jeasonstudio / ustb_login.sh
Last active May 15, 2019 08:17
校园网登录脚本
#!/bin/bash
# Your StuNo. & Password
username='00000000'
password='00000000'
curl --retry 3 --data "DDDDD=${username}&upass=${password}&0MKKey=123456789" http://202.204.48.66 --silent -o LOGIN_STATUS.out
echo "Login Success!!"
@justinfagnani
justinfagnani / mixins.md
Last active April 13, 2022 12:14
Maximally Minimal Mixins
@tannerlinsley
tannerlinsley / Counter.js
Last active July 8, 2024 07:06
Global React State with Context and Immer
import { useCount, useIncrement, useDecrement } from './store.Count'
export default function Counter () {
const count = useCount()
const increment = useIncrement()
const decrement = useDecrement()
return (
<div>
<div>Count: {count}</div>
@sindresorhus
sindresorhus / esm-package.md
Last active July 15, 2024 20:29
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@noobnooc
noobnooc / cloudflare-worker-proxy.js
Last active June 25, 2024 09:44
cloudflare-worker-proxy
// Website you intended to retrieve for users.
const upstream = 'api.openai.com'
// Custom pathname for the upstream website.
const upstream_path = '/'
// Website you intended to retrieve for users using mobile devices.
const upstream_mobile = upstream
// Countries and regions where you wish to suspend your service.
@jeasonstudio
jeasonstudio / deploy.js
Created October 27, 2023 07:17
Deploy on scroll mainnet
// 切换到 Scroll Mainnet (0x82750)
// 或者是 Scroll Sepolia Testnet(0x8274f)
await ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: '0x82750' }],
});
// 连接钱包(选择有余额的账户)
const [address] = await ethereum.request({ method: 'eth_requestAccounts' });