Skip to content

Instantly share code, notes, and snippets.

@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@elijahmanor
elijahmanor / emailPattern.coffee
Created February 8, 2012 05:37
Regular Expressions in CoffeeScript
emailPattern = /// ^ #begin of line
([\w.-]+) #one or more letters, numbers, _ . or -
@ #followed by an @ sign
([\w.-]+) #then one or more letters, numbers, _ . or -
\. #followed by a period
([a-zA-Z.]{2,6}) #followed by 2 to 6 letters or periods
$ ///i #end of line and ignore case
if "john.smith@gmail.com".match emailPattern
console.log "E-mail is valid"
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@michaelcox
michaelcox / SpecRunner.js
Last active January 11, 2024 06:05
Browser Unit Testing with Backbone Mocha Chai and RequireJS
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'
@brian-mann
brian-mann / FadeTransitionRegion.js
Created October 24, 2012 16:28
Allows jQuery animation transitions between marionette regions
var FadeTransitionRegion = Backbone.Marionette.Region.extend({
show: function(view){
this.ensureEl();
view.render();
this.close(function() {
if (this.currentView && this.currentView !== view) { return; }
this.currentView = view;
@radiosilence
radiosilence / gist:4040553
Created November 8, 2012 18:19
RequireJS with Zurb Foundation
requirejs.config({
shim: {
'foundation/jquery.foundation.topbar': {
deps: ['jquery'],
},
'foundation/jquery.cookie': {
deps: ['jquery']
},
'foundation/jquery.event.move': {
deps: ['jquery']
@krisnoble
krisnoble / deploy.php
Last active April 25, 2023 15:52
A slightly modified version of Brandon Summers' script. For more information: http://simianstudios.com/blog/post/using-bitbucket-for-automated-deployment-of-multiple-repositories
<?php
date_default_timezone_set('Europe/London'); // Set this to your local timezone - http://www.php.net/manual/en/timezones.php
/**
* The root directory where the repos live.
*
* @var string
*/
$root_dir = '/your/root/dir/';
@cheeaun
cheeaun / js-error-logging-services.md
Last active December 10, 2023 13:04
JavaScript error logging services
@brian-mann
brian-mann / gist:7085079
Last active July 13, 2023 08:37
Expanded version of loading controller with edge cases covered
showRealView: (realView, loadingView, config) ->
xhrs = App.request "fetched:entities", config.entities
## ...after the entities are successfully fetched, execute this callback
$.when(xhrs...).done =>
## ================================================================ ##
## If the region we are trying to insert is not the loadingView then
## we know the user has navigated to a different page while the loading
## view was still open. In that case, we know to manually close the original
## view so its controller is also closed. We also prevent showing the real