Skip to content

Instantly share code, notes, and snippets.

@yushiro
yushiro / kindleDown.js
Last active Nov 14, 2022
批量从亚马逊中国区下载kindle上购买的电子书
View kindleDown.js
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);
@yushiro
yushiro / SecureCallAttribute.cs
Created Jan 9, 2020 — forked from thehoneymad/SecureCallAttribute.cs
Custom Authorization Attribute on Asp.net web api 2.2
View SecureCallAttribute.cs
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 Mar 4, 2019
c#单件模式代码 #C#
View Singleton.cs
using System;
using System.Collections.Generic;
using System.Text;
namespace DesignPatterns
{
class Program
{
static void Main(string[] args)
{
@yushiro
yushiro / baidu.js
Last active Nov 16, 2017
针对百度云盘的分享, 自动保存到自己的云盘(解决非会员不能一次保存大于5000文件的限制)
View baidu.js
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 Jan 3, 2016
javascript常用代码
View javascript.md

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

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

在查看源码的页面, 执行

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

或者在普通tab页面, 执行

var result = JSON.parse($('body>pre').innerHTML);
@yushiro
yushiro / download.cs
Created Nov 25, 2013
ASP.NET中点击Link下载Excel文件
View download.cs
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 Oct 23, 2013
C#版的MD5实现
View md5.cs
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++)
View access.md

创建自增字段

ALTER TABLE tablename ADD COLUMN RowId integer identity Primary Key

判断字段名是否存在

            using (OleDbConnection conn = new OleDbConnection(_connStr))
            {
 conn.Open();
@yushiro
yushiro / csshack.md
Last active Dec 25, 2015
css hack tips
View csshack.md

IE7 inline-block CSS BUG

.sample {
    display: inline-block;
    zoom: 1;
    *display: inline;
}