Skip to content

Instantly share code, notes, and snippets.

Avatar

Nikola Sivkov aviatrix

View GitHub Profile
@aviatrix
aviatrix / chrome_install_headless.sh
Last active Feb 21, 2020 — forked from phith0n/chrome_install_headless.sh
Install Chrome headless on Ubuntu
View chrome_install_headless.sh
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
View sql
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 / README.md
Last active Nov 26, 2017 — forked from mrrooijen/README.md
Setting up XEN on a Hetzner Dedicated Server
View README.md

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:

View TvShowsMover.linq
<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);
View DeleteOldDownloads.linq
<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";
@aviatrix
aviatrix / ViewParser
Created Mar 6, 2013
This class removes Razor code blocks
View ViewParser
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)
{
@aviatrix
aviatrix / chardensitycalc.cs
Created Jan 16, 2012
Calculating density of characters and printing them in hi-to-low manner
View chardensitycalc.cs
/*
sample input : aazzaaffggghhtzzz
sample output : zzzzzaaaagggffhht
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@aviatrix
aviatrix / densitycalc.cs
Created Jan 16, 2012
Calculating dansity of posts/items/events etc .. over 24 hr period
View densitycalc.cs
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>();
You can’t perform that action at this time.