// Normal scope
angular.element(targetNode).scope()
// Isolated scope
angular.element(targetNode).isolateScope()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createSlideNumbering = function (skipFirstN) { | |
var num = 0, | |
slides = $('.slides article'), | |
slidesNum = slides.length; | |
slides.each(function () { | |
var $this = $(this); | |
num += 1; | |
if (num <= skipFirstN) | |
return; | |
if ( $this.hasClass('nonumber') ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set an error message and redirect | |
var redirectWithMessage = function (message, url, req, res) { | |
req.session.messages = message; | |
res.redirect(url); | |
}; | |
// Return 'messages' value or null instead | |
var getMessages = function (req) { | |
var messages = req.session.messages || null; | |
delete req.session.messages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
app.use(express.bodyParser()); // Read POST parameters | |
app.use(express.cookieParser()); // Read cookies | |
app.use(express.cookieSession({secret: 'mysecret'})); // Create a session using cookies | |
app.use(express.csrf()); // Enable CSRF protection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var connect = require('connect'); | |
// Disable CSRF for some requests | |
var conditionalCSRF = function (req, res, next) { | |
req.session._csrf || (req.session._csrf = connect.utils.uid(24)); | |
if (req.method !== 'POST') { | |
next(); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var connect = require('connect'); | |
// Disable CSRF for some requests | |
var conditionalCSRF = function (req, res, next) { | |
var whitelist = [ | |
'/api/req1', | |
'/api/req2' | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'memoist' | |
class Footnote | |
extend Memoist | |
def footnote(statement, number) | |
if number == 1 | |
"Ignore this" | |
elsif number == 2 | |
statement.to_i + 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
Simple popup jQuery widget | |
### | |
$.fn.popup = do -> | |
popups = [] | |
# One time binding to document of the handler that listens for clicks | |
# on [data-popup-trigger] elements and outside popup elements | |
do ( -> | |
# Close popups on outside click |
I hereby claim:
- I am Gpx on github.
- I am gpx (https://keybase.io/gpx) on keybase.
- I have a public key whose fingerprint is 4B6B 2525 1A27 508F DA18 A226 6962 22B7 616B 78B0
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const getLog = () => { | |
return new Promise((done, reject) => { | |
fs.readFile('./semi.log', { encoding: 'utf-8' }, (err, data) => { | |
err | |
? reject(err) | |
: done(data) | |
}) | |
}) |
OlderNewer