Skip to content

Instantly share code, notes, and snippets.

View BrainCrumbz's full-sized avatar

BrainCrumbz BrainCrumbz

View GitHub Profile
Here is a simple jQuery plugin to make a table header fixed on top when window is scrolled.
Using the code from twitter bootstrap documentation page, this code is customized for table header.
Create the table with following layout -
<table class="table-fixed-header">
<thead class="header">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
@BrainCrumbz
BrainCrumbz / directives.js
Created June 18, 2013 19:24
Reusing an AngularJS Directive core code. The idea is to: 1. conceal the actual directive behaviour in a separate JS "class", 2. store that in an Angular Module value, 3. inject that value into an Angular directive, and then 4. just have the directive factory function return the constructed instance of the "class".
// Define core directive code + attributes and store that as a module value
angular.module('com.namespace.directives').value('MyDirectiveCore', MyDirectiveCore);
function MyDirectiveCore($compile) {
this.restrict = 'A';
this.priority = 10;
this.link = postLink;
return this;
@BrainCrumbz
BrainCrumbz / Directives Inheritance
Last active May 12, 2017 03:57
Reusing an AngularJS Directive core code. Please see 'Directives Inheritance' file for an extended description. (Text here comes out unformatted). For a working sample, please see plunkr at http://plnkr.co/edit/6kzpuSGPFfXe6eSH5bc2
Reusing an AngularJS Directive core code. The idea is to:
** 1. conceal the actual directive behaviour in a separate JS "class",
** 2. store that in an Angular service,
** 3. inject that service into an Angular directive,
** 4. just have the directive factory function return the constructed instance of the "class".
That is to separate the directive core code from the actual directive factory.
Then one actually wants to inherit a directive core "class" from another. It's not really a matter of JS inheritance, but more on how to inject one into the other by means of Angular modules, without actually instantiating none of them until needed,
<?php
class PeThemeShortcodeBrainCrumbzParallaxSeparator extends PeThemeShortcode {
/*
Syntax:
[parallax-sep imageurl="URL of parallax background image"
textcolor="font color code (optional)"
bgcolor="background color code (optional)"
padding_top="top padding (optional)"
@BrainCrumbz
BrainCrumbz / consoleLogger.js
Created October 17, 2014 08:39
CommonJS module used in a ThunderBird add-on
'use strict';
exports.log = log;
exports.dir = dir;
const { components } = require('chrome');
var consoleService = components.classes["@mozilla.org/consoleservice;1"]
.getService(components.interfaces.nsIConsoleService);
@BrainCrumbz
BrainCrumbz / Exception.log
Last active August 29, 2015 14:16
Join WAV files into a WMA file with NAudio - With COMException (see fork for fixes)
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in WavToWma.Presentation.exe
Additional information: Eccezione da HRESULT: 0xC00D36B0
in NAudio.MediaFoundation.MediaFoundationInterop.MFCreateSinkWriterFromURL(String pwszOutputURL, IMFByteStream pByteStream, IMFAttributes pAttributes, IMFSinkWriter& ppSinkWriter)
in NAudio.Wave.MediaFoundationEncoder.CreateSinkWriter(String outputFile)
in NAudio.Wave.MediaFoundationEncoder.Encode(String outputFile, IWaveProvider inputProvider)
in NAudio.Wave.MediaFoundationEncoder.EncodeToWma(IWaveProvider inputProvider, String outputFile, Int32 desiredBitRate)
... <the line invoking MediaFoundationEncoder.EncodeToWma> ...
@BrainCrumbz
BrainCrumbz / JoinWavFilesIntoWma.cs
Last active August 29, 2015 14:16 — forked from BrainCrumbz/Exception.log
Join WAV files into a WMA file with NAudio - COMException fixed
// ...
/* Mixing WaveFileReader with MediaFoundationEncoder causes an exception.
* Stick with MediaFoundationReader when working with MediaFoundation namespace.
List<WaveFileReader> waveFileReaders = BuildTheReaderListFromPathNames();
*/
List<MediaFoundationReader> waveFileReaders = BuildTheReaderListFromPathNames();
IWaveProvider joinedWaveProvider = buildProvider(waveFileReaders);
@BrainCrumbz
BrainCrumbz / client-output.log
Last active April 1, 2019 13:48
mosca publish demo
MQTT Client is starting...
MQTT client connected
MQTT client subscribing to broker/someTopic...
subscribe granted: [ { topic: 'broker/someTopic', qos: 1 } ]
#########################################
MQTT client received message
* topic broker/someTopic
* message <Buffer 7b 22 66 69 65 6c 64 41 22 3a 22 61 22 2c 22 66 69 65 6c 64 42 22 3a 22 62 22 7d>
@BrainCrumbz
BrainCrumbz / describe_execution_order.cs
Last active December 28, 2015 19:56
Changes to NSpec docs to show execution order
using NSpec;
using System;
namespace NSpecExecutionOrder
{
abstract class parent_class : nspec // this can be either an abstract class, or just a class
{
public const string parentPrefix = "parent: ";
public const string childPrefix = "\t\t child: ";
public const string methodPrefix = "\t\t\t\t method: ";
@BrainCrumbz
BrainCrumbz / apm-test-01.log
Last active March 15, 2016 00:42
Atom issue #11137
## output from 'apm test', after a previous 'apm test' run showed some 'F' but still gave 'Tests passed'
## this is only stderr. stdout was redirected on command line to a file, and is appended at the bottom
[3724:3748:0314/213441:VERBOSE1:crash_service_main.cc(68)] Session start. cmdline is [--reporter-url=http://54.249.141.255:1127/post --application-name=Atom --v=1]
[3724:3748:0314/213441:VERBOSE1:crash_service.cc(142)] window handle is 000C0666
[3724:3748:0314/213441:VERBOSE1:crash_service.cc(290)] pipe name is \\.\pipe\Atom Crash Service
dumps at C:\Users\_My_User_\AppData\Local\Temp\Atom Crashes
[3724:3748:0314/213441:VERBOSE1:crash_service.cc(294)] checkpoint is C:\Users\_My_User_\AppData\Local\Temp\Atom Crashes\crash_checkpoint.txt
server is http://54.249.141.255:1127/post
maximum 128 reports/day