Skip to content

Instantly share code, notes, and snippets.

View DarrylD's full-sized avatar
💭
daydreaming

Darryl D. DarrylD

💭
daydreaming
View GitHub Profile
@DarrylD
DarrylD / zen.1h.js
Created November 6, 2017 16:20
Bitbar plugin to give zen like quotes
#!/usr/local/bin/node
var quotes = [
"Whatever you are, be a good one.\n-Abraham Lincoln",
"If you dream it, you can do it.\n-Walt Disney",
"Never, never, never give up.\n-Winston Churchill",
"Don’t wait. The time will never be just right.\n-Napoleon Hill",
"If not us, who? If not now, when?\n-John F. Kennedy",
"Everything you can imagine is real.\n-Pablo Picasso",
"I can, therefore I am.\n-Simone Weil",
@DarrylD
DarrylD / ChatScroller.js
Created September 8, 2016 16:06
A chat scroller for react
import React from 'react'
/**
example:
<ChatScroller ref="chatScroller">
{this.renderStuff()}
</ChatScroller>
to force move the containt to the bottom:
@DarrylD
DarrylD / directive.js
Created February 14, 2015 22:02
ionic slide box dynamic height - fixes the issue where the slide boxes aren't taking up the full height of the device
app.directive('dynamicHeight', function() {
return {
require: ['^ionSlideBox'],
link: function(scope, elem, attrs, slider) {
scope.$watch(function() {
return slider[0].__slider.selected();
}, function(val) {
//getting the heigh of the container that has the height of the viewport
var newHeight = window.getComputedStyle(elem.parent()[0], null).getPropertyValue("height");
if (newHeight) {
@DarrylD
DarrylD / app.js
Created May 2, 2014 16:17
express.js, simple dynamic route loading
//all of your express config stuff
var express = require('express')
, app = express()
//load api routes (app of the files from /api)
require('./api').boot(app)
//rest of your expressjs stuff
@DarrylD
DarrylD / view-constructor-override.js
Last active August 29, 2015 13:56
Simple override of a Backbone class, View in this case. Can be applied to modal, collection, etc...
Backbone.View = (function(View) {
// Define the new constructor
Backbone.View = function(attributes, options) {
// New constructor stuff here...
// Call default constructor
View.apply(this, arguments);
@DarrylD
DarrylD / koa-example.js
Last active January 3, 2016 09:29
Made a lengthier example on Koa's flow and how it uses generators. This is just demonstrating how the middleware stacks and uses yield opposed to using callbacks like in ExpressJS. https://github.com/koajs/koa
//Koajs example
var koa = require('koa');
var app = koa();
//Middleware cascading
app.use(function * (next) {
//Some stuff will happen here first
console.log('FIRST execution')
@DarrylD
DarrylD / paste-image.html
Created November 7, 2013 16:09
Demo of simple way to paste ( ctrl+v ) from clipboard.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Paste image from clipboard in Chrome</title>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script>
//plugin for pasting from https://gist.github.com/STRd6/5286415
(function($) {
// plugin by STRd6
@DarrylD
DarrylD / stickyheader.js
Last active December 27, 2015 12:09
Simple fixed header after trigger point
(function(){
var triggerElement = $(".container") //element to he used to trigger the fixed header
, header = $(".header") //element of header
, stickyClass = "stickit" // class to be used to give the fixed header a fixed position
$(window).scroll(function(){
var offset = 0,sticky = false,top = $(window).scrollTop();
if (triggerElement.offset().top < top) {
header.addClass(stickyClass)
sticky = true;