Skip to content

Instantly share code, notes, and snippets.

View AshV's full-sized avatar
🌴
Coding @ Maldives Beaches

Ashish Vishwakarma AshV

🌴
Coding @ Maldives Beaches
View GitHub Profile
@fekberg
fekberg / SOS_Morse.cs
Created December 12, 2013 02:16
Here's how you do SOS Morse Code in C#.
var sequence = Enumerable.Range(0, 3).ToList();
while(true) {
sequence.ForEach(e => Console.Beep(650, 100));
Thread.Sleep(200);
sequence.ForEach(e => Console.Beep(650, 400));
Thread.Sleep(200);
@Landish
Landish / git.md
Last active September 4, 2017 05:51
GIT Tips & Tricks

Change Remote URL

$ git remote set-url origin <remote_repo>

Discard Unstaged/Untracked Changes

$ git checkout -- .
$ git reset --hard
@LindaLawton
LindaLawton / GoogleDriveServiceAccountcsharp
Created July 22, 2015 07:22
accessing google drive with a service account and C#
string[] scopes = new string[] {DriveService.Scope.Drive}; // Full access
var keyFilePath = @"c:\file.p12" ; // Downloaded from https://console.developers.google.com
var serviceAccountEmail = "xx@developer.gserviceaccount.com"; // found https://console.developers.google.com
//loading the Key file
var certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable);
var credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) {
Scopes = scopes}.FromCertificate(certificate));
@anth-3
anth-3 / passThruProxy.cs
Last active April 24, 2019 11:18
Defines a simple pass-through proxy interface for C#.NET (IIS) Server applications and web sites.
<%@ WebHandler Language="C#" Class="PassThruProxy" Debug="true" %>
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Web;
/**
* <summary><c>PassThruProxy</c> is a simple pass-through proxy interface for C#.NET (IIS Servers).</summary>
SELECT DISTINCT
'InputParameter',
REPLACE(mreq.Name, '{Entity.PrimaryEntityName}', ''),
mrf.Name,
CASE
WHEN CHARINDEX(',', mrf.ClrParser) > 0 THEN SUBSTRING(mrf.ClrParser, 1, CHARINDEX(',', mrf.ClrParser) - 1)
ELSE mrf.ClrParser
END,
CASE
WHEN mrf.Optional is null THEN 1
@dynajoe
dynajoe / Program.cs
Created November 1, 2012 16:06
Example C# HTTP Server
using System;
using System.Net;
using System.Text;
using System.Threading;
namespace ExampleSimpleWebserver
{
class Program
{
static void Main (string[] args)
@gabrielgreen
gabrielgreen / gist:3013620
Created June 28, 2012 20:10
Quick way to display a grid of key/value pairs using LINQ to Objects and WinForms
if (EomAppCommon.Settings.DebugEomDatabase)
{
var form = new System.Windows.Forms.Form();
var grid = new System.Windows.Forms.DataGridView {
AutoGenerateColumns = true,
Dock = System.Windows.Forms.DockStyle.Fill,
DataSource =
(from c in new [] {
Tuple.Create("DADatabaseR1ConnectionString", this.DADatabaseR1ConnectionString),
Tuple.Create("StatsYear", this.StatsYear.ToString()),
@prasanthj
prasanthj / chrome-ext-tab-url.js
Created December 15, 2014 20:00
Chrome extension get tab url
chrome.tabs.query({'active': true, 'lastFocusedWindow': true, 'currentWindow': true}, function (tabs) {
var url = tabs[0].url;
console.log(url);
});
@aliostad
aliostad / gist:3202814
Created July 30, 2012 00:18
Serialisation and deserialisation of HTTP request and response messages in ASP.NET Web API
public interface IHttpMessageSerializer
{
void Serialize(HttpResponseMessage response, Stream stream);
void Serialize(HttpRequestMessage request, Stream stream);
HttpResponseMessage DeserializeToResponse(Stream stream);
HttpRequestMessage DeserializeToRequest(Stream stream);
}
public class MessageContentHttpMessageSerializer : IHttpMessageSerializer
@coolaj86
coolaj86 / github-pages-https-lets-encrypt.md
Last active November 16, 2021 22:36
Github Pages: Let's Encrypt!