Skip to content

Instantly share code, notes, and snippets.

// 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!"
@devsignite
devsignite / CORS.allowed
Created June 20, 2013 02:19
Allow CORS in ExpressJS / NodeJS
//CORS middleware
var allowCrossDomain = function(req, res, next) {
res.header('Access-Control-Allow-Origin', config.allowedDomains);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
}
//...
CREATE TABLE [dbo].[UserProfile] (
[UserId] INT IDENTITY (1, 1) NOT NULL,
[UserName] NVARCHAR (MAX) NULL,
PRIMARY KEY CLUSTERED ([UserId] ASC)
);
CREATE TABLE [dbo].[webpages_Membership] (
[UserId] INT NOT NULL,
[CreateDate] DATETIME NULL,
[ConfirmationToken] NVARCHAR (128) NULL,
@devsignite
devsignite / api-website.js
Last active December 19, 2015 03:38
example of node.js api module with express.js error middleware
var mongoose = require("mongoose"),
UserSchema = require('../models/User').Schema;
WebsiteSchema = require('../models/Website').Schema;
Website = require('../models/Website').Model;
module.exports = {
// get > api/website
get: function (req, res, next) {
return Website.find(function (err, websites) {
if (!err) {
@devsignite
devsignite / api-routes.js
Created June 29, 2013 17:50
Express.js api routing
app.get('/api/website', routes.api.website.get);
app.get('/api/website/:id', routes.api.website.getById);
app.post('/api/website', routes.api.website.create);
app.put('/api/website/:id', routes.api.website.update);
app.delete('/api/website/:id', routes.api.website.delete);
git config --global mergetool.sublime.cmd "subl -w \$MERGED"
git config --global mergetool.sublime.trustExitCode false
git config --global merge.tool sublime
git mergetool -y
@devsignite
devsignite / commands.bat
Last active December 19, 2015 15:59
Removing directory
rmdir /s /q dirname
@devsignite
devsignite / validation.css
Created August 1, 2013 22:40
Angular.js validation styles
.css-form input.ng-valid.ng-dirty {
background-color: #cbffcb;
}
.css-form input.ng-invalid.ng-dirty {
background-color: #ffcbcb;
}
@devsignite
devsignite / active.class.js
Created August 1, 2013 23:51
Add active class to the tab / menu / link based on the location pathname
$(document).ready(function () {
$('ul.nav > li > a[href="' + document.location.pathname + '"]').parent().addClass('active');
});
@devsignite
devsignite / User.js
Created August 2, 2013 21:57
User definition
var UserSchema = new Schema({
username: { type: String, required: true, trim: true, unique: true },
password: { type: String, required: true },
email: { type: String, lowercase: true, trim: true, unique: true },
salt: { type: String, required: true },
hash: { type: String, required: true },
verificationToken: { type: String },
verificationTokenExpirationDate: { type: Date },
isConfirmed: { type: Boolean, default: false },