Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / sharedProperties.js
Last active August 2, 2017 01:48
angularjs service to share properties between functions
//share properties between functions
angular
.module('app', [])
.service('sharedProperties', function () {
var hashtable = {};
return {
setValue: function (key, value) {
hashtable[key] = value;
},
@martianyi
martianyi / loader.js
Last active March 21, 2017 02:21
simple loader
var flag = false;
var timer = null;
window.addEventListener('load', function () {
if (!flag) {
flag = true;
document.getElementById("load").style["display"] = "none";
clearTimeout(timer);
}
}, false);
timer = setTimeout(function () {
@martianyi
martianyi / head.html
Last active May 4, 2020 16:23
meta prevent wechat browser from caching. via https://www.v2ex.com/t/140680
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
@martianyi
martianyi / routeData.js
Last active March 21, 2017 02:22
angularjs service to update settings when route change
var routeData = angular.module('RouteData', []);
routeData.provider('RouteData', function () {
var settings = {};
var hookToRootScope = false;
this.applyConfig = function (newSettings) {
settings = newSettings;
};
@martianyi
martianyi / rangeFilter.js
Created May 7, 2015 04:20
range filter using with angular rangeslider
app.filter('rangeFilter', function () {
return function (items, sliderRanges) {
var filtered = [];
var expectedReturnMin = sliderRanges.expectedReturnMin;
var expectedReturnMax = sliderRanges.expectedReturnMax;
var durationMin = sliderRanges.durationMin;
var durationMax = sliderRanges.durationMax;
angular.forEach(items, function (item) {
@martianyi
martianyi / securityService.js
Last active March 21, 2017 02:23
angularjs security service
var securityService = angular.module('security.service', []);
//Security
securityService.factory('Security', [
'$http', '$location', '$cookieStore', 'API_SERVER', '$window', '$route', 'toaster',
function ($http, $location, $cookieStore, API_SERVER, $window, $route, toaster) {
var security = {};
//login
@martianyi
martianyi / securityInterceptor.js
Last active March 21, 2017 02:23
angularjs security interceptor
var securityInterceptor = angular.module('security.interceptor', []);
//securityInterceptor, add token to page_header
securityInterceptor.factory('securityInterceptor', ['$q', '$cookieStore', '$location', 'toaster',
function ($q, $cookieStore, $location, toaster) {
var token = $cookieStore.get('token');
return {
'request': function (config) {
config.headers = config.headers || {};
if (token) {