Skip to content

Instantly share code, notes, and snippets.

View xavierpena's full-sized avatar

Xavier Peña xavierpena

  • hydrique.ch
  • Switzerland
View GitHub Profile
@cowlicks
cowlicks / getconsole.js
Created May 23, 2017 20:02
Get restore `console.log` on pages where it has been removed (like twitter) by pulling it out of an iframe.
function setConsole() {
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
console = iframe.contentWindow.console;
window.console = console;
}
@regisdiogo
regisdiogo / Startup.cs
Last active June 13, 2022 11:17
ASP.NET Core - Json serializer settings Enum as string and ignore null values
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddJsonOptions(options =>
{
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
});
}
@machupicchubeta
machupicchubeta / convert_snakecase_to_camelcase_in_c#
Created April 7, 2014 07:32
convert snake case to camel case in c#
"foo_bar".Split(new [] {"_"}, StringSplitOptions.RemoveEmptyEntries).Select(s => char.ToUpperInvariant(s[0]) + s.Substring(1, s.Length - 1)).Aggregate(string.Empty, (s1, s2) => s1 + s2);
@jogleasonjr
jogleasonjr / SlackClient.cs
Last active October 20, 2023 15:54
A simple C# class to post messages to a Slack channel. You must have the Incoming WebHooks Integration enabled. This class uses the Newtonsoft Json.NET serializer available via NuGet. Scroll down for an example test method and a LinqPad snippet. Enjoy!
using Newtonsoft.Json;
using System;
using System.Collections.Specialized;
using System.Net;
using System.Text;
//A simple C# class to post messages to a Slack channel
//Note: This class uses the Newtonsoft Json.NET serializer available via NuGet
public class SlackClient
{
@chilversc
chilversc / gist:5575617
Created May 14, 2013 12:47
Connection to MySql from .net over an SSH tunnel, using http://nuget.org/packages/SSH.NET/
void Test()
{
var ci = new ConnectionInfo ("remoteserver", "remoteuser", new PasswordAuthenticationMethod ("remoteuser", "password"));
var cs = new MySqlConnectionStringBuilder ();
cs.AllowBatch = true;
cs.Server = "127.0.0.1";
cs.Database = "database";
cs.UserID = "dbuser";
cs.Password = "dbpassword";
@blachniet
blachniet / ClassLogDefClip.cs
Last active November 26, 2019 11:39
Simple log4net configuration
private static readonly log4net.ILog _log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);