Skip to content

Instantly share code, notes, and snippets.

@mikeobrien
mikeobrien / bundle.bash
Last active September 25, 2015 21:34
Package Scoped Bundle?
Error: ENOENT, open '/Volumes/Data/.../src/InternalWeb/app/aurelia-framework.js'
at Error (native)
public static class StringExtensions
{
public static string StripHtml(this string value)
{
return Regex.Replace(value, @"<[^>]+>|&nbsp;", "").Trim();
}
}
<button id="favicon-change" class="btn btn-default">Change Header</button>
<button id="notification" class="btn btn-default">Notification</button>
@mikeobrien
mikeobrien / dashboard_show.html.haml
Last active August 29, 2015 14:22
Getting rid of the obnoxious GitLab activity sections (7.10.4 omnibus)
-# /opt/gitlab/embedded/service/gitlab-rails/app/views/dashboard/show.html.haml
- if @projects.any?
= render 'sidebar'
= link_to '#aside', class: 'show-aside' do
%i.fa.fa-angle-left
- else
= render "zero_authorized_projects"
public static class EmailAddressValidator
{
public const string EmailAddressRegex = "^[^@]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
private static readonly Regex Validator = new Regex(EmailAddressRegex);
public static bool IsValid(string email)
{
return email != null && !email.Contains("\n") && Validator.Match(email).Success;
}
}
@mikeobrien
mikeobrien / update.sql
Created January 7, 2015 04:19
Converting CIDR block to IPv4 address range
UPDATE GeoLite2CityBlocks
SET network_start = (CAST(LEFT(Network, CHARINDEX('.', Network) - 1) AS bigint) * 16777216) |
(CAST(SUBSTRING(Network, CHARINDEX('.', Network) + 1, CHARINDEX('.', Network, CHARINDEX('.', Network) + 1) -
CHARINDEX('.', Network) - 1) AS bigint) * 65536) |
(CAST(SUBSTRING(Network, CHARINDEX('.', Network, CHARINDEX('.', Network) + 1) + 1,
CHARINDEX('.', Network, CHARINDEX('.', Network, CHARINDEX('.', Network) + 1) + 1) -
CHARINDEX('.', Network, CHARINDEX('.', Network) + 1) - 1) AS bigint) * 256) |
CAST(SUBSTRING(Network,CHARINDEX('.', Network, CHARINDEX('.', Network, CHARINDEX('.', Network) + 1) + 1) + 1,
CHARINDEX('/', Network) - CHARINDEX('.', Network, CHARINDEX('.', Network,
CHARINDEX('.', Network) + 1) + 1) - 1) AS bigint)
@mikeobrien
mikeobrien / gulpfile.js
Last active August 29, 2015 14:11
Watching tests with gulp
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
mocha = require('gulp-mocha'),
process = require('child_process');
gulp.task('default', ['test', 'lint']);
gulp.task('lint', function() {
return gulp.src(['**/*.js', '!node_modules/**/*'])
.pipe(jshint({ node: true }))
@mikeobrien
mikeobrien / Data.cs
Created August 7, 2014 19:57
Model of request/response data
{
public string Name { get; set; }
public string Comments { get; set; }
public string TypeName { get; set; }
public string DefaultValue { get; set; }
public bool IsOpening { get; set; }
public bool IsClosing { get; set; }
public bool IsClosed { get; set; }
public bool IsMember { get; set; }
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('<html><body>oh hai</body></html>');
}).listen(3091);
@mikeobrien
mikeobrien / gist:6691272
Last active December 23, 2015 20:39
Company name missing so it shows up in the browser tab as " - Home".
<title> - Home</title>
<meta property="og:title" content=" - Home" />
Should be:
<title>Ambri - Home</title>
<meta property="og:title" content="Ambri - Home" />