Skip to content

Instantly share code, notes, and snippets.

@aviatrix
aviatrix / densitycalc.cs
Created January 16, 2012 16:26
Calculating dansity of posts/items/events etc .. over 24 hr period
private static DateTime ConvertFromUnixTimestamp(double timestamp)
{
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return origin.AddSeconds(timestamp);
}
public Dictionary<int, int> CalculateDensity(List<int> timestamps)
{
// the Key represents the hour , and the value represents the number of timestamps sent during a given hour
var converted = new Dictionary<int, int>();
@aviatrix
aviatrix / chardensitycalc.cs
Created January 16, 2012 16:27
Calculating density of characters and printing them in hi-to-low manner
/*
sample input : aazzaaffggghhtzzz
sample output : zzzzzaaaagggffhht
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@aviatrix
aviatrix / ViewParser
Created March 6, 2013 16:44
This class removes Razor code blocks
public static class ViewParser
{
/// <summary>
/// This removes clode blocs in razor @{ //codegoes here }
/// </summary>
/// <param name="text">a view in a string format</param>
/// <returns>Parsed View</returns>
public static string RemoveCodeBlocks(string text)
{
<Query Kind="Statements">
<Reference>&lt;RuntimeDirectory&gt;\System.Dynamic.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Dynamic.Runtime.dll</Reference>
<Namespace>System</Namespace>
<Namespace>System.Collections</Namespace>
<Namespace>System.Collections.Generic</Namespace>
</Query>
var sourceDir = @"D:\Downloads\All Shows\The Big Bang Theory";
<Query Kind="Statements">
<Reference>&lt;RuntimeDirectory&gt;\System.Dynamic.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Dynamic.Runtime.dll</Reference>
<Namespace>System</Namespace>
<Namespace>System.Collections.Generic</Namespace>
</Query>
var sourceDir = @"d:\downloads\all shows\";
var directories = Directory.GetDirectories(sourceDir,"*",SearchOption.TopDirectoryOnly);
@aviatrix
aviatrix / README.md
Last active November 26, 2017 17:05 — forked from mrrooijen/README.md
Setting up XEN on a Hetzner Dedicated Server

Setting up XEN on a Hetzner Dedicated Server

Author: Michael van Rooijen (@mrrooijen)

DISCLAIMER: I am a programmer, not a sysadmin in my day-to-day life. I provide this guide simply as a self-reference, and as a way to contribute to the community of developers. The main motivation for writing this guide is because of the lack of properly written guides/tutorials. They were either out-dated, inaccurate, in a non-English language or simply too vague to understand (at least for me, as a programmer and not a sysadmin).

I hope this guide helps getting you up and running with your own collection of VPS's on your own Dedicated Server over at Hetzner.de.

Requirements:

USE AdventureWorks2012;
GO
-- Find the average fragmentation percentage of all indexes
-- in the HumanResources.Employee table.
SELECT a.index_id, name, avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (DB_ID(N'AdventureWorks2012'),
OBJECT_ID(N'HumanResources.Employee'), NULL, NULL, NULL) AS a
JOIN sys.indexes AS b
ON a.object_id = b.object_id AND a.index_id = b.index_id;
GO
@aviatrix
aviatrix / chrome_install_headless.sh
Last active February 21, 2020 15:29 — forked from phith0n/chrome_install_headless.sh
Install Chrome headless on Ubuntu
export CHROME_BIN=/usr/bin/google-chrome
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation libasound2 libgconf-2-4 libnspr4 libxss1 libnss3 xdg-utils libappindicator3-1 libatk-bridge2.0-0 libatspi2.0-0 libgtk-3-0 libx11-xcb1 libxtst6
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
@aviatrix
aviatrix / gist:268305494fdf31e6fc32710af7778ee9
Created February 18, 2021 10:46
Interesting galaxies on legacysurvey
https://viewer.legacysurvey.org/?ra=165.1234&dec=28.9911&layer=ls-dr9&zoom=16
https://viewer.legacysurvey.org/?ra=32.4129&dec=-6.9182&layer=ls-dr9&zoom=15
https://viewer.legacysurvey.org/?ra=160.5107&dec=13.7666&layer=ls-dr9&zoom=13
https://viewer.legacysurvey.org/?ra=21.1293&dec=1.7317&layer=ls-dr9&zoom=15
https://viewer.legacysurvey.org/?ra=60.9593&dec=-54.1051&layer=ls-dr9&zoom=13
https://viewer.legacysurvey.org/?ra=19.9627&dec=3.4147&layer=ls-dr9&zoom=14
https://viewer.legacysurvey.org/?ra=208.8708&dec=40.4650&layer=ls-dr9&zoom=13
https://viewer.legacysurvey.org/?ra=208.3400&dec=40.3278&layer=ls-dr9&zoom=13
https://viewer.legacysurvey.org/?ra=21.1262&dec=3.7915&layer=ls-dr9&zoom=14
https://viewer.legacysurvey.org/?ra=206.6086&dec=60.3203&layer=ls-dr9&zoom=13