Skip to content

Instantly share code, notes, and snippets.

@zmilojko
zmilojko / setup.nsi
Created July 25, 2012 06:48
NSIS package for a C# application - a package file I used in Zaws, with comments on how to use it for your own application
; 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 (http://nsis.sourceforge.net/Download) 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.
@zmilojko
zmilojko / ZGacInst.cs
Created July 25, 2012 07:24
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.
// 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
zmilojko / gist:3181545
Created July 26, 2012 11:20
video settings
#duplicate{dst="transcode{vfilter={rotate{angle=270}:croppadd{croptop=120,cropbottom=0,cropleft=740,cropright=610}},live-caching=80,network-caching=0,vcodec=VP80,vb=4000,height=1080,width=1920,fps=15,acodec=none}:standard{access=http,mux=webm,dst=0.0.0.0:8090/main.webm}",dst="transcode{vfilter={rotate{angle=270}:croppadd{croptop=120,cropbottom=0,cropleft=740,cropright=610}},live-caching=80,network-caching=0,vcodec=h264,venc=x264{ultrafast},vb=4000,height=1080,width=1920,fps=15,acodec=none}:standard{access=http,mux=ts,dst=0.0.0.0:8090/main.mp4}",dst="transcode{vfilter={rotate{angle=270}:croppadd{croptop=120,cropbottom=0,cropleft=740,cropright=610}},live-caching=80,network-caching=0,vcodec=theo,vb=4000,height=1080,width=1920,fps=15,acodec=none}:standard{access=http,mux=ogg,dst=0.0.0.0:8090/main.ogg}"}
@zmilojko
zmilojko / SpeedActivity.java
Created February 8, 2013 10:30
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.app.Activity;
import android.content.Context;
import android.view.Menu;
import android.widget.TextView;
@zmilojko
zmilojko / UDPer.cs
Last active December 15, 2021 14:59
C# sends and receives UDP broadcasts
using System;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Threading;
namespace UDPer
{
class UDPer
{
@zmilojko
zmilojko / gist:5756502
Last active May 11, 2020 03:09
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.
/*
* ----------------------------------------------------------------------------
* "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
zmilojko / gist:9343394
Last active May 11, 2020 03:05
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.
string Serialize(object o)
{
XmlWriterSettings Settings = new XmlWriterSettings()
{
Indent = true,
IndentChars = " ",
NewLineHandling = NewLineHandling.None,
NewLineChars = "\n",
};
var sb = new StringBuilder();
@zmilojko
zmilojko / gist:f208a6216a6fb40e08906234601b831a
Created January 20, 2021 07:51
Posti postcode fetch and parse
class PostcodesRequest
require 'open-uri'
require 'nokogiri'
def postcode_file_name
page = Nokogiri::HTML(open('http://www.posti.fi/webpcode/unzip/'))
href = page.css('p').css('a')
text = href.text
splits = text.split('webpcode/')
names = splits[1].split('.dat')