Skip to content

Instantly share code, notes, and snippets.

@AlexMAS
AlexMAS / CassandraSequenceGenerator.java
Last active March 25, 2025 06:13
How to create a unique integer sequence in Apache Cassandra by using the Lamport Timestamps.
package ru.mos.emias.simi.cdc.repositories;
import java.util.UUID;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import static com.datastax.oss.driver.api.querybuilder.QueryBuilder.*;
import static com.datastax.oss.driver.api.querybuilder.condition.Condition.column;
@AlexMAS
AlexMAS / ProcessAsyncHelper.cs
Last active September 30, 2024 04:25
The right way to run external process in .NET (async version)
using System;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
public static class ProcessAsyncHelper
{
public static async Task<ProcessResult> ExecuteShellCommand(string command, string arguments, int timeout)
{
var result = new ProcessResult();
@AlexMAS
AlexMAS / ProcessHelper.cs
Last active October 10, 2024 21:05
The right way to run external process in .NET
public static class ProcessHelper
{
public static ProcessResult ExecuteShellCommand(string command, string arguments, int timeout)
{
var result = new ProcessResult();
using (var process = new Process())
{
process.StartInfo.FileName = command;
process.StartInfo.Arguments = arguments;
@AlexMAS
AlexMAS / ContentDisposition.cs
Created March 12, 2016 12:51
Set Content-Disposition with encoded filename
public static void SetContentDispositionInline(this HttpResponse response, string fileName, string userAgent)
{
SetContentDisposition(response, "inline", fileName, userAgent);
}
public static void SetContentDispositionAttachment(this HttpResponse response, string fileName, string userAgent)
{
SetContentDisposition(response, "attachment", fileName, userAgent);
}