Skip to content

Instantly share code, notes, and snippets.

View smith-neil's full-sized avatar

Neil Smith smith-neil

  • Otey White & Associates
  • Baton Rouge, La
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLink>
<name>WPC Day 1 24-Hour QPF</name>
<open>1</open>
<refreshVisibility>1</refreshVisibility>
<Link>
<href>http://www.wpc.ncep.noaa.gov/kml/qpf/QPF24hr_Day1_latest.kml</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>21600</refreshInterval>
// This uses a 100% height pseudo element to vertically align its child.
// The parent can be any height/width.
.parent {
text-align: center; // horizontal alignment
text-wrap: wrap; // just in case the container is narrower than the element inside.
}
.parent:before {
content: '';
// This works in a fixed sized environment.
// The child element is 200x100.
.parent {
width: 500px;
height: 500px;
}
.child {
position: absolute;
.thing {
display: table-cell;
vertical-align: middle;
}
- email address
- /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i
var Singleton = (function () {
var instance;
function Singleton() {
if (!instance)
instance = {
foo: 'bar'
}
return instance;
@smith-neil
smith-neil / getMajorityElement
Created December 24, 2014 02:42
Gets the majority element in an array. If there is no majority, undefined is returned.
var arr = [1, 1, 1, 2, 3];
function getMajorityElement(input) {
var count = 0;
var majorityElement;
var size = input.length;
for (var i = 0; i < size; i++) {
if (count === 0)
majorityElement = input[i];
@smith-neil
smith-neil / OneLineFizzBizz
Last active August 29, 2015 14:02
One line Fizz Buzz.... but why?
Enumerable.Range(1, 100)
.FirstOrDefault(m =>
{
Console.WriteLine(
m % 15 == 0 ? "FizzBuzz" :
m % 5 == 0 ? "Buzz" :
m % 3 == 0 ? "Fizz" :
m.ToString()
);
return false;
@smith-neil
smith-neil / Recursively SearchAccessibleFiles
Last active May 14, 2024 05:25
c# recursive function used to search for a file by name in a given directory and all subdirectories under the given root
IEnumerable<string> SearchAccessibleFiles(string root, string searchTerm) {
var files = new List<string>();
foreach (var file in Directory.EnumerateFiles(root).Where(m => m.Contains(searchTerm))) {
files.Add(file);
}
foreach (var subDir in Directory.EnumerateDirectories(root)) {
try {
files.AddRange(SearchAccessibleFiles(subDir, searchTerm));
}