Skip to content

Instantly share code, notes, and snippets.

View dhlavaty's full-sized avatar

Dusan Hlavaty dhlavaty

View GitHub Profile
@dhlavaty
dhlavaty / RestApi.cs
Created January 2, 2013 09:54
Simplest method to do a REST API calls in c# with basic .NET classes (no external library needed). I use it when communicationg with Recurly.com REST services.
/*
Simplest method to do a REST API calls in c# with basic .NET classes.
I use it when communicationg with Recurly.com REST services.
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
@dhlavaty
dhlavaty / AbsoluteUrl.cs
Last active August 30, 2021 07:46
How to get an Absolute URLs in ASP.NET MVC without HttpContext and/or UrlHelper
public static class AbsoluteUrl
{
private static bool initializedAlready = false;
private static Object initlock = new Object();
// AbsoluteUrl without parameters
public static string MVC_Home_Index;
public static string MVC_MyArea_Settings_Index;
// AbsoluteUrl with parameters
@dhlavaty
dhlavaty / downloadCSV.cs
Last active June 10, 2023 14:08
Download CSV file from Google Spreadsheet (Google Drive) using minimum c# code
using System;
using System.Net;
namespace ConsoleApplication1
{
class Program
{
public class WebClientEx : WebClient
{
public WebClientEx(CookieContainer container)
@dhlavaty
dhlavaty / ZendeskCreateTicket.cs
Created August 26, 2013 12:30
Create new Zendesk.com ticket - simplest possible C# code
using System;
using System.IO;
using System.Net;
using System.Text;
namespace DHlavaty
{
public class Zendesk
{
/*
@dhlavaty
dhlavaty / CSVParser.cs
Created October 2, 2013 11:50
Simple CSV parser in C#
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
using System;
using System.Globalization;
using System.Text;
namespace TC
{
// Removes diacritics from a string
//
// Original version by Michael Kaplan:
// -> http://blogs.msdn.com/b/michkap/archive/2007/05/14/2629747.aspx
@dhlavaty
dhlavaty / toLiteral.js
Last active May 24, 2016 10:07
Very naive Atom script to convert string concatenation to EcmaScript 6 template literals - for fixing ESLint 'prefer-template' rules
function toLiteral() {
var t = atom.workspace.getActiveTextEditor().getSelectedText();
t = t.replace(/\' \+ /g, "${");
t = t.replace(/ \+ \'/g, "}");
if (t.indexOf("'") == 0) {
t = t.substring(1);
} else {
t = "${" + t;
@dhlavaty
dhlavaty / color-difference-calulation.scss
Created May 30, 2017 11:25
SASS color difference calculations
// Use https://www.sassmeister.com/ to try it out
$have: #dfe2e5;
$need: #e1e4e6;
//$need: #d8dbe1;
//$out: saturate(darken($have, 2.15), 2.7);
$out: desaturate(lighten($have, 0.58), 1.25);
@dhlavaty
dhlavaty / go-lang-factorization-tests-multithreaded.go
Last active October 23, 2017 13:22
Factorization test in golang
package main
import (
"fmt"
"math/big"
"sync"
)
func runInThread(wg *sync.WaitGroup, startFrom int64, numOfIterations int64) {
defer wg.Done()
@dhlavaty
dhlavaty / ramdisk-howto.md
Last active June 4, 2024 12:06
Create RAM disk in macOS High Sierra (10.13.3), macOS Monterey (12.6.5), macOS Sonoma (14.5)

Create RAM disk in macOS High Sierra (10.13.3), macOS Monterey (12.6.5) ARM, macOS Sonoma (14.5) ARM

Update 2023-04-24

Tested on macOS Monterey (12.6.5) with Apple M1 Pro chip (ARM architecture)

Update 2024-05-04

Tested on macOS Sonoma (14.5) with Apple M1 Pro chip (ARM architecture)