Perl Regex Group Name

(?P<NAME>pattern)
(?<NAME>pattern)

  $variable =~ /(?<count>\d+)/;
  print "Count is $+{count}";

 

ref: http://stackoverflow.com/a/288989

Stackdump – an offline browser for StackExchange/Stackverflow

Screenshot
o99c1z8j4z4ZA1GRjox-o

==========================================
System Requirements

– Python, version 2.5 or later but not version 3 – tested with v2.7.6,
– Java, version 6 – 1.6 or later,
– Stackdump,
– the StackExchange Data Dump – download the sites you wish to import – note that StackOverflow is split into 7 archive files; only Comments, Posts and Users are required but after extraction the files need to be renamed to Comments.xml, Posts.xml and Users.xml respectively
– 7-zip needed to extract the data dump files
==========================================
Commands
https://bitbucket.org/samuel.lai/stackdump/

**ใช้กับ powershell**
// administrative privileges
PS# Get-ExecutionPolicy
PS# Set-ExecutionPolicy
RemoteSigned

PS Desktop# cd .\stackdump\
PS Desktop\stackdump# .\List-StackdumpCommands.ps1
download_site_info
import_site
manage_sites
PS Desktop\stackdump# .\Run-StackdumpCommand.ps1
download_site_info
PS Desktop\stackdump# .\Start-Solr.ps1

PS Desktop\stackdump# .\Run-StackdumpCommand.ps1
import_site
PS Desktop\stackdump\python\src\stackdump\commands# python.exe .\import_site.py –base-url opensource.stackexchange.com –dump-date “August 2012” opensource.stackexchange.com
==========================================
Fix icon problem
download and resize to 48px
http://cdn.sstatic.net/Sites/__SUB-DOMAIN__/img/apple-touch-icon.png
example:
http://cdn.sstatic.net/Sites/security/img/apple-touch-icon.png
==========================================
Link : Database dump
https://archive.org/details/stackexchange

** the StackExchange Data Dump (download the sites you wish to import – note that StackOverflow is split into 7 archive files; only Comments, Posts and Users are required but after extraction the files need to be renamed to Comments.xml, Posts.xml and Users.xml respectively) **
==========================================
ปล. ผมโหลด dump ของเดือน xx/03/2016 (data อัพเดทล่าสุด 22/06/16) เฉลี่ยเวลา import เฉพาะเว็บ stackoverflow ประมาณ 40.35 ชั่วโมง
ทั้งนี้ความช้าเร็วขึ้นอยู่กับ spec pc/nb ของท่านนะครับ ;p
ปล.2 ต้นคลิป รอเรือออออออ ชัดมาก 555555+

Save

Save

Save

detect when a removable disk is inserted using C#

    	static ManagementEventWatcher w = null;
    	static void AddRemoveUSBHandler()
    	{
    		WqlEventQuery q;
    		ManagementScope scope = new ManagementScope("root\\CIMV2");
    		scope.Options.EnablePrivileges = true;
    		try {
    			q = new WqlEventQuery();
    			q.EventClassName = "__InstanceDeletionEvent";
    			q.WithinInterval = new TimeSpan(0, 0, 3);
    			q.Condition = "TargetInstance ISA 'Win32_USBControllerdevice'";
    			w = new ManagementEventWatcher(scope, q);
    			w.EventArrived += USBRemoved;
    			w.Start();
    		}
    		catch (Exception e) {
    			Console.WriteLine(e.Message);
    			if (w != null)
    			{
    				w.Stop();
    			}
    		}
    	}

    	static void AddInsertUSBHandler()
    	{
    		WqlEventQuery q;
    		ManagementScope scope = new ManagementScope("root\\CIMV2");
    		scope.Options.EnablePrivileges = true;
    		try {
    			q = new WqlEventQuery();
    			q.EventClassName = "__InstanceCreationEvent";
    			q.WithinInterval = new TimeSpan(0, 0, 3);
    			q.Condition = "TargetInstance ISA 'Win32_USBControllerdevice'";
    			w = new ManagementEventWatcher(scope, q);
    			w.EventArrived += USBInserted;
    			w.Start();
    		}
    		catch (Exception e) {
    			Console.WriteLine(e.Message);
    			if (w != null)
    			{
    				w.Stop();
    			}
    		}
    	}

    	static void USBInserted(object sender, EventArgs e)
    	{
    		Console.WriteLine("A USB device inserted");
    	}

    	static void USBRemoved(object sender, EventArgs e)
    	{
    		Console.WriteLine("A USB device removed");
    	}

How to use

    	Main()
    	{
    		AddInsertUSBHandler();
    		AddRemoveUSBHandler();
    		while (true) {}
    	}

http://stackoverflow.com/a/271251

Answer:WMI: Get USB device description on insertion

        ManagementScope sc =
            new ManagementScope(@"\\YOURCOMPUTERNAME\root\cimv2");

        ObjectQuery query =
            new ObjectQuery("Select * from Win32_USBHub");

        ManagementObjectSearcher searcher = new ManagementObjectSearcher(sc, query);
        ManagementObjectCollection result = searcher.Get();

        foreach (ManagementObject obj in result)
        {
            if (obj["Description"] != null) Console.WriteLine("Description:\t" + obj["Description"].ToString());
            if (obj["DeviceID"] != null) Console.WriteLine("DeviceID:\t" + obj["DeviceID"].ToString());
            if (obj["PNPDeviceID"] != null) Console.WriteLine("PNPDeviceID:\t" + obj["PNPDeviceID"].ToString());
        }

WMI Code creator : http://sdrv.ms/PZKlKu

http://stackoverflow.com/a/6643234
https://social.msdn.microsoft.com/Forums/vstudio/en-US/f3003f55-aecf-41da-b0a8-1b5e8bf99894/extracting-serial-number-vendor-id-and-product-id-from-usb-pendrive-using-c?forum=netfxbcl

Get different and common items in two arrays with LINQ [C#]

var list1 = new string[] {"1", "2", "3", "4", "5", "6"};
var list2 = new string[] {"2", "3", "4"};
var listCommon = list1.Intersect(list2);
foreach (string s in listCommon) Console.WriteLine(s);

Output:

2
3
4

 

http://stackoverflow.com/a/10648270

How to create a Winforms Combobox with Label and Value [C#]

    private void PopulateComboBox()
    {
        var dict = new Dictionary<int, string>();
        dict.Add(2324, "Toronto");
        dict.Add(64547, "Vancouver");
        dict.Add(42329, "Foobar");

        comboBox1.DataSource = new BindingSource(dict, null);
        comboBox1.DisplayMember = "Value";
        comboBox1.ValueMember = "Key";
    }

http://stackoverflow.com/a/2023457

Remove duplicates from array c#

int[] s = { 1, 2, 3, 3, 4};
int[] q = s.Distinct().ToArray();

http://stackoverflow.com/a/9685

search value (with regex) in array and push search value to multidimensional array in PHP

Example Data

Array
(
    [0] => [DATA_1_A]
    [1] => [DATA_1_B] [DATA_2_B]
    [2] => [DATA_1_C] [DATA_2_C] [DATA_3_C]
)

And push value to multidimensional array.

Array
(
    [0] => Array
        (
            [0] => DATA_1_A
        )
    [1] => Array
        (
            [0] => DATA_1_B
            [1] => DATA_2_B
        )
    [2] => Array
        (
            [0] => DATA_1_C
            [1] => DATA_2_C
            [2] => DATA_3_C
        )
)

$new = array_map(function($i) {
if(preg_match_all('/\[([^\]]+)\]/', $i, $m)) return $m[1];
return $i; }, $arr);

http://stackoverflow.com/a/37666969

Answer:Scripts to convert data-dump to other formats

https://github.com/testlnord/sedumpy/blob/master/makedb.py
http://meta.stackexchange.com/a/28231

ref: https://twitter.com/sornram9254/status/738783811073232896

Answer:How to print all information from an HTTP request to the screen, in PHP

echo file_get_contents( 'php://input' );

http://stackoverflow.com/a/3136304
ref: https://twitter.com/sornram9254/status/738058662141263872