How to get your IP in C#
There are two ways of getting your IP address in C#. One of them is by using the methods provided by the .NET framework and the other one by using a third party api.
What is the difference you might ask. The answer is fairly simple. There are two kinds of IP’s, internal IP’s and external IP’s. Sadly the .NET framework methods are not able to retrieve the external IP if the computer is not directly connected to the internet (no router or any other similar devices). Since this limitation exists there is only one option if you wish to get the external IP, and this is by using an online service.
I’ve constructed two methods below. One uses only the .NET framework methods but is not 100% accurate when trying to retrieve the external IP (requires the system to be directly connected to the internet). The second method uses an online service which should have fairly accurate results as long as the service is online and the computer is not behind a proxy.
Method 1
LINQ approach
1 2 3 4 5 6 | IPAddress localAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork); if (localAddress != null) { // do something with localAddress } |
Non-LINQ approach (for .NET framework versions before 3.5)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | IPAddress localAddress = null; foreach (IPAddress address in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (address.AddressFamily == AddressFamily.InterNetwork) { localAddress = address; break; } } if (localAddress != null) { // do something with localAddress } |
Method 2
1 2 3 4 5 6 7 8 9 10 | string ipAddress; using (WebClient wc = new WebClient()) { ipAddress = wc.DownloadString("http://icanhazip.com/"); } if (!string.IsNullOrEmpty(ipAddress)) { // do something with ipAddress } |
Bypass the Internet Explorer 10 requirement for Visual Studio 2013
Since the release of Visual Studio 2013 there have been some complains about one of the requirements in particular. Some versions of Visual Studio 2013 require Internet Explorer 10 to be installed or else the installation refuses to continue. For users that for some reasons they can’t, or simply don’t want to install Internet Explorer 10 on their system this might pose a big problem as they won’t be able to upgrade to the latest version of Visual Studio.
Luckily a user managed to find a workaround that can be used till Microsoft manages to find a way to remove this requirement. The workaround basically tricks the installer into thinking that you already have Internet Explorer 10 installed on your system, therefore allowing the installer to resume the installation.
Simply paste the following lines in a file and save it as .bat
. Then simply run it. After that the registry entries should be modified and you can continue the installation of Visual Studio 2013 as you normally would, this time without the Internet Explorer 10 requirement error.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | @ECHO OFF :IE10HACK REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer" /v Version /t REG_SZ /d "9.10.9200.16384" /f REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer" /v svcVersion /t REG_SZ /d "10.0.9200.16384" /f REG ADD "HKLM\SOFTWARE\Microsoft\Internet Explorer" /v Version /t REG_SZ /d "9.10.9200.16384" /f REG ADD "HKLM\SOFTWARE\Microsoft\Internet Explorer" /v svcVersion /t REG_SZ /d "10.0.9200.16384" /f GOTO EXIT :REVERTIE REG DELETE "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer" /v svcVersion REG DELETE "HKLM\SOFTWARE\Microsoft\Internet Explorer" /v svcVersion REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer" /v Version /t REG_SZ /d "8.0.7601.17514" /f REG ADD "HKLM\SOFTWARE\Microsoft\Internet Explorer" /v Version /t REG_SZ /d "8.0.7601.17514" /f GOTO EXIT :EXIT |
Note that since this alters the registry entries under HKEY_LOCAL_MACHINE you might need administration rights. So make sure that the .bat file you created is run as admin.
If you are having issues creating the .bat file I’ve attached it below for you.
Posted in Software Tips.
Tagged Internet Explorer, Internet Explorer 10, Microsoft, Visual Studio, Visual Studio 2013
Eazfuscator.NET free version
Eazfuscator.NET is one of the more popular obfuscators for .NET platform.
In June 29, 2012 the authors of the software decided to take the commercial route therefore not offering Eazfuscator.NET for free anymore. Since they decided to remove all the older versions from their website I decided to host the last free version they offered, which is Eazfuscator.Net 3.3.161 in case people can’t find a working link of the software anymore.
Keep in mind since this isn’t the latest release a few features are not present, such as the support for .NET Framework 4.5. If you wish to take advantage of the latest features then you will probably need to consider paying for the latest version or seeking for another (possibly free) obfuscator which offers the same features.
You can download Eazfuscator.Net 3.3.161 below.
Posted in Software Releases.
Tagged Eazfuscator.NET, obfuscation
How to watch streams on VLC
The majority of the popular stream services such as Twitch.tv, Justin.tv, GOMTV.net, etc, display their streams through the flash plugin. Because of that a lot of users might experience high CPU usage generated by the flash plugin as well as causing the stream to lag more because of the overhead that is created.
Thankfully there is a way to watch those streams directly in your VLC player with the use of Livestreamer.
Livestreamer currently supports the following services:
Name | Live | VOD | Notes |
---|---|---|---|
Aliez.tv | Yes | No | |
Azubu.tv | Yes | No | |
Cast3D.tv | Yes | Yes | |
Dailymotion | Yes | No | |
Euronews.com | Yes | No | |
Filmon.com | Yes | Yes | Only SD (HD requires authentication) |
Freedocast | Yes | No | |
GOMTV.net | Yes | Yes | Requires authentication. |
Hashd.tv | Yes | Yes | |
ILive | Yes | – | |
Livestation | Yes | – | |
Livestream | Yes | – | Both new and old site supported. |
Mips | Yes | – | |
Owncast.me | Yes | – | |
SVT Play | Yes | Yes | Videos may be geo-restricted to Sweden. |
Twitch/Justin.tv | Yes | Yes | Possible to authenticate for access to protected streams. |
UStream TV | Yes | Yes | |
Veetle.com | Yes | Yes | |
Weeb.tv | Yes | – | Requires rtmpdump with K-S-V patches. |
YouTube | Yes | Yes | |
YYCast | Yes | – |
The usage of Livestreamer is fairly easy. First you will need the link of the stream you would like to watch. Example: twitch.tv/<streamer id>
Then we need to find which, if any, streams are available, this is done by passing the stream link to Livestreamer as follows.
livestreamer.exe twitch.tv/<streamer id>
The above example will output the streams that are available to watch, assuming the stream link is valid and currently live. The output will be something similar to this if the above requirements are met:
1 2 3 | [cli][info] Found matching plugin twitch for URL http://www.twitch.tv/<streamer id> Available streams: mobile_high (best), mobile_low (worst), mobile_medium, mobile _mobile |
The part we are interested about are the “available streams”. Assuming available streams are found we can simply execute Livestreamer again with the link and the quality you want to watch as parameters.
Example:
livestreamer.exe twitch.tv/<streamer id> mobile_high
Alternative you can use the words in the parenthesis (best/worst etc).
And there you have it. Livestreamer should then launch VLC for you and start displaying the stream.
Note: Keep in mind that by viewing the streams through VLC you will not receive any ads the streamers will play. If you wish to support the streamers please consider running the stream on a separate browser in the background with the lowest quality while setting it on mute so it won’t bother you while still supporting your favorite streamers.
You can download the current latest version of Livestreamer below.
Posted in Software Tips.
Tagged livestreamer, VLC
How to disable WordPress automatic updates
As of WordPress 3.7 and upwards WordPress will now check and install updates automatically. This feature is on by default and only applies to minor versions and not the major ones.
If you wish to have full control over when to update your WordPress installation then it would be wise to disable the automatic installation of the new updates. This way you will still get notified when an update is available to download but it won’t be installed automatically.
There are two methods to disable WordPress automatic update feature.
Method 1 (Recommended)
Edit your wp-config.php file and add the following line.
1 | define('AUTOMATIC_UPDATER_DISABLED', true); |
Method 2 (Advanced)
Make use of the automatic_updater_disabled
and/or auto_update_core
WordPress filters.