Skip to content

Instantly share code, notes, and snippets.

View AymericG's full-sized avatar

Aymeric Gaurat-Apelli AymericG

View GitHub Profile
@AymericG
AymericG / better-herbie-3.js
Created August 17, 2016 12:01
Yet another one.
// 1. Set the species attributes
var species = new Species();
species.Name = "ant";
// Determine how your animal looks like
species.Skin = AnimalSkin.ant; // options: ant, beetle, inchworm, scorpion or spider
// How big can your creature grow?
// The bigger the more powerful it is, but the slower it is to reproduce.
species.MatureSize = 24; // between 24 and 48
@AymericG
AymericG / better-herbie.js
Last active August 17, 2016 11:56
Another herbivore
// 1. Set the species attributes
var species = new Species();
species.Name = "ant";
// Determine how your animal looks like
species.Skin = AnimalSkin.ant; // options: ant, beetle, inchworm, scorpion or spider
// How big can your creature grow?
// The bigger the more powerful it is, but the slower it is to reproduce.
species.MatureSize = 24; // between 24 and 48
@AymericG
AymericG / herbie.js
Created August 17, 2016 11:31
Sample herbivore code
// 1. Set the species attributes
var species = new Species();
species.Name = "ant";
// Determine how your animal looks like
species.Skin = AnimalSkin.ant; // options: ant, beetle, inchworm, scorpion or spider
// How big can your creature grow?
// The bigger the more powerful it is, but the slower it is to reproduce.
species.MatureSize = 24; // between 24 and 48
@AymericG
AymericG / CorsMessageHandler.cs
Created December 31, 2015 14:43
Issue with PATCH and CORS
public class CorsMessageHandler : DelegatingHandler
{
const string Origin = "Origin";
const string AccessControlRequestMethod = "Access-Control-Request-Method";
const string AccessControlRequestHeaders = "Access-Control-Request-Headers";
const string AccessControlAllowOrigin = "Access-Control-Allow-Origin";
const string AccessControlAllowMethods = "Access-Control-Allow-Methods";
const string AccessControlAllowHeaders = "Access-Control-Allow-Headers";
const string AccessControlAllowCredentials = "Access-Control-Allow-Credentials";
@AymericG
AymericG / gist:5410475
Created April 18, 2013 05:58
server.conf
port 1194
proto udp
# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
dev tun
ca /etc/openvpn/server/ca.crt
cert /etc/openvpn/server/server.crt
key /etc/openvpn/server/server.key # This file should be kept secret
@AymericG
AymericG / SecretController.cs
Created May 2, 2012 09:31
Processing incoming emails from SendGrid.
[HttpPost]
[ValidateInput(false)]
public ActionResult ProcessIncomingEmail(IncomingEmail email)
{
var serializer = new JavaScriptSerializer();
serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
email.envelope = serializer.Deserialize(HttpContext.Request.Form["envelope"], typeof(object));
// Parse incoming to: email address
// Do something
@AymericG
AymericG / AccountController.cs
Created April 28, 2012 04:05
How to implement unsubscription.
public ActionResult Unsubscribed(string id)
{
_userService.UnsubscribeFromEmails(id);
return View();
}
@AymericG
AymericG / ActionService.cs
Created April 27, 2012 23:26
Migrating from LinqToSql to Code First Entity Framework
//before
var weeklyReview = Db.WeeklyReviews
.Include(x => x.WeeklyGoals)
.SingleOrDefault(x => x.WorkspaceId == workspace.WorkspaceId && x.WeekDate == weekStart.WeeklyReviewDay(workspace.StartOfWeek));
// after
var weeklyReviewDay = weekStart.WeeklyReviewDay(workspace.StartOfWeek);
var weeklyReview = Db.WeeklyReviews
.Include(x => x.WeeklyGoals)
@AymericG
AymericG / AccountController.cs
Created April 27, 2012 12:28
How to use MvcMailer
Mailer.Invitation(emailAddresses.ToArray(), LoggedInUser.Name, inviteMessage).Send();
public class Team
{
public List<Player> Players { get; set; }
public int TotalRuns
{
get
{
return Players.Sum(player => player.Runs);
}
}