Skip to content

Instantly share code, notes, and snippets.

View dejanstojanovic's full-sized avatar
🎧
Focusing

Dejan Stojanovic dejanstojanovic

🎧
Focusing
View GitHub Profile
var printMap = function(map) {
map.setOptions({
mapTypeControl: false,
zoomControl: false,
streetViewControl: false,
panControl: false
});
var popUpAndPrint = function() {
dataUrl = [];
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Web;
using System.IO;
using System.Drawing.Imaging;
@dejanstojanovic
dejanstojanovic / SelfHostWithAssembliesResolver.cs
Created October 6, 2015 07:33 — forked from HenrikFrystykNielsen/SelfHostWithAssembliesResolver.cs
ASP.NET Web API: Controlling assemblies loaded by providing own AssembliesResolver
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Dispatcher;
using System.Web.Http.SelfHost;
namespace SelfHost
{
@dejanstojanovic
dejanstojanovic / parse-IIS-Log.cmd
Last active June 2, 2023 22:07 — forked from GuyHarwood/parse-IIS-Log.cmd
parse raw IIS logs using MS Log Parser into csv file
logparser -i:W3C -o:csv "SELECT * INTO c:\temp\results.csv FROM c:\temp\myLogFile.log"
logparser.exe "SELECT * FROM u_ex17020200.log WHERE cs-uri-query LIKE '%updvmsisdn.aspx%'" -o:CSV -q:ON -stats:OFF >> C:\Log1\output.csv
logparser.exe "SELECT * FROM u_ex*.log WHERE cs-uri-stem LIKE '%updvmsisdn.aspx%' AND cs-uri-query LIKE '%countryId=31%'" -o:CSV -q:ON -stats:OFF >> C:\Users\Administrator\Desktop\temp\output.csv
logparser.exe "SELECT * FROM u_ex17022402.log WHERE cs-uri-stem LIKE '%updvmsisdn.aspx%' AND cs-uri-query LIKE '%countryId=31%'" -o:CSV -q:ON -stats:OFF >> C:\Users\Administrator\Desktop\temp\TEMP.csv
@dejanstojanovic
dejanstojanovic / Gzip.java
Created September 1, 2016 13:20
Java gzip compress/decompress string
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class Gzip {
@dejanstojanovic
dejanstojanovic / OpenSSL.md
Last active April 16, 2024 04:57
Common OpenSSL commands

Common openssl commands

Create CSR

openssl req -nodes -newkey rsa:2048 -nodes -keyout privateKey.key -out CertRequest.csr -subj "/CN=mydomain.com"

Generate self-sign certificate

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt
@dejanstojanovic
dejanstojanovic / Mvc.Razor.Helpers.Extensions.cs
Created April 27, 2017 05:39
Inline minification and caching in razor
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Yahoo.Yui.Compressor;
@dejanstojanovic
dejanstojanovic / LINQ-DistinctBy.cs
Created August 15, 2017 12:13
Distinct by a specific object property in LINQ
public static IEnumerable<TSource> DistinctBy<TSource, TKey> (this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
{
HashSet<TKey> seenKeys = new HashSet<TKey>();
foreach (TSource element in source)
{
if (seenKeys.Add(keySelector(element)))
{
yield return element;
}
}
@dejanstojanovic
dejanstojanovic / mbrola-pi-setup.sh
Last active October 12, 2017 17:21 — forked from sourceperl/say_cpu_temp.py
Text to speak software with espeak and mbrola for Raspberry Pi2 (under Raspbian/jessie)
# install espeak
sudo apt-get install espeak
# install mbrola
wget http://tcts.fpms.ac.be/synthesis/mbrola/bin/raspberri_pi/mbrola.tgz
tar xvzf mbrola.tgz
chmod 755 mbrola
sudo mv ./mbrola /usr/local/bin/
# install voices for mbrola
@dejanstojanovic
dejanstojanovic / CreateIISSite
Last active January 16, 2018 17:14 — forked from ifrahim/CreateIISSite
Create IIS Site using Powershell
#unzip -> https://stackoverflow.com/questions/27768303/how-to-unzip-a-file-in-powershell
#check -> http://geekswithblogs.net/QuandaryPhase/archive/2013/02/24/create-iis-app-pool-and-site-with-windows-powershell.aspx
#check -> https://docs.microsoft.com/en-us/iis/manage/powershell/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools
# The following code will create an IIS site and it associated Application Pool.
# Please note that you will be required to run PS with elevated permissions.
# Visit http://ifrahimblog.wordpress.com/2014/02/26/run-powershell-elevated-permissions-import-iis-module/