Skip to content

Instantly share code, notes, and snippets.

View thomastuts's full-sized avatar

Thomas Tuts thomastuts

View GitHub Profile
@thomastuts
thomastuts / gulpfile.js
Created February 27, 2015 14:25
Splitting up Gulp tasks in separate files
// gulpfile.js
var gulp = require('gulp');
var requireDir = require('require-dir');
var tasks = requireDir('./tasks');
gulp.task('sass', tasks.sass);
gulp.task('serve:dev', tasks.serve.dev);
gulp.task('serve:dist', tasks.serve.dist);
@thomastuts
thomastuts / bundle.js
Created April 1, 2015 18:10
Gulp workflow with Browserify, Babel, React & BrowserSync
// tasks/bundle.js
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
var watchify = require('watchify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var concat = require('gulp-concat');

I'm working on an application that plays audio clips. The audio clips that are currently playing are stored in the Redux store (you can play more than one clip at once). Everything is working just fine, but I'm wondering what the cleanest way to play/stop the audio would be. (See below JS files for the full source of my store and audio manager file)

Currently, I am triggering the play/stop actions from within the store itself, but this feels kind of wrong:

// store.js

// ...
case 'AUDIO_PLAY':
      const audioObject = createAudioObject({
@thomastuts
thomastuts / gist:6717157
Created September 26, 2013 17:03
AngularJS code convention: 2 ways of declaring controllers
/**
* WAY 1: ANGULARJS TUTORIAL
*/
// app.js
var myApp = angular.module('myApp',[]);
// controllers/greeting.js
myApp.controller('GreetingCtrl', ['$scope', function($scope) {
@thomastuts
thomastuts / PHP rewrite
Created July 10, 2013 20:39
Remove .php from extensions
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
@thomastuts
thomastuts / Gruntfile.js
Created May 13, 2013 09:53
Gruntfile with SCSS watcher
'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
'use strict';
angular
.module('test')
.factory('Animal', function () {
function Animal(name) {
this.name = name;
}
app/
├── index.html
└── src
├── app.js
├── bundle.js
├── common
│   ├── auth.js
│   ├── router.js
│   └── storage.js
├── components
'use strict';
angular.module('myAuthApp', [
'ui.router'
])
.config(function ($urlRouterProvider, $stateProvider) {
$stateProvider
.state('login', {
url: '/signin',
templateUrl: 'src/views/auth/partials/login.html',
gulp.task('bundle:source', function () {
return es.merge(
gulp.src('src/scripts/**/*.html')
.pipe(templateCache({
module: 'myModule',
root: 'scripts'
})),
gulp.src([
'src/scripts/app.js',