Skip to content

Instantly share code, notes, and snippets.

View thomastuts's full-sized avatar

Thomas Tuts thomastuts

View GitHub Profile
@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);
@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 / 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 / gist:7c35d748e558c4936ff8
Last active August 29, 2015 14:05
Adding files mid-stream in Gulp
var path = require('path');
var gulp = require('gulp');
var concat = require('gulp-concat');
var templateCache = require('gulp-angular-templatecache');
var addsrc = require('gulp-add-src');
var paths = {
src: 'public/assets/src'
};
var gulp = require('gulp');
var path = require('path');
var paths = require('./paths');
var concat = require('gulp-concat');
var sourceMaps = require('gulp-sourcemaps');
var mainBowerFiles = require('main-bower-files');
var sourceOrdered = [
'!' + path.join(paths.scripts, 'bundle.js'),
'!' + path.join(paths.scripts, 'vendor.js'),
var gulp = require('gulp');
var open = require('gulp-open');
var karma = require('karma').server;
var protractor = require('gulp-protractor').protractor;
var paths = require('./paths');
module.exports = {
unit: function (done) {
karma.start({
configFile: paths.tests.unit.config,
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',
'use strict';
angular.module('myAuthApp', [
'ui.router'
])
.config(function ($urlRouterProvider, $stateProvider) {
$stateProvider
.state('login', {
url: '/signin',
templateUrl: 'src/views/auth/partials/login.html',
app/
├── index.html
└── src
├── app.js
├── bundle.js
├── common
│   ├── auth.js
│   ├── router.js
│   └── storage.js
├── components
@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);