Skip to content

Instantly share code, notes, and snippets.

View joshperry's full-sized avatar
😝

Joshua Perry joshperry

😝
View GitHub Profile
@joshperry
joshperry / rollOnLoad.js
Created April 3, 2015 18:26
Roll on load directive
angular.module('saidpApp')
.directive('rollOnLoad', function(){
return {
restrict: 'A',
link: function(scope,element){
element.addClass('preroll');
setTimeout(function() {
requestAnimationFrame(function() {
element.removeClass('preroll');
});
$('.level1>.x-panel-bwrap>.x-panel-tbar, .level2>.x-panel-bwrap>.x-panel-tbar, .level3>.x-panel-bwrap>.x-panel-tbar').click(function(){
parent = this.parentNode;
body = $(parent).children('.x-panel-body');
xpanel = $(body).children('.x-panel');
// I always specifically open and close because I've seen some issues with toggleClass. - CM
if($(this).hasClass('open')) {
$(this).removeClass('open');
$(xpanel).removeClass('open');
} else {
$(this).addClass('open');
@joshperry
joshperry / gist:9e3e35e10094746ecb0a
Last active August 29, 2015 14:11
Pumping an event stream using Promises
var network = getNetworkSystem();
var io = initWebsockets();
var waitForNodes = function(reject) {
return network.onNodeIdentification()
.then(function(nodeId) {
io.emit('node found', nodeId);
}, reject)
.then(waitForNodes.bind(this, reject));
};
@joshperry
joshperry / gist:b32559be5a2e05d51c53
Created October 8, 2014 21:43
HTTP client proxy
var http = require('http'),
EventEmitter = require('event').EventEmitter,
httpProxy = require('http-proxy');
var proxyAgent = new http.Agent({ maxSockets: 3 });
proxyAgent.createConnection = function(options) {
var clientSocket = registry.getSocket(options.servername);
if(!clientSocket) {
// Set clientSocket to a future Socket here somehow
'use strict';
angular.module('saidpApp')
.directive('ngDebounce', function ($timeout) {
return {
restrict: 'A',
require: '?ngModel',
priority: 99,
link: function (scope, elm, attr, ngModel) {
if (!ngModel || attr.type === 'radio' || attr.type === 'checkbox') {
public function getRecentEpisodes()
{
$podcastid = Input::get('podcast_id');
$podcast = Podcast::find($podcastid);
// If we don't have any epsisodes, we need to import them for the feed
$this->episodesController->importEpisodes($podcast);
// Now let's collect our episodes
public class Episode
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[Indexed]
public int SubscriptionId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Content { get; set; }
public string Guid { get; set; }
Subscription sub = new Subscription
{
Title = "Accidental Tech Podcast",
Description = "Nerd stuff"
};
var result = await App.db.InsertAsync(sub);
Debug.WriteLine("{0} : {1} {2}", sub.Id, sub.Title, sub.Description);
'use strict';
angular.module('sawebApp')
.directive('pdkFilesSelected', function($parse) {
return {
restrict: 'A',
link: function(scope, elm, attrs) {
var onSelected = $parse(attrs.pdkFilesSelected);
elm.on('change', function() {
scope.$apply(function() {
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<immediateFlush value="true" />
<file value="pdk.log"/>
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="1" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{yyyy-MM-dd hh:mm:ss} %level %thread %logger - %message%newline" />