Perl Regex Group Name
(?P<NAME>pattern)
(?<NAME>pattern)
$variable =~ /(?<count>\d+)/; print "Count is $+{count}";
ref: http://stackoverflow.com/a/288989
การเขียน Program , การสร้าง website ฯลฯ
(?P<NAME>pattern)
(?<NAME>pattern)
$variable =~ /(?<count>\d+)/; print "Count is $+{count}";
ref: http://stackoverflow.com/a/288989
==========================================
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+
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:How do I detect when a removable disk is inserted using C#? https://t.co/cZVNYSF9Ej
— ศรรามไงจะใครล่ะ❤️ (@sornram9254) June 3, 2016
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
Answer:WMI: Get USB device description on insertion https://t.co/3EjWHFmXiD
— ศรรามไงจะใครล่ะ❤️ (@sornram9254) June 3, 2016
Extracting S/N, vendor id and product id from USB pendrive using C#https://t.co/x14T5rEzNE
WMI Code creator: https://t.co/UG3oqpVu1W
— ศรรามไงจะใครล่ะ❤️ (@sornram9254) June 3, 2016
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
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
int[] s = { 1, 2, 3, 3, 4};
int[] q = s.Distinct().ToArray();
http://stackoverflow.com/a/9685
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
https://github.com/testlnord/sedumpy/blob/master/makedb.py
http://meta.stackexchange.com/a/28231
ref: https://twitter.com/sornram9254/status/738783811073232896
echo file_get_contents( 'php://input' );
http://stackoverflow.com/a/3136304
ref: https://twitter.com/sornram9254/status/738058662141263872