Skip to content

Instantly share code, notes, and snippets.

View dhlavaty's full-sized avatar

Dusan Hlavaty dhlavaty

View GitHub Profile
@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;
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 / 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)
{
@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 / 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 / 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 / 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;