Skip to content

Instantly share code, notes, and snippets.

View droyad's full-sized avatar

Robert Wagner droyad

View GitHub Profile
@droyad
droyad / gist:4fabdd1dc01e1691cba9
Last active August 29, 2015 14:24
Angular mvc-partial
module Fams.EnumSelector {
interface IScope extends ng.IScope
{
promise;
loaded();
onLoad();
}
function directiveFactory() {
SELECT
t.NAME AS TableName,
s.Name AS SchemaName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
public interface IResult
{
bool WasSuccessful { get; }
string[] Errors { get; }
bool WasFailure { get; }
}
public class Result : IResult
{
@droyad
droyad / gist:d094ebaef382b40a973a
Last active August 29, 2015 14:21
Directive example
/// <reference path="../../app.ts"/>
module Foo.AddBarAuditLink {
class Controller {
barId: number;
constructor($scope, $modal) {
@droyad
droyad / gist:03b814732f2a169d228a
Created May 12, 2015 07:05
Humanized Timestamp Directive
export function humanTimestampDirective($interval: ng.IIntervalService): ng.IDirective {
function link(scope, element, attrs) {
var timeoutId;
var date;
function apply() {
var humanised;
if (date) {
@droyad
droyad / gist:50d7cc4a135f6fc7eb2b
Created May 12, 2015 07:04
Disable IE Caching for Angular
module.config(['$httpProvider', function ($httpProvider) {
//initialize get if not there
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
//disable IE ajax request caching
$httpProvider.defaults.headers.get['If-Modified-Since'] = '0';
}]);
@droyad
droyad / gist:8757f98f05eb00d99d48
Last active August 29, 2015 14:21
Angular Error handling
export function httpErrorHandler($httpProvider: ng.IHttpProvider) {
var interceptor = ($q: ng.IQService) => {
return {
'requestError': response => {
toastr.error(response.message || response.statusText || "An error occured");
return $q.reject(response);
},
'responseError': response => {
var error = (response.data && response.data.errors) || response.statusText || "An error occured";
void Main()
{
IDb db;
new PersonNameProjection(
new PersonQuery(db.Table<Person>()).ByName("Tod")
).Execute();
}
@droyad
droyad / gist:e9938e4b6528a26a0ad9
Created December 18, 2014 23:32
Gource settings (git visualisation)
// 3s/day
c:\temp\gource\gource.exe -o out.ppm -r 25 -s 3 -a 1 --colour-images --hide filenames
c:\temp\ffmpeg\bin\ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i out.ppm -vcodec libx264 -threads 0 gource..avi -fpre "c:\temp\ffmpeg\presets\libvpx-720p.ffpreset"
// Fast 1s/day
c:\temp\gource\gource.exe -o out.fast.ppm -r 25 -s 1 -a 1 --colour-images --hide filenames --font-size 6
c:\temp\ffmpeg\bin\ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i out.fast.ppm -vcodec libx264 -threads 0 gource.fast.avi -fpre "c:\temp\ffmpeg\presets\libvpx-720p.ffpreset"
@droyad
droyad / gist:605cbc124481e918f1d2
Last active August 29, 2015 14:11
Dogfooding API Client
public class GenerateInvoice
{
private readonly IApiDogfoodingClient<Api.ElectricityInvoiceController> _apiElectricityController
public async Task<ActionResult> Invoice(int id)
{
var invoice = await _apiElectricityController.Get(c => c.Get(id));
return new PdfReportResult<ElectricityInvoiceReport>(invoice);
}
}