Limit the number of months displayed by WordPress archives widget
Locate and edit your themes functions.php file. This can either be done in the admin panel by navigating to
Appearance -> Editor -> Click on functions.php file
or by directly editing the file which you can usually find under
wp-content/themes/<theme name>/functions.php
After opening the file simply add the following lines in it.
1 2 3 4 5 6 7 | function my_limit_archives( $args ) { $args['limit'] = 10; return $args; } add_filter( 'widget_archives_args', 'my_limit_archives' ); add_filter( 'widget_archives_dropdown_args', 'my_limit_archives' ); |
Replace the number 10 with the number of months that you want to display and you are done!
Posted in WordPress.
Tagged snippet, tutorial, WordPress, Wordpress archives
How to register a global hotkey for your application in C#
If you are looking for a way to set a global hotkey for your C# application that can be used without your form having focus I have created a decently commentated example for you below that you can use.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | using System; using System.Windows.Forms; namespace GlobalHotkeyExampleForm { public partial class ExampleForm : Form { [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk); [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern bool UnregisterHotKey(IntPtr hWnd, int id); enum KeyModifier { None = 0, Alt = 1, Control = 2, Shift = 4, WinKey = 8 } public ExampleForm() { InitializeComponent(); int id = 0; // The id of the hotkey. RegisterHotKey(this.Handle, id, (int)KeyModifier.Shift, Keys.A.GetHashCode()); // Register Shift + A as global hotkey. } protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == 0x0312) { /* Note that the three lines below are not needed if you only want to register one hotkey. * The below lines are useful in case you want to register multiple keys, which you can use a switch with the id as argument, or if you want to know which key/modifier was pressed for some particular reason. */ Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF); // The key of the hotkey that was pressed. KeyModifier modifier = (KeyModifier)((int)m.LParam & 0xFFFF); // The modifier of the hotkey that was pressed. int id = m.WParam.ToInt32(); // The id of the hotkey that was pressed. MessageBox.Show("Hotkey has been pressed!"); // do something } } private void ExampleForm_FormClosing(object sender, FormClosingEventArgs e) { UnregisterHotKey(this.Handle, 0); // Unregister hotkey with id 0 before closing the form. You might want to call this more than once with different id values if you are planning to register more than one hotkey. } } } |
Posted in C#.
Tagged C#, csharp, global hotkey, RegisterHotKey, snippet, UnregisterHotKey, winforms
How to know if a process has stopped or started using events in C#
There are numerous of ways to detect if a new process has started or stopped, sadly the majority of them are extremely inefficient as it requires you to keep looping through the active process constantly to see if a new one appeared in the array or if one is not there any more.
Luckily the windows Win32_ProcessStartTrace
and Win32_ProcessStopTrace
classes are here to help out.
The first thing we need to do is reference System.Management.dll in our project. Then we need to define the scope in your class which we will be using.
1 | using System.Management; |
After that we need to initialise the class which will contain the process start and process stopped events and add the handlers and their methods.
Add the two following variables in your Class.
1 2 | ManagementEventWatcher processStartEvent = new ManagementEventWatcher("SELECT * FROM Win32_ProcessStartTrace"); ManagementEventWatcher processStopEvent = new ManagementEventWatcher("SELECT * FROM Win32_ProcessStopTrace"); |
In your constructor the event handlers need to be added.
1 2 | processStartEvent.EventArrived += new EventArrivedEventHandler(processStartEvent_EventArrived); processStopEvent.EventArrived += new EventArrivedEventHandler(processStopEvent_EventArrived); |
and then their event methods that will be trigged when a process either starts or stops.
1 2 3 4 5 6 7 8 9 | void processStartEvent_EventArrived(object sender, EventArrivedEventArgs e) { // A new process has started } void processStopEvent_EventArrived(object sender, EventArrivedEventArgs e) { // A process has been stopped } |
And finally we need to start the events by using
1 2 | processStartEvent.Start(); processStopEvent.Start(); |
Posted in C#.
Tagged C#, csharp, process start event, process stop event, snippet, Win32_ProcessStartTrace, Win32_ProcessStopTrace, winforms
Unigine releases Heaven 4.0 benchmark
Unigine has released a new version of Heaven, a DirectX 11 graphics benchmark.
The new version offers a number of new features such as:
- Extreme hardware stability testing
- Accurate results due to 100% GPU-bound benchmarking
- Benchmarking presets for convenient comparison of results
- Support for DirectX 9, DirectX 11 and OpenGL 4.0
- Multi-Platform support for Windows, Linux and Mac OS X
- Comprehensive use of hardware tessellation, with adjustable settings
- Dynamic sky with volumetric clouds and tweakable day-night cycle
- Real-time global illumination and screen-space ambient occlusion
- Cinematic and interactive fly/walk-through camera modes
- Support for multi-monitor configurations
- Various stereo 3D modes
- GPU temperature and clock monitoring
- Command line automation support
- Highly customizable reports in CSV format
- Support for software rendering mode in DirectX 11 for reference purposes
- Support for English, Russian and Chinese languages
System Requirements
- ATI Radeon HD 4xxx and higher, NVIDIA GeForce 8xxx and higher, or Intel HD 3000 and higher
- Video memory: 512 Mb
- Disk space: 1 Gb
- Microsoft Windows XP / Vista / 7 / 8, Linux (proprietary video drivers required), or Mac OS X 10.8+ (Mountain Lion)
There are three versions currently available .
- Free version which can be downloaded from http://unigine.com/products/heaven/download/
- Advanced (9.59 GBP / 14.95 USD)
- Professional (317.68 GBP / 495.00 USD)
Posted in Software Releases.
Tagged benchmarks, Heaven, Heaven 4.0, Unigine
3DMark 11 is now available
Futuremark has released a new version of the known benchmark software 3DMark.
The new version consists of six new benchmark tests which make extensive use of DirectX 11 features including tessellation, compute shaders and multi-threading.
Available Benchmarks
- Deep Sea 1
- Deep Sea 2
- High Temple 1
- High Temple 2
- Physics test
- Combined test
Graphic test using lights with no tessellation.
Graphic test using tessellation, post processing, depth of field and other camera lens effects.
Graphic test using lights and tessellation.
Graphic test with high tessellation usage.
Multi-theaded CPU heavy benchmark with minimal impact on the GPU.
All around benchmark, that tests both the GPU and CPU using object collision, tessellation, volumetric lighting and post processing effects.
Minimum Requirements
- OS: Microsoft Windows Vista or Windows 7
- Processor: 1.8GHz dual-core Intel or AMD CPU
- Memory: 1 GB of system memory
- Graphics: DirectX 11 compatible graphics card
- Hard drive space: 1.5 GB
- Audio: Windows Vista / Windows 7 compatible sound card
There is a free edition available at http://www.3dmark.com/3dmark11/download
Posted in Software Releases.
Tagged 3DMark, 3DMark 11, benchmarks, Futuremark