Skip to content

Instantly share code, notes, and snippets.

@codeyu
codeyu / dnd.js
Created February 25, 2016 07:14 — forked from npow/dnd.js
PhantomJS drag and drop
var page = require('webpage').create();
page.open('http://jsbin.com/ifuma#noedit', function () {
setTimeout(function () {
page.sendEvent("mousedown", 10, 10);
page.sendEvent("mousemove", 200, 200);
page.sendEvent("mouseup", 200, 200);
page.render('ss.png');
phantom.exit();
}, 3000);
});
@codeyu
codeyu / LRU.cs
Created September 6, 2016 02:31
LRU cache
void Main()
{
dynamic model = new System.Dynamic.ExpandoObject();
model.IsTransferOut = null;
model.OwnerId = -1;
if(model.IsTransferOut == true)
{
Console.WriteLine(model.IsTransferOut);
}
var t1 = Convert.ToDateTime("2016-05-02");
@codeyu
codeyu / csharp_daemon_demo.cs
Created April 25, 2017 01:54
一个完整的linux daemon示例
using System;
using System.Threading;
using System.Timers;
using System.Runtime.InteropServices;
using System.IO;
using System.Text;
/********************************************
* 一个完整的linux daemon示例,作者宇内流云 *
@codeyu
codeyu / ServiceController.cs
Created May 22, 2017 16:05
C# code completion using Roslyn. Beta.
//server's code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using reExp.Utils;
<!DOCTYPE html>
<html>
<body>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
<html>
<head>
<title>3D动态玫瑰(js实现)</title>
<meta charset="utf-8" />
</head>
<body>
<canvas id="c"></canvas>
<script>
@codeyu
codeyu / gh-pages-deploy.md
Created August 14, 2017 00:31 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@codeyu
codeyu / k8s-pi.md
Created December 12, 2017 05:51 — forked from alexellis/k8s-pi.md
K8s on Raspbian

K8s on (vanilla) Raspbian Lite

Yes - you can create a Kubernetes cluster with Raspberry Pis with the default operating system Raspbian. Carry on using all the tools and packages you're used to with the officially-supported OS.

Pre-reqs:

  • You must use an RPi2 or 3 for Kubernetes
  • I'm assuming you're using wired ethernet (Wi-Fi also works)

Master node setup

@codeyu
codeyu / CryptoRandom.cs
Created December 24, 2017 14:31 — forked from prettycode/CryptoRandom.cs
Cryptographically-strong random number generator in C#.
// Cryptographically-strong random number generator
// Source: MSDN Magazine > 2007 > September > .NET Matters: Tales from the CryptoRandom
// Source URL: http://msdn.microsoft.com/en-us/magazine/cc163367.aspx
// Authors: Stephen Toub & Shawn Farkas
public class CryptoRandom : Random
{
private RNGCryptoServiceProvider cryptoProvider = new RNGCryptoServiceProvider();
private byte[] uint32Buffer = new byte[4];
/**
匹配身份证号码
**/
function isIdCardNo(num) {
if (num == null || num == "") {
alert("请输入身份证号码!");
return false;
}
//去除字符串收尾空格