Skip to content

Instantly share code, notes, and snippets.

@yushiro
yushiro / kindleDown.js
Last active March 10, 2024 02:01
批量从亚马逊中国区下载kindle上购买的电子书
var curIndex = -1;
function callbackDown(){
if(curIndex >=0) $('input.hideItem_myx')[curIndex].click();
curIndex++;
$('input.hideItem_myx')[curIndex].click();
$('ul button.myx-button-text')[curIndex].click();
//触发下载popup
setTimeout(function(){$('.myx-popover-inner .transcludedContent_myx .contentDetails_myx #contentAction_download_myx').trigger('click');},1000);
setTimeout(function(){$('.dialog_myx .myx-button-primary').trigger('click');},2000);
// 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.
@yushiro
yushiro / gist:cefbfc77c3768b36eddf
Created October 20, 2014 23:36
Mac版MonoDevelop的中英文等宽字体
Mac版的MonoDevelop能显示中文, 前提是字体包含中文, 但是平时用惯的Lucida Console不带汉字, 导致IDE的文本区, 汉字都是挤在一起的乱码。 在网上找了一下, 汉字等宽字体, 终于找到一个, 用下来感觉还行, 就先这么凑合吧。
http://wenq.org/?FontGuide 中介绍的“兼顾中英文对齐的等宽开源字体:文泉驿等宽正黑”
@yushiro
yushiro / SecureCallAttribute.cs
Created January 9, 2020 08:44 — forked from thehoneymad/SecureCallAttribute.cs
Custom Authorization Attribute on Asp.net web api 2.2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http.Controllers;
using System.Web.Http;
@yushiro
yushiro / Singleton.cs
Last active March 4, 2019 09:15
c#单件模式代码 #C#
using System;
using System.Collections.Generic;
using System.Text;
namespace DesignPatterns
{
class Program
{
static void Main(string[] args)
{
@yushiro
yushiro / baidu.js
Last active November 16, 2017 08:07
针对百度云盘的分享, 自动保存到自己的云盘(解决非会员不能一次保存大于5000文件的限制)
var aa =$('.chk[node-type="chk"]');
var pos = 0;
var MaxPos = aa.length;//分享页面的一级文件夹数量
var timer;
function saveItem(){
$(aa[pos]).trigger('click');
window.setTimeout(function(){$('.btn.saveToDisk-btn').click()},1000);
timer = window.setInterval(function(){
if($('.b-panel.b-dialog.move-dialog').css('display') == "block"){
@yushiro
yushiro / javascript.md
Last active January 3, 2016 07:48
javascript常用代码

###取当前URL中的页面名称

 window.location.href.split('/').pop().split('#')[0];
@yushiro
yushiro / chrome.md
Last active January 3, 2016 02:39
不用chrome插件, 在chrome下调试json格式的数据

在查看源码的页面, 执行

JSON.parse($('.webkit-line-content').innerHTML);

或者在普通tab页面, 执行

var result = JSON.parse($('body>pre').innerHTML);
@yushiro
yushiro / download.cs
Created November 25, 2013 06:41
ASP.NET中点击Link下载Excel文件
string filename = ExportExcel.ExportSurvey(iSurveyId, MapPath("/"));
System.IO.FileInfo file = new System.IO.FileInfo(filename);
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
Response.AddHeader("Content-Disposition", "attachment; filename = " + Server.UrlEncode(file.Name));
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
Response.AddHeader("Content-Length", file.Length.ToString());
// 指定返回的是一个不能被客户端读取的流,必须被下载
@yushiro
yushiro / md5.cs
Created October 23, 2013 04:03
C#版的MD5实现
public string CalculateMD5Hash(string input)
{
// step 1, calculate MD5 hash from input
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
// step 2, convert byte array to hex string
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)