Skip to content

Instantly share code, notes, and snippets.

View cxfksword's full-sized avatar

cxfksword

  • China
  • 14:37 (UTC +08:00)
View GitHub Profile
@cxfksword
cxfksword / TextSelectionReader.cs
Created May 5, 2018 10:07
Class that can be used to retrieve the currently selected text (if any) from an active control in the active window. It does this by trying several methods internally (UIAutomation, API calls using SendMessage + WM_GETTEXT, Clipboard). Be sure to reference UIAutomationClient and UIAutomationTypes!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Automation;
using System.Windows.Forms;
//WARNING: The code below is NOT for the faint of heart. Exceptions are swallowed freely, sendkeys
#!/bin/bash
# How to install Graphite as a user on CentOS 5.5 (with neither internet access and root account)
# --------------------------------------------------------------------------------
# Tomasz Kalkosiński - refaktor.blogspot.com
#
# Graphite is a Scalable Realtime Graphing (http://graphite.wikidot.com/)
# This script is based on two excellent tutorials:
# http://community.webfaction.com/questions/10038/how-to-install-pycairo-in-python27-thanks
@cxfksword
cxfksword / RemoveMultipleSpaces.cs
Created March 28, 2012 17:35 — forked from Ninputer/RemoveMultipleSpaces.cs
模拟微面试之去空格
//请实现下面的函数,输入参数baseStr是一个(可以更改的)字符串,请将其中所有连续出现的多个空格都替换成一个空格,单一空格需保留。
//请直接使用baseStr的空间,如需开辟新的存储空间,不能超过o(N)(注意是小o,N是字符串的长度)。返回值是替换后的字符串的长度。
//样例代码为C#,但可以使用任何语言。如需使用任何库函数,必须同时给出库函数的实现。
class Program
{
public static int RemoveMultipleSpaces(char[] baseStr)
{
if (baseStr == null)
throw new ArgumentNullException("baseStr");
// Please write an sequence list implements the interface with the required
// time complexity described in the comments. The users can add the same
// element as many times as they want, but it doesn't support the null item.
// You can use any types in .NET BCL but cannot use any 3rd party libraries.
// PS: You don't need to consider the multi-threaded environment.
interface void IMyList<T> : IEnumerable<T>
{
// O(1)
// Add an item at the beginning of the list.
void AddFirst(T item);