Skip to content

Instantly share code, notes, and snippets.

View leojh's full-sized avatar

Leo Hernandez leojh

View GitHub Profile
@leojh
leojh / Bubble Sort
Last active December 30, 2016 20:56
const bubbleSort = arr => {
let didSwap = true
while(didSwap) {
didSwap = false
for(let i = 0; i < arr.length; i++) {
if (arr[i] > arr[i + 1]) {
const tmp = arr[i + 1]
arr[i + 1] = arr[i]
arr[i] = tmp;
didSwap = true
DO
$do$
DECLARE n data_patchdata%rowtype;
BEGIN
FOR n IN SELECT * from data_patchdata LOOP
insert into data_patchdata_content
(stateset_id, description, identifier, name, severity, status, type)
VALUES
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Crux.Core.Types
{
//Hexavigesimal number system A = 1 ... Z = 26, AA = 27 ...
public class Base26
{
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = DatabaseConfig.class, loader = AnnotationConfigContextLoader.class)
public class RegistrationStatusPersistenceTests
{
@PersistenceContext
private EntityManager entityManager;
@Autowired
private RegistrationStatusRepository registrationStatusRepository;
ObjectFactory.Initialize(x =>
{
x.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
scan.ConnectImplementationsToTypesClosing(typeof(AbstractValidator<>));
});
});
@leojh
leojh / gist:4009097
Created November 3, 2012 22:21
Strongly Typed Application Settings
//THE BAD
System.Console.WriteLine(ConfigurationManager.AppSettings["ConfigSettings.SampleSetting1"]);
System.Console.WriteLine(ConfigurationManager.AppSettings["ConfigSettings.SampleSetting2"]);
//THE BETTER
System.Console.WriteLine(settings.SampleSetting1);
System.Console.WriteLine(settings.SampleSetting2);
@leojh
leojh / ExceptionExtensions.cs
Created July 6, 2012 00:42
Global Error Handler For ASP.NET MVC 3
public static bool IsIt404NotFound(this Exception ex)
{
var httpException = ex as HttpException;
return httpException != null && httpException.GetHttpCode() == 404;
}
@leojh
leojh / Attributes
Created May 23, 2012 15:43
FubuMVC Sample HtmlConventions
using System;
namespace Is3.App.Web.IS3Portal.Core2.Web.Conventions.Html.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public sealed class DisplayNameAttribute : Attribute
{
public DisplayNameAttribute(string displayName)
{
DisplayName = displayName;