Skip to content

Instantly share code, notes, and snippets.

@mscdex
mscdex / test.js
Last active September 15, 2023 11:55
sharing sessions between node.js and php using redis
var express = require('express'),
app = express(),
cookieParser = require('cookie-parser'),
session = require('express-session'),
RedisStore = require('connect-redis')(session);
app.use(express.static(__dirname + '/public'));
app.use(function(req, res, next) {
if (~req.url.indexOf('favicon'))
return res.send(404);
@nathansmith
nathansmith / scroll-offset.js
Last active November 27, 2023 04:51
Check if the user is scrolled to the bottom of the page.
window.onscroll = function() {
var d = document.documentElement;
var offset = d.scrollTop + window.innerHeight;
var height = d.offsetHeight;
console.log('offset = ' + offset);
console.log('height = ' + height);
if (offset >= height) {
console.log('At the bottom');
@janodev
janodev / ARSketchView.h
Last active December 22, 2015 19:19
ARSketchView
@interface ARSketchView : UIView
- (IBAction) clear;
- (IBAction) replay;
@end
// For example:
// UIColorFromRGBA(0xffee00, 0.5)
// UIColorFromRGB(0xffee00)
static inline UIColor *UIColorFromRGBA(int rgb, float a) {
return [UIColor colorWithRed:((float)((rgb & 0xFF0000) >> 16))/255.0
green:((float)((rgb & 0xFF00) >> 8))/255.0
blue:((float)(rgb & 0xFF))/255.0 alpha:a];
}