Skip to content

Instantly share code, notes, and snippets.

@solobat
solobat / gasPrice.js
Created November 7, 2021 12:55 — forked from thrilok209/gasPrice.js
Fetch GasPrice from eth gas station
// in nodeJs
const axios = require('axios')
async function getCurrentGasPrices() {
let response = await axios.get('https://ethgasstation.info/json/ethgasAPI.json')
let prices = {
low: response.data.safeLow / 10,
medium: response.data.average / 10,
high: response.data.fast / 10
}
@solobat
solobat / round_percents.js
Created January 13, 2020 12:05 — forked from robcolburn/round_percents.js
Rounding of complementary percentages
/*!
* Given a set of numeric values, returns a set of integer percents
*
* Algorithm defined by Rahul Narain, translated to JavaScript.
* http://math.stackexchange.com/questions/183476/rounding-of-complementary-percentages#186225
*
* > round_percents([20.5, 79.5])
* [21, 79]
* > round_percents([24.8, 25.2, 0.5, 49.5])
* [25, 25, 1, 49]
@solobat
solobat / inquirer_repeat.js
Created November 13, 2018 06:39
repeat a prompt
const inquirer = require('inquirer');
const quos = [
{ type: 'input', name: 'name', message: '模块名字: ', default: 'demo' },
{ type: 'input', name: 'author', message: '您的姓名?', default: 'somebody' },
{ type: 'input', name: 'rd', message: '后端的姓名?', default: 'rd' },
{ type: 'confirm', name: 'moveon', message: '继续?' }
];
const ans = [];
https://press.one/p/address/v?s=9529a15a1f9a4c35de09d03cea24f2b1874f9e9089255250c8dc7b1ae590fb21f5f7e34d417b239c7c70fadd54bc5809a76d4505a8db8d0611285215ec99999e0&h=6f90b4653addb7460669fe723fa155aea4ab20c6374c522578b02381666d856a&a=4600e32b728e6be3df6b37e73267ebb02586b93b&f=P1&v=2
List of Chrome URLs
chrome://accessibility
chrome://appcache-internals
chrome://apps
chrome://blob-internals
chrome://bookmarks
chrome://cache
chrome://chrome
chrome://chrome-urls
@solobat
solobat / CapsLockCtrlEscape.ahk
Created October 26, 2017 03:52 — forked from sedm0784/CapsLockCtrlEscape.ahk
AutoHotkey script to map Caps Lock to Escape when it's pressed on its own, and Ctrl when used in combination with another key, à la Steve Losh. Adapted from the one that does something similar with the Ctrl Key on the Vim Tips Wiki (http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows?oldid=32281). (With some extra key combos added by @r…
g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false
*CapsLock::
if (g_ControlRepeatDetected)
{
return
}
@solobat
solobat / calibre-viewer.css
Created October 13, 2017 18:09
my calibre view styles
.calibre {
font-family: "SF Pro SC","SF Pro Display","SF Pro Icons","PingFang SC","Helvetica Neue","Helvetica","Arial",sans-serif;
text-shadow: none;
color: rgb(68, 68, 17);
font-size: 16px;
line-height: 25px;
margin-right: 0px;
text-align: left;
background: #ededed;
overflow: hidden;
@solobat
solobat / gist:95b1906e1e8fb989d5fd1057b29eafba
Created June 7, 2017 07:33 — forked from nobuti/gist:3756881
Easy jquery/zepto images preload
var images = ["path/to/image", "path/to/image", ... , "path/to/image"],
preloaded = images.length;
_.each(images, function(img) {
var image = $('<img />').attr('src', img);
image.on('load', function(){
preloaded--;
if (preloaded === 0){
console.log("All preloaded!");
}

代码按钮

<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count" data-size="small" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&amp;src=sdkpreparse">分享</a></div>

SDK 代码

@solobat
solobat / how-to-publish-package.md
Created June 30, 2016 02:36 — forked from abruzzi/how-to-publish-package.md
如何发布你的开源软件包(npm && gem)

NPM

  1. 创建npm账户,如果没有的话
  2. 定义package.json
  3. 本地开发测试
  4. npm pack 成本地宝测试
  5. npm publish .

命令npm pack可以将你的包打包成一个本地的tgz文件: