Skip to content

Instantly share code, notes, and snippets.

View Nate-Wilkins's full-sized avatar
🐧

Nate-Wilkins Nate-Wilkins

🐧
View GitHub Profile
@Nate-Wilkins
Nate-Wilkins / emacs-pipe
Created July 8, 2018 20:41
Pipe to emacs
#! /usr/bin/perl
# https://www.emacswiki.org/emacs/GnuClient#toc13
##
## This script uses gnudoit to put the contents of STDIN
## in an Emacs buffer called *Piped*
##
if (! `which gnudoit 2>/dev/null`) {
print STDERR "This script requires gnudoit\n";
@Nate-Wilkins
Nate-Wilkins / gist:ab4bd10e13521ff91b80ed30463612e4
Created July 3, 2017 06:32
Whitespace Project Conversion - Tabs to Spaces
find . -name '*.java' ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
// Taken from: https://daveaglick.com/posts/capturing-standard-input-in-csharp
string stdin = null;
if (Console.IsInputRedirected)
{
using (Stream stream = Console.OpenStandardInput())
{
byte[] buffer = new byte[1000]; // Use whatever size you want
StringBuilder builder = new StringBuilder();
int read = -1;
while (true)
// https://github.com/angular/angular.js/blob/5a60302389162c6ef45f311c1aaa65a00d538c66/i18n/src/parser.js
// e.g. '#,##0.###'
function parsePattern(pattern) {
var p = {
minInt: 1,
minFrac: 0,
maxFrac: 0,
posPre: '',
posSuf: '',
negPre: '',
// https://github.com/angular/angular.js/blob/51d6774286202b55ade402ca097e417e70fd546b/src/ng/filter/filters.js#L428
var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
// 1 2 3 4 5 6 7 8 9 10 11
@Nate-Wilkins
Nate-Wilkins / isolate-form.md
Created November 18, 2014 19:19
Angular isolate form

Taken directly from: http://jsfiddle.net/gikoo/qNrFX/

var demoApp = angular.module('demoApp', []);


demoApp.controller('nestedFormIsolation', function ($scope) {
    $scope.setPristine = function(form){
		form.$setPristine();
	};
@Nate-Wilkins
Nate-Wilkins / Assertion.cs
Created October 29, 2014 03:29
Assert expression
[Conditional("DEBUG")]
public static void Assert(Expression<Func<bool>> assertion, string message, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
{
bool condition = assertion.Compile()();
if (!condition)
{
string errorMssage = string.Format("Failed assertion in {0} in file {1} line {2}: {3}", memberName, sourceFilePath, sourceLineNumber, assertion.Body.ToString());
throw new AssertionException(message);
}
}
@Nate-Wilkins
Nate-Wilkins / git-file-version
Created October 3, 2014 23:39
Git File Version
git rev-list HEAD -- lib/rules/space-in-brackets.js | tail -n1 | xargs git tag --contains | head -n1
@Nate-Wilkins
Nate-Wilkins / proxy.js
Created October 1, 2014 21:50
Get (generated) js file
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(File.ReadAllBytes("path"));
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/javascript");
return result;
@Nate-Wilkins
Nate-Wilkins / DirectiveTemplateUrl
Created September 18, 2014 15:52
templateUrl custom directive
// taken from: https://github.com/esvit/ng-table/blob/master/ng-table.js
scope: {
'params': '=ngTablePagination',
'templateUrl': '='
},
replace: false,
link: function (scope, element, attrs) {
scope.params.settings().$scope.$on('ngTableAfterReloadData', function () {