Skip to content

Instantly share code, notes, and snippets.

View GFoley83's full-sized avatar
☘️
CTO @ Educa

Gavin Foley GFoley83

☘️
CTO @ Educa
View GitHub Profile
@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));
}
@GFoley83
GFoley83 / location-finder.js
Last active January 22, 2020 11:55
A function which returns a jQuery promise that resolves when a user's location has been found. Also handles the scenario where by when not clicking allow/deny the browser never fires the timeout option of `getCurrentPosition()`. If `getCurrentPosition()` fails then the fallback lat lng is used instead.
/*
Sample use:
var loc = new LocationFinder(-41.29247, 174.7732);
$.when(loc.findUserLocationAsync()).then(function (lat, lng) {
// console.log("Lat & lng set as: ", loc.usersPosition())
});
*/
@turtlemonvh
turtlemonvh / main.js
Last active January 3, 2021 16:37
Angular Messaging
var MyApp = angular.module('MyApp');
MyApp.factory('msgBus', ['$rootScope', function($rootScope) {
var msgBus = {};
msgBus.emitMsg = function(msg, data) {
data = data || {};
$rootScope.$emit(msg, data);
};
msgBus.onMsg = function(msg, func, scope) {
var unbind = $rootScope.$on(msg, func);
if (scope) {
@JamesRandall
JamesRandall / BlobStorageMultipartStreamProvider.cs
Last active March 19, 2020 23:12
Azure Blob Container Web API Image Upload
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
@pdcullen
pdcullen / UploadController.cs
Created July 28, 2014 13:36
ng-flow asp.net api2 upload class
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using System.Web;
@albertbori
albertbori / MyDB.cs
Last active June 13, 2023 18:11
.NET EntityFramework Encryption Example (C#)
public class MyDB : IdentityDbContext<User>
{
//DBSet properties go here
public MyDB()
{
((IObjectContextAdapter)this).ObjectContext.ObjectMaterialized += new ObjectMaterializedEventHandler(ObjectMaterialized);
}
#region Encryption
@ericelliott
ericelliott / essential-javascript-links.md
Last active May 17, 2024 03:38
Essential JavaScript Links
@devlead
devlead / PostMessage.ps1
Created January 8, 2015 16:10
Post to slack from PowerShell
$postSlackMessage = @{token="*topsecret*";channel="#general";text="Hello from PowerShell!";username="PowerShell";icon_url="https://pbs.twimg.com/profile_images/1604347359/logo_512x512_normal.png"}
Invoke-RestMethod -Uri https://slack.com/api/chat.postMessage -Body $postSlackMessage
@panda4man
panda4man / app.js
Created January 18, 2015 01:28
Ionic Route Example
$stateProvider
.state('app', {
url: "/app",
abstract: true,
controller: 'MainCtrl',
templateUrl: "templates/tabs.html",
resolve: {
Migrations: ['$q', 'InitService', function($q, Init) {
return Init.promise.then(function(good) {
return good;
@axoplasm
axoplasm / gist:bdda3922fa43b2ef25d8
Last active January 17, 2018 12:41
Ditching Compass and Sass for LibSass

I had a large client framework extending my personal boilerplate that was taking upwards of 10seconds to compile with standard Ruby Sass. This framework had minimal dependencies:

I used Bundler to manage Ruby dependencies and ran tasks with Grunt — mainly compiling Sass via grunt-contrib-compass, and previewing with live-reload. Simple stuff.

But 10seconds was an unacceptable performance hit for me. I typically keep my monitor split in half (using Spectacle ), with a browser on one half and MacVim on the other. With Live Reload running I get a nearly realtime preview of my work … except for that one client framework, where I was gettin