This c# code can connect sharepoint 2013 through restful by username and password

Thanks God, This c# code can connect sharepoint 2013 through restful by username and password

            HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create("http://win-344c6v6tjp4:88/_api/web/lists");

            endpointRequest.Method = "GET";
            endpointRequest.Accept = "application/json;odata=verbose";
            NetworkCredential cred = new System.Net.NetworkCredential("administrator", "this is my password");
            endpointRequest.Credentials = cred;
            HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse();
                WebResponse webResponse = endpointRequest.GetResponse();
                Stream webStream = webResponse.GetResponseStream();
                StreamReader responseReader = new StreamReader(webStream);
                string response = responseReader.ReadToEnd();
                JObject jobj = JObject.Parse(response);
                JArray jarr = (JArray)jobj["d"]["results"];
                foreach (JObject j in jarr)
                    Console.WriteLine(j["Title"] + " " + j["Body"]);

            catch (Exception e)
                Console.Out.WriteLine(e.Message); Console.ReadLine();

read count : 21

open default editor using netbeans api

		try {
			DataObject.find(FileUtil.toFileObject(new File("/Users/peter/workspace/PeterI/kernel/kernel.cpp"))).
		} catch (DataObjectNotFoundException ex) {

read count : 5

Powershell commands to upload/download a page to sharepoint 2013

Upload file:

Add-PSSnapIn "Microsoft.SharePoint.Powershell" 
# Set the variables 
$WebURL = “http://your_sharepoint/your_site” 
$DocLibName = "Pages"
$FilePath = “C:\a.aspx” 

# Get a variable that points to the folder 
$Web = Get-SPWeb $WebURL 

$List = $Web.GetFolder($DocLibName) 
$Files = $List.Files 

# Get just the name of the file from the whole path 
$FileName = $FilePath.Substring($FilePath.LastIndexOf("\")+1) 

# Load the file into a variable 
$File= Get-ChildItem $FilePath

# Upload it to SharePoint 
$Files.Add($DocLibName +"/" + $FileName,$File.OpenRead(),$false) 

Download file (Html special characters will be escaped):

Add-PSSnapin Microsoft.Sharepoint.Powershell

$WebURL = “http://kmp21dev.emsd.hksarg/kmp21dev” 
$web = Get-SPWeb $WebURL
$file = $web.GetFile('pages/homepage.aspx');
$bytes = $file.OpenBinary();

[System.IO.File]::WriteAllBytes('c:\users\spadmin\homepage.aspx', $bytes);

read count : 12

bochs breakpoint panel

extended netbeans, auto scan .c/.cc/.cpp files to find my bochs breakpoint marco, double click it will jump to there. Small tool, but save me a lot of time.pause_bochs-panel

read count : 14

Visual c++ example to read mbr

Install windows ddk and run it using admin permission, otherwise all bytes that read from mbr are 0xcd. It can be compile using visual c++ community exition.


#include "stdafx.h"
#include <cstdlib>
#include <windows.h>
#include <stdio.h>
#include <iostream>
#define FILE_SHARE_VALID_FLAGS (0x00000007) 
using namespace std;

short ReadSect
	const char *_dsk,    // disk to access
	char *&_buff,         // buffer where sector will be stored
	unsigned int _nsect   // sector number, starting with 0
	DWORD dwRead;
	wchar_t wdsk[100];
	size_t count;
	mbstowcs_s(&count, wdsk, sizeof(wdsk) / sizeof(wdsk[0]), _dsk, _TRUNCATE);
	if (hDisk == INVALID_HANDLE_VALUE) // this may happen if another program is already reading from disk
		return 1;
	SetFilePointer(hDisk, _nsect * 512, 0, FILE_BEGIN); // which sector to read

	ReadFile(hDisk, _buff, 512, &dwRead, 0);  // read sector
	return 0;

int main()
	char *dsk = "\\\\.\\PhysicalDrive0";
	int sector = 0;

	char *buff = new char[512];
	ReadSect(dsk, buff, sector);
	for (int x = 0; x < 512; x++) {
		printf("%x ", buff[x] & 0xff);
	if ((unsigned char)buff[510] == 0x55 && (unsigned char)buff[511] == 0xaa) {
		cout << "Disk is bootable!" << endl;

	return 0;

read count : 51

ffmpeg and ffplay for logitech webcam

These command works on windows and capture video using my logitech C920 webcam

Save viewcam to a file, becareful, windows media play may not able to play mp4 in a very clean windows. You can save it to avi.

ffmpeg -f dshow -i video="Logitech HD Pro Webcam C920" -c copy -y c:\users\peter\desktop\a.mp4

Save viewcam video and play it using ffplay, but it has few seconds delay

ffmpeg -f dshow -i video="Logitech HD Pro Webcam C920" -c copy -y c:\users\peter\desktop\a.mp4 -c:v copy -copytb 1 -an -f mjpeg udp:// | ffplay -f mjpeg p-rpbesize 32 udp://

Just play it by ffplay

ffmpeg -f dshow -i video="Logitech HD Pro Webcam C920" -c:v copy -copytb 1 -an -f mjpeg udp:// | ffplay -f mjpeg -probesize 32 udp://

read count : 40