Skip to content

Instantly share code, notes, and snippets.

View gist:f208a6216a6fb40e08906234601b831a
class PostcodesRequest
require 'open-uri'
require 'nokogiri'
def postcode_file_name
page = Nokogiri::HTML(open(''))
href = page.css('p').css('a')
text = href.text
splits = text.split('webpcode/')
names = splits[1].split('.dat')
zmilojko / gist:9343394
Last active May 11, 2020
C# XML (de)serialization made simple. I am sick of C# approach to use 12 lines of code where one would suffice. These two functions will (de)serialize string <=> object and with nice format two.
View gist:9343394
string Serialize(object o)
XmlWriterSettings Settings = new XmlWriterSettings()
Indent = true,
IndentChars = " ",
NewLineHandling = NewLineHandling.None,
NewLineChars = "\n",
var sb = new StringBuilder();
zmilojko / gist:5756502
Last active May 11, 2020
Here is how you can make C# WebRequests asynchronously. The version on MSDN is overcomplicated and utterly sucks. This one is minimal and doesn't suck.
View gist:5756502
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Guoxun Yang and Zeljko Milojkovic wrote this file. As long as you retain this
* notice you can do whatever you want with this stuff. If we meet some day, and
* you think this stuff is worth it, you can buy us beer in return.
* ----------------------------------------------------------------------------
using System;
zmilojko / UDPer.cs
Last active Sep 11, 2021
C# sends and receives UDP broadcasts
View UDPer.cs
using System;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Threading;
namespace UDPer
class UDPer
zmilojko /
Created Feb 8, 2013
Minimalistic Android GPS app - shows speed on the screen - but mainly shows how to read GPS data in Android
package com.zwr.speed;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.content.Context;
import android.view.Menu;
import android.widget.TextView;
View gist:3181545
zmilojko / ZGacInst.cs
Created Jul 25, 2012
Source of the ZGacInst - my little utility that will add assemblies to and remove them from GAC. Replaces GacUtil, which MS for some reason keeps weirdly licensed.
View ZGacInst.cs
// GacUtil my own way.
// Since GacUtil is not distributed with .NET framework (after 1.1.), should yo uwant to install your assemblies to GAC,
// you are likely to need this code.
using System;
// Add reference: System.EnterpriseServices
namespace ZGacInst
zmilojko / setup.nsi
Created Jul 25, 2012
NSIS package for a C# application - a package file I used in Zaws, with comments on how to use it for your own application
View setup.nsi
; Full script for making an NSIS installation package for .NET programs,
; Allows installing and uninstalling programs on Windows environment, and unlike the package system
; integrated with Visual Studio, this one does not suck.
;To use this script:
; 1. Download NSIS ( and install
; 2. Save this script to your project and edit it to include files you want - and display text you want
; 3. Add something like the following into your post-build script (maybe only for Release configuration)
; "$(DevEnvDir)..\..\..\NSIS\makensis.exe" "$(ProjectDir)Setup\setup.nsi"
; 4. Build your project.