Skip to content

Instantly share code, notes, and snippets.

@CipherLab
CipherLab / EasyTimer
Created July 11, 2014 15:12
Javascript style interval/timeout in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DailyCoding.EasyTimer
{
public static class EasyTimer
{
public static IDisposable SetInterval(Action method, int delayInMilliseconds)
@CipherLab
CipherLab / CsvToJson
Created July 11, 2014 13:49
Convert a csv file to a json obect! Neat!
public static string CsvToJson(string value, char delim, bool hasHeader)
{
// Get lines.
if (value == null) return null;
value = value.Replace("\r\n", "\r");
value = value.Replace("\r", "\r\n");
value = value.Replace(delim, ',');
string[] lines = value.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
if (lines.Length < 2) throw new InvalidDataException("Must have header line.");
@CipherLab
CipherLab / Serialize
Last active August 29, 2015 14:03
Serialize/deserialize objects
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.IO.IsolatedStorage;
using System.Data;
using System.ComponentModel;
@CipherLab
CipherLab / EventLogger
Created July 11, 2014 13:14
Event logger
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
public static class EventLogger
{
private static EventLog log;
@CipherLab
CipherLab / FtpClient
Created July 11, 2014 13:13
Ftp client helper
using System;
using System.IO;
using System.Net;
public class FTPClient
{
private string host = null;
private string user = null;
private string pass = null;
private FtpWebRequest ftpRequest = null;
private FtpWebResponse ftpResponse = null;
@CipherLab
CipherLab / SocketConnector
Created July 11, 2014 13:13
Socket connector class
using System;
using System.Threading;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Data.SqlClient;
using Timer = System.Windows.Forms.Timer;
using System.Diagnostics;
@CipherLab
CipherLab / SocketListener
Created July 11, 2014 13:12
Threaded socket listener
using System;
using System.Threading;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Data.SqlClient;
using Timer = System.Windows.Forms.Timer;
using System.Diagnostics;
@CipherLab
CipherLab / General
Created July 11, 2014 13:11
General useful functions
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
@CipherLab
CipherLab / Encryption
Created July 11, 2014 13:10
Simple encryption/decryption
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
@CipherLab
CipherLab / Emailer
Created July 11, 2014 13:09
Emailer Client
using System;
using System.Data;
using System.Configuration;
using System.Collections;
//using System.Linq;
using System.Net.Mail;
using System.Net.Mime;
using System.Text.RegularExpressions;
using System.Web;
using System.IO;