Skip to content

Instantly share code, notes, and snippets.

View scottcorgan's full-sized avatar
💭
Not coding

Scott Corgan scottcorgan

💭
Not coding
  • Tamarack
  • Shelbyville, KY
View GitHub Profile
var bind = function (selector, event) {
return binder(selector, event);
};
var binder = function (selector, event) {
var listeners = [];
document.querySelector(selector)
.addEventListener(event, function (e) {
listeners.forEach(function (listener) {
// inside a function on the Divshot prototype
// it uses https://www.npmjs.org/package/promise under the hood
var promise = this.http._promiseWrap(function (resolve, reject) {
// resolve or reject in here
});
// Server
var express = require('express');
var app = express();
var apiV1 = require('api-v1');
app.user('/api/v1', apiV1.app);
app.user('/api/v2', apiV2.app);
app.listen(process.env.PORT || 9876);
<my-element></my-element>
<my-element></my-element>
@scottcorgan
scottcorgan / gulpfile.js
Last active August 29, 2015 14:10
Divshot local with LiveReload and Gulp
var livereload = require('gulp-livereload'),
superstatic = require('superstatic'),
dest = 'build';
gulp.task('server', function(next) {
var server = superstatic();
next();
});
gulp.task('watch', ['server'], function() {
@scottcorgan
scottcorgan / redux-devtools-separate-window.js
Last active August 29, 2015 14:27 — forked from tlrobinson/redux-devtools-separate-window.js
Put the awesome redux-devtools in it's own window so it doesn't obscure or be obscured by your application
// give it a name so it reuses the same window
var win = window.open(null, "redux-devtools", "menubar=no,location=no,resizable=yes,scrollbars=no,status=no");
// reload in case it's reusing the same window with the old content
win.location.reload();
// wait a little bit for it to reload, then render
setTimeout(function() {
React.render(
<DebugPanel top right bottom left >
var opts = {
log: require('./logger'),
fs: require('./fs')
};
var someCommand(
name('something'),
use(function (data, flags, options) {
options.log('hey!');
options.fs.write('something');
@scottcorgan
scottcorgan / causes.php
Created December 21, 2011 16:23
Dynamic Causes
$campaigns = array();
$sql = "SELECT * FROM svn_posts WHERE post_type = 'shirts' AND post_date < now() ORDER BY ID DESC LIMIT 10";
$query = $this->db->query($sql);
// create organized arrays of campaign data
foreach($query->result() as $campaign){
$sql = 'SELECT * FROM svn_postmeta WHERE post_id = ' . $campaign->ID;
$results = $this->db->query($sql)->result();
$meta = array();
@scottcorgan
scottcorgan / scrolltop.js
Created December 22, 2011 22:53
Scrolltop
$(document).animate({
scrollTop : 100
});