Skip to content

Instantly share code, notes, and snippets.

View rwhitmire's full-sized avatar
👢
New boot goofin'

Ryan Whitmire rwhitmire

👢
New boot goofin'
View GitHub Profile
@rwhitmire
rwhitmire / loc.sh
Created June 13, 2013 13:23
counts lines of code
( find ./ -name '*.js' -print0 | xargs -0 cat ) | wc -l
@rwhitmire
rwhitmire / !description.md
Last active August 29, 2015 14:14
grunt-sails-linker ideas

continuation from: https://gist.github.com/mikermcneil/f1294b34f89f9ee9f392

Problems I ran into

After spending a decent amount of time working on a new approach for bundling and automatically injecting references into the HTML, a few problems started presenting themselves. First of all, declaring glob patterns inline with a tag limits our flexibility. It makes it difficult (impossible?) to bundle files from multiple directories. It also becomes difficult (impossible?) to specify the order of scripts if needed.

Also, injecting files from pipeline.js becomes difficult as we don't really know where to put files if multiple blocks exist.

Potential solution

I spend a fair amount of time working in ASP.NET, and I think we can possibly borrow some of their ideas for bundling and injecting scripts onto the page. I think we could repurpose pipleine.js - possibly rename it bundles.js - to contain data about resource bundles. See code below for examples.

@rwhitmire
rwhitmire / makeCancelable.js
Created October 3, 2016 14:28
Cancelable Promises
// source: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html
const makeCancelable = (promise) => {
let hasCanceled_ = false;
const wrappedPromise = new Promise((resolve, reject) => {
promise.then((val) =>
hasCanceled_ ? reject({isCanceled: true}) : resolve(val)
);
promise.catch((error) =>
@rwhitmire
rwhitmire / native.css
Created November 3, 2016 20:52
native fonts for major operating systems
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
@rwhitmire
rwhitmire / round.js
Created December 6, 2016 18:41
round
const round = function(number, precision) {
var factor = Math.pow(10, precision);
var tempNumber = number * factor;
var roundedTempNumber = Math.round(tempNumber);
return roundedTempNumber / factor;
}
@rwhitmire
rwhitmire / checkbox.css
Created February 2, 2017 03:02
styled checkboxes
input[type=checkbox] {
outline: none;
position: relative;
}
input[type=checkbox]:after {
content: ' ';
display: inline-block;
width: 13px;
height: 13px;
@rwhitmire
rwhitmire / AsyncHelper.cs
Last active November 7, 2017 14:13
async in sync
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
@rwhitmire
rwhitmire / keybase.md
Created November 21, 2017 19:46
keybase.md

Keybase proof

I hereby claim:

  • I am rwhitmire on github.
  • I am rwhitmire (https://keybase.io/rwhitmire) on keybase.
  • I have a public key ASDLhfQYyRZtGx6CB4wsXp0gUG-hw7nUGyNjZlcJ306r-wo

To claim this, I am signing this object:

@rwhitmire
rwhitmire / DateHelpers.cs
Created July 17, 2018 13:53
date helpers
public class DateHelpers
{
public static DateTime GetDayStart(DateTime date, string timezone)
{
var timezoneInfo = TimeZoneInfo.FindSystemTimeZoneById(timezone);
var timezoneNow = TimeZoneInfo.ConvertTimeFromUtc(date, timezoneInfo);
return TimeZoneInfo.ConvertTimeToUtc(timezoneNow.Date, timezoneInfo);
}
public static DateTime GetWeekStart(DateTime date, string timezone)
@rwhitmire
rwhitmire / index_suggestions.sql
Created October 9, 2018 13:40
Index Suggestions for SQL Server
SELECT CAST(SERVERPROPERTY('ServerName') AS [nvarchar](256)) AS [SQLServer]
,db.[database_id] AS [DatabaseID]
,db.[name] AS [DatabaseName]
,id.[object_id] AS [ObjectID]
,id.[statement] AS [FullyQualifiedObjectName]
,id.[equality_columns] AS [EqualityColumns]
,id.[inequality_columns] AS [InEqualityColumns]
,id.[included_columns] AS [IncludedColumns]
,gs.[unique_compiles] AS [UniqueCompiles]
,gs.[user_seeks] AS [UserSeeks]