Skip to content

Instantly share code, notes, and snippets.

View lmatt-bit's full-sized avatar
🎱

lmatt lmatt-bit

🎱
View GitHub Profile
@lmatt-bit
lmatt-bit / compare_file.cpp
Created October 26, 2010 09:26
比较两个路径所指内容是否相同
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <windows.h>
#include <fstream>
#include <cstring>
#include <cassert>
using namespace std;
@lmatt-bit
lmatt-bit / BeautifulSoup.py
Created November 10, 2010 14:56
BeautifulSoup示例
from BeautifulSoup import BeautifulSoup
import re
doc = ['<html><head><title>Page title</title></head>',
'<body><p id="firstpara" align="center">This is paragraph <b>one</b>.',
'<p id="secondpara" align="blah">This is paragraph <b>two</b>.',
'</html>']
doc = ''.join(doc)
soup = BeautifulSoup(doc)
@lmatt-bit
lmatt-bit / courses_1469.cpp
Created November 23, 2010 14:15
poj 1469
#include <cstdio>
#include <cstring>
#define NUM 501
int grid[NUM][NUM];
int used[NUM];
int path[NUM];
bool dfs(int x, int n)
@lmatt-bit
lmatt-bit / gist:1898235
Created February 24, 2012 06:06
判断是否为管理员
using System.Security.Principal
public static bool IsAdministrator()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
@lmatt-bit
lmatt-bit / gist:1898840
Created February 24, 2012 07:52
run process as administrator
ProcessStartInfo psi = new ProcessStartInfo();
//psi.UseShellExecute = false; if uncomment this line, then you can not run as administrator
psi.Verb = "runas";
Process.Start(psi);
@lmatt-bit
lmatt-bit / gist:1994164
Created March 7, 2012 16:20
C# XPath search
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.IO;
namespace StudyCSharp
{
@lmatt-bit
lmatt-bit / gist:1994203
Created March 7, 2012 16:29
Peter Lawrey's unsigned java
/*
* Copyright (c) 2011. Peter Lawrey
*
* "THE BEER-WARE LICENSE" (Revision 128)
* As long as you retain this notice you can do whatever you want with this stuff.
* If we meet some day, and you think this stuff is worth it, you can buy me a beer in return
* There is no warranty.
*/
@lmatt-bit
lmatt-bit / gist:2004868
Created March 9, 2012 03:30
SQL to XML
XElement root = new XElement("Orders");
using (SqlConnection con = new SqlConnection("data source=LMATT-PC\\SQLEXPRESS;integrated security=SSPI"))
{
con.Open();
using(SqlCommand command = new SqlCommand("SELECT top 50 * from Spt_values", con))
{
SqlDataReader reader = command.ExecuteReader();
while(reader.Read())
{
@lmatt-bit
lmatt-bit / gist:2621066
Created May 6, 2012 08:24
google code jam template
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
@lmatt-bit
lmatt-bit / gist:2636116
Created May 8, 2012 15:12
杨辉三角求C(N, K)
for(int i = 0; i <= N; i++)
{
for(int j = 0; j < i + 1; j++)
{
if(j == 0 || i == j) d[i][j] = 1;
else d[i][j] = d[i - 1][j] + d [i - 1][j - 1];
}
}