Skip to content

Instantly share code, notes, and snippets.

View RaccoonDev's full-sized avatar
🏠
Working from home

Dmytro Mykhailov RaccoonDev

🏠
Working from home
View GitHub Profile
@RaccoonDev
RaccoonDev / MyList.scala
Created February 26, 2020 15:08
Simple linked list with tail addition
package excercises
abstract class MyList {
def head(): Int
def tail(): MyList
def isEmpty: Boolean
def add(element: Int): MyList
def printElements: String
@RaccoonDev
RaccoonDev / TestStreamTest.java
Created January 31, 2020 20:18
Going through unit testing for streaming applications with Apache Beam.
package org.apache.beam.examples.streams;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
import org.apache.beam.sdk.coders.StringUtf8Coder;
import org.apache.beam.sdk.testing.PAssert;
import org.apache.beam.sdk.testing.TestPipeline;
@RaccoonDev
RaccoonDev / main.go
Created March 20, 2018 20:29
Blocking calls for changes in consul
package main
import (
"bufio"
"fmt"
"log"
"os"
"time"
consulapi "github.com/hashicorp/consul/api"
@RaccoonDev
RaccoonDev / index.html
Last active October 31, 2017 09:39
Websockets testing
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@RaccoonDev
RaccoonDev / download.scala
Last active August 1, 2017 15:53
Download files by list of URL in a text file
import scala.io.Source
import sys.process._
import java.net.URL
import java.io.File
Source.fromFile("name_of_file_that_contains_list_of_urls.txt")
.getLines
.zipWithIndex
.foreach { case(line, count) => new URL(line) #> new File(s"output_file_name_$count.txt") !! }
function EnsureAdminPrivileges([String]$mesageOnError)
{
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = new-object Security.Principal.WindowsPrincipal $identity
if (!($principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)))
{
Write-Error $mesageOnError
throw
}
}
@RaccoonDev
RaccoonDev / GenerateApiKey.ps1
Created December 17, 2015 09:40
Generate secure byte array and encode it with base64 string.
param(
[int]$SecretArrayLength = 64
)
$randomNumberGenerator = [System.Security.Cryptography.RandomNumberGenerator]::Create();
$ba = [Byte[]] (,0 * $SecretArrayLength);
$randomNumberGenerator.GetBytes($ba, 0, $SecretArrayLength);
return [System.Convert]::ToBase64String($ba);
@RaccoonDev
RaccoonDev / dev-setup.ps1
Last active November 19, 2015 16:21
Install choco and useful stuff on new dev machine.
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
choco install sourcetree -y
choco install google-chrome-x64 -y
choco install notepadplusplus -y
$msdeploy = "$env:ProgramFiles\IIS\Microsoft Web Deploy V3\msdeploy.exe"
##Get this values from publish profile
$publishUrl=""
$msdeploySite=""
$userName=""
$userPWD=""
$computerNameParams = ",computername=`"https://$publishUrl/msdeploy.axd?site=$msdeploySite`",userName='$userName',password='$userPWD',AuthType='Basic'"
<#
TODO:
1. Make the script to run itself with elevated permissions. Otherwise it can't open certificate store.
2. Take the certificate from some public place. Let's say blob.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$True)]
[ValidateScript({