You can find results here:
result1
result2
You are a software engineer... you can do anything... it is just a matter of time ;)
You are a software engineer... you can do anything... it is just a matter of time ;)
using System.Diagnostics;
CounterCreationDataCollection collection = new CounterCreationDataCollection();
CounterCreationData counter = new CounterCreationData(); counter.CounterName = "CountsPerSecond"; counter.CounterHelp = "CountsPerSecond"; counter.CounterType = PerformanceCounterType.RateOfCountsPerSecond32); collection.Add(counter);
if (!PerformanceCounterCategory.Exists("TestCategory"))
{
PerformanceCounterCategory.Create("TestCategory", "This is test category", PerformanceCounterCategoryType.SingleInstance, collection);
}
using System.Diagnostics;
namespace PerformaceCountersTest
{
class Program
{
static void Main(string[] args)
{
CounterCreationDataCollection collection = new CounterCreationDataCollection();
CounterCreationData counter = new CounterCreationData();
counter.CounterName = "CountsPerSecond";
counter.CounterHelp = "CountsPerSecond";
counter.CounterType = PerformanceCounterType.RateOfCountsPerSecond32);
collection.Add(counter);
if (!PerformanceCounterCategory.Exists("TestCategory"))
{
PerformanceCounterCategory.Create("TestCategory", "This is test category", PerformanceCounterCategoryType.SingleInstance, collection);
}
}
}
}PerformanceCounter countsPerSec = new PerformanceCounter("TestCategory", "CountsPerSecond", false);
countsPerSec.Increment();
using System.Diagnostics;
namespace PerformaceCountersTest
{
class Program
{
static void Main(string[] args)
{
PerformanceCounter countsPerSec = new PerformanceCounter("TestCategory", "CountsPerSecond", false);
for (int i = 0; i < 100; i++)
{
countsPerSec.Increment();
int sleep = 1000 - i * 10;
Console.WriteLine(sleep);
System.Threading.Thread.Sleep(sleep);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace PerformaceCountersTest
{
class PerformanceCounterCreator
{
CounterCreationDataCollection collection = new CounterCreationDataCollection();
public PerformanceCounterCreator()
{
}
public void addPerformaceCounter(String name, String description, PerformanceCounterType type)
{
CounterCreationData counter = new CounterCreationData();
counter.CounterName = name;
counter.CounterHelp = description;
counter.CounterType = type;
collection.Add(counter);
}
public void createCategory(String categoryName,String categoryHelp, bool force)
{
if (PerformanceCounterCategory.Exists(categoryName))
{
if (force)
{
PerformanceCounterCategory.Delete(categoryName);
PerformanceCounterCategory.Create(categoryName, categoryHelp, PerformanceCounterCategoryType.SingleInstance, collection);
}
}
else
PerformanceCounterCategory.Create(categoryName, categoryHelp, PerformanceCounterCategoryType.SingleInstance, collection);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace PerformaceCountersTest
{
class Program
{
static void Main(string[] args)
{
PerformanceCounterCreator creator = new PerformanceCounterCreator();
creator.addPerformaceCounter("CountsPerSecond", "CountsPerSecond", PerformanceCounterType.RateOfCountsPerSecond32);
creator.createCategory("TestCategory","This is test category", true);
//Create counter instance.
PerformanceCounter countsPerSec = new PerformanceCounter("TestCategory", "CountsPerSecond", false);
for (int i = 0; i < 100; i++)
{
countsPerSec.Increment();
int sleep = 1000 - i * 10;
Console.WriteLine(sleep);
System.Threading.Thread.Sleep(sleep);
}
}
}
}
4. References: lsusbwe should find our device
Bus 003 Device 020: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
/dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0
ln -s /dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0 ~/.wine/dosdevices/com1
lsusbpowinniśmy znaleźć takie urządzenie:
Bus 003 Device 020: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
/dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0Podepnijmy więc USB pod COM1 w Wine tworząc link:
ln -s /dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0 ~/.wine/dosdevices/com1
gem install exifr
require 'rubygems'
require 'exifr'
inputDir = ARGV[0]
prefix = ARGV[1].nil? ? "IMG" : ARGV[1]
if (ARGV.length >= 1)
Dir.glob("#{inputDir}/*.jpg",File::FNM_CASEFOLD).each() {|file|
timeTaken = EXIFR::JPEG.new(file).date_time
if (timeTaken.nil? & !EXIFR::JPEG.new(file).exif.nil?)
timeTaken = EXIFR::JPEG.new(file).exif.date_time_original
end
if (timeTaken.nil?)
timeTaken = File.mtime(file)
end
if (!timeTaken.nil?)
filename = "#{inputDir}/#{prefix}_#{timeTaken.strftime('%Y%m%d_%H%M%S')}.JPG"
puts "RENAME: #{file} -> #{filename}"
if(!File.exist?(filename))
File.rename(file,filename)
else
puts "ERROR: FILE #{filename} ALREADY_EXISTS!!!!"
end
else
puts "ERROR: Can't get time for #{file}"
end
}
else
puts "JPG_RENAME.rb #IMAGES_FOLDER [FILE_NAME_PREFIX]"
end
Latest version gan be found here https://bitbucket.org/chesti/jpgrename
mCI = new CultureInfo(language);
Thread.CurrentThread.CurrentCulture = mCI;
Thread.CurrentThread.CurrentUICulture = mCI;
CultureInfo[] a = CultureInfo.GetCultures(CultureTypes.AllCultures);
ComponentResourceManager resources = new ComponentResourceManager(inputForm.GetType());
using System.Globalization;
using System.Threading;
using System.Windows.Forms;
using System.ComponentModel;
public void ApplyLanguageToForm(Form inputForm, string language)
{
CultureInfo mCI = new CultureInfo(language);
Thread.CurrentThread.CurrentCulture = mCI;
Thread.CurrentThread.CurrentUICulture = mCI;
ComponentResourceManager resources = new ComponentResourceManager(inputForm.GetType());
foreach (Control c in inputForm.Controls)
{
resources.ApplyResources(c, c.Name, mCI);
}
}
using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using System.Threading;
using System.Windows.Forms;
namespace Lang
{
public class LanguageChange
{
private CultureInfo mCI = null;
public void ChangeLanguage(string language)
{
mCI = new CultureInfo(language);
Thread.CurrentThread.CurrentCulture = mCI;
Thread.CurrentThread.CurrentUICulture = mCI;
}
public void ApplyLanguageToForm(Form inputForm)
{
Form mainForm = inputForm;
while (mainForm.Owner != null)
{
mainForm = mainForm.Owner;
}
ApplyLanguage(mainForm, null);
}
private void ApplyLanguage(object value, ComponentResourceManager resources)
{
if (value is Form)
{
resources = new ComponentResourceManager(value.GetType());
resources.ApplyResources(value, "$this");
}
Type type = value.GetType();
foreach (PropertyInfo info in type.GetProperties())
{
switch (info.Name)
{
case "Items":
case "DropDownItems":
case "Controls":
case "OwnedForms":
if (info.PropertyType.GetInterface("IEnumerable") != null)
{
IEnumerable collection = (IEnumerable)info.GetValue(value, null);
if (collection != null)
{
foreach (object o in collection)
{
PropertyInfo objNameProp = o.GetType().GetProperty("Name");
ApplyResourceOnType(resources, o, objNameProp);
}
}
}
break;
case "ContextMenuStrip":
object obj = (object)info.GetValue(value, null);
if (obj != null)
{
ApplyLanguage(obj, resources);
resources.ApplyResources(obj, info.Name, mCI);
}
break;
default:
break;
}
}
}
private void ApplyResourceOnType(ComponentResourceManager resources, object o, PropertyInfo objNameProp)
{
switch (o.GetType().Name)
{
case "ComboBox":
for (int i = 0; i < ((ComboBox)o).Items.Count; i++)
{
((ComboBox)o).Items[i] = resources.GetString(GetItemName(o, objNameProp, i), mCI);
}
break;
case "ListBox":
for (int i = 0; i < ((ListBox)o).Items.Count; i++)
{
((ListBox)o).Items[i] = resources.GetString(GetItemName(o, objNameProp, i), mCI);
}
break;
// Other classes with string items
default:
if (objNameProp != null)
{
string name = objNameProp.GetValue(o, null).ToString();
ApplyLanguage(o, resources);
resources.ApplyResources(o, name, mCI);
}
break;
}
}
private string GetItemName(object o, PropertyInfo objNameProp, int i)
{
string name = String.Format("{0}.{1}",
objNameProp.GetValue(o, null).ToString(),
"Items");
if (i != 0) name = String.Format("{0}{1}", name, i);
return name;
}
}
}