Skip to content

Instantly share code, notes, and snippets.

View SpikeXy's full-sized avatar
🏠
Working from home

spike SpikeXy

🏠
Working from home
View GitHub Profile
@SpikeXy
SpikeXy / README.md
Created October 20, 2016 01:09 — forked from jm3/README.md
Cognitive Bias Codex
@SpikeXy
SpikeXy / getJson.js
Last active October 2, 2017 03:15
get post method #jquery
$.getJSON("/some/url", function (data) {
// Now use this data to update your view models,
// and Knockout will update your UI automatically
})
@SpikeXy
SpikeXy / AdUserAvatarJpegPhoto.cs
Last active October 2, 2017 03:14
重置AD域用户的密码 #csharp #ad
// 重置AD域用户的密码,设置AD用户头像和缩略图必须使用管理员权限才可以,普通用户的时候,系统会拒绝访问
public bool ModifyAdUserAvatarJpegPhoto(DirectoryEntry userEntry,byte[] imgData)
{
try
{
string sAMAccountName = String.Empty;
#region sAMAccountName
if (userEntry.Properties.Contains("sAMAccountName"))
{
@SpikeXy
SpikeXy / jquery.cookie
Last active October 2, 2017 03:14
jquery.cookie 插件的用法 #jquery
@SpikeXy
SpikeXy / ajax.demo.js
Last active October 2, 2017 03:14
ajax的例子 #js
//jsonp传输方式
$.ajax({
type: "get",
async: false,
url: "ajax.ashx",
dataType: "jsonp",
jsonp: "callbackparam", //传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(默认为:callback)
jsonpCallback: "success_jsonpCallback",//自定义的jsonp回调函数名称,默认为jQuery自动生成的随机函数名
success: function (json) { alert(json); alert(json[0].name); },
error: function () { alert('fail'); }
@SpikeXy
SpikeXy / ado.net.add.demo.cs
Last active October 2, 2017 03:14
ado.net示例 #csharp
//添加
string id = txt_id.Text.Trim();
string username = txt_username.Text.Trim();
string ps = txt_ps.Text.Trim();
string date = txt_date.Text.Trim();
string conn_string ="Data Source=localhost;Initial Catalog=SQLtest;Integrated Security=True";
SqlConnection connection =newSqlConnection(conn_string);
SqlCommand sqcommand =newSqlCommand("InsertInto", connection);
sqcommand.CommandType=CommandType.StoredProcedure;// 将命令变为存储过程的方式
SqlParameter sp_id =newSqlParameter("ID", id);
@SpikeXy
SpikeXy / AnonymousType.cs
Last active October 2, 2017 03:13
AnonymousType AnonymousFunction匿名类型 , 匿名方法 #csharp
//匿名类型匿名方法
namespace Anonymous_Type
{
delegate void Speak(string a);
class Program
{
static void Main(string[] args)
{
//匿名类型
var n = new {name = "school",age=25};
@SpikeXy
SpikeXy / dataTableToList.Demo.cs
Last active October 2, 2017 03:13
DataTable转换为List对象 #csharp
#region 将DataTable转换为List对象
/// <summary>
/// 利用反射将DataTable转换为List<T>对象
/// </summary>
/// <param name="dt">DataTable 对象</param>
/// <returns>List<T>集合</returns>
public static List<T> DataTableToList<T>(DataTable dt) where T : class,new() {
// 定义集合
List<T> ts = new List<T>();
//定义一个临时变量
@SpikeXy
SpikeXy / DateTime.Demo.cs
Last active October 2, 2017 03:13
DateTime示例 #csharp
DateTime.Now.ToString("ddHHmmssff")
DateTime.Now.ToString("yyyy-mm-dd")
DateTime.Now.ToString("D") //输出成"2016年11月16日"
@SpikeXy
SpikeXy / Dynamic.Demo.cs
Last active October 2, 2017 03:13
Dynamic例子 #csharp
dynamic dyn = 1;
int j = dyn;
//下面这句话会无法通过编译,typeof 运算符无法用在动态类型上
//如果你是typeof(dynamic)会报typeof运算符无法用在动态类型上的错误
//Console.WriteLine(typeof(dynamic));
Console.WriteLine(typeof(List<dynamic>));
//在大多数情况下, dynamic 类型与 object 类型的行为是一样的
//但是,不会用编译器对包含 dynamic 类型表达式的操作进行解析或类型检查
// 编译器将有关该操作信息打包在一起,并且该信息以后用于计算运行时操作