Skip to content

Instantly share code, notes, and snippets.

@martianyi
martianyi / visor-archivos-online.md
Last active September 22, 2015 09:19 — forked from izazueta/visor-archivos-online.md
Google Docs Viewer & Office Web Apps Viewer

Google Docs Viewer

Only files under 25 MB can be previewed with the Google Drive viewer.

Google Drive viewer helps you preview over 16 different file types, listed below:

  • Image files (.JPEG, .PNG, .GIF, .TIFF, .BMP)
  • Video files (WebM, .MPEG4, .3GPP, .MOV, .AVI, .MPEGPS, .WMV, .FLV)
  • Text files (.TXT)
  • Markup/Code (.CSS, .HTML, .PHP, .C, .CPP, .H, .HPP, .JS)
  • Microsoft Word (.DOC and .DOCX)
@martianyi
martianyi / ergodic.sh
Created August 2, 2017 01:45
update folder to qiniu using qshell
#!/usr/bin/env bash
function ergodic(){
for file in `ls $1`
do
if [ -d "$1/$file" ]
then
ergodic "$1/$file"
else
echo "Uploading $1/$file"
@martianyi
martianyi / README.md
Last active June 21, 2018 02:05
nginx conf with http2 support

certbot签发证书

  1. certbot升级到最新版(0.23以上),签发证书: https://certbot.eff.org/lets-encrypt/ubuntuxenial-nginx
  2. 检查/etc/letsencript/renewal文件夹下renewal配置
  3. 运行certbot renew --dry-run测试更新证书是否成功

openssl self signed certificate

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
@martianyi
martianyi / daemon.md
Last active April 16, 2018 02:29
Simple way to run and stop a daemon in Linux

start a daemon

nohup COMMAND >/dev/null 2>&1 &

stop a daemon

ps -ef | grep COMMAND or ps aux | grep COMMAND

kill pid

@martianyi
martianyi / vconsole.js
Last active September 10, 2020 18:57
bookmarklet to add vConsole in mobile browser
javascript: (function() {
if (document.getElementById('__vconsole')) return;
function callback() {
var vConsole = new VConsole();
}
var s = document.createElement("script");
s.src = "https://res.wx.qq.com/mmbizwap/zh_CN/htmledition/js/vconsole/3.0.0/vconsole.min.js";
if (s.addEventListener) {
s.addEventListener("load", callback, false)
} else if (s.readyState) {
@martianyi
martianyi / view-source-with-line-numbers.js
Last active September 10, 2020 18:54
bookmarklet to view source with syntax highlighting using highlight.js
javascript: function getSelSource() {
x = document.createElement('div');
x.appendChild(window.getSelection().getRangeAt(0).cloneContents());
return x.innerHTML;
}
function makePre(text) {
p = nd.createElement('pre');
c = nd.createElement('code');
c.setAttribute('class', 'language-html');
@martianyi
martianyi / search-text.js
Created April 21, 2018 08:27
bookmarklet to search text in page
javascript: (function() {
var count = 0,
text;
text = prompt("Search phrase:", "");
if (text == null || text.length == 0) return;
if (!window.__obody) window.__obody = document.body.cloneNode(true);
function searchWithinNode(node, te, len) {
var pos, skip, spannode, middlebit, endbit, middleclone;
skip = 0;
@martianyi
martianyi / via-hypothesis.js
Created April 21, 2018 12:42
bookmarklet to open link in via.hypothes.is
javascript:(function () {location = 'https://via.hypothes.is/' + location.href;})()
@martianyi
martianyi / browser-detect.js
Last active May 16, 2018 04:06
feature detect desktop browser
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
var isChrome = !!window.chrome && !!window.chrome.webstore;
var isFirefox = typeof InstallTrigger !== 'undefined';
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
@martianyi
martianyi / rawgit.js
Last active April 25, 2018 04:51
bookmarklet to view file in rawgit.com
javascript: (function() {
let devDomain = 'rawgit.com';
const GITHUB_API_URL = 'https://api.github.com';
const REGEX_GIST_URL = /^https?:\/\/gist\.github\.com\/.+?\/([0-9a-f]+)(?:\/([0-9a-f]+))?/i;
const REGEX_RAW_GIST_URL = /^https?:\/\/gist\.githubusercontent\.com\/(.+?\/[0-9a-f]+\/raw\/(?:[0-9a-f]+\/)?.+\..+)$/i;
const REGEX_RAW_REPO_URL = /^https?:\/\/raw\.github(?:usercontent)?\.com\/(.+?)\/(.+?)\/(.+?)\/(.+)/i;
const REGEX_REPO_URL = /^https?:\/\/github\.com\/(.+?)\/(.+?)\/(?!releases\/)(?:(?:blob|raw)\/)?(.+?)\/(.+)/i;
formatUrl();
function formatRawGistUrl(url) {