Skip to content

Instantly share code, notes, and snippets.

@sergiolopes
sergiolopes / README.md
Created February 28, 2012 21:57
Pure CSS fix to iOS zoom bug on device rotation

My approach to fix the iOS bug is documented here:

https://github.com/sergiolopes/ios-zoom-bug-fix

Here I present one experiment with a pure CSS solution, no JS required. It uses width=device-width normally (no device-height hacking) and scales down the page on landscape.

Works fine on all iOS versions.

There's only one problem: on old iOS versions (prior to 4.3.5), the page will get a big empty space at bottom, below the content, when on landscape. Recent iOS versions don't show this behavior.

@crtr0
crtr0 / client.js
Created June 8, 2012 17:02
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@youtalk
youtalk / redirect.http2https.js
Created July 31, 2012 12:42
Automatic redirection from HTTP to HTTPS with Node.js
app.configure(function () {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.configure('production', function () {
app.use (function (req, res, next) {
var schema = (req.headers['x-forwarded-proto'] || '').toLowerCase();
if (schema === 'https') {
@sukima
sukima / XORCipher.js
Last active May 9, 2024 23:49
A Super simple encryption cipher using XOR and Base64 in JavaScript
// XORCipher - Super simple encryption using XOR and Base64
//
// Depends on [Underscore](http://underscorejs.org/).
//
// As a warning, this is **not** a secure encryption algorythm. It uses a very
// simplistic keystore and will be easy to crack.
//
// The Base64 algorythm is a modification of the one used in phpjs.org
// * http://phpjs.org/functions/base64_encode/
// * http://phpjs.org/functions/base64_decode/
@joyrexus
joyrexus / README.md
Last active February 1, 2023 08:51 — forked from joelambert/README
RAF replacements for setTimeout and setInterval

Drop in replace functions for setTimeout and setInterval that make use of requestAnimationFrame.

See overview article and Paul Irish's earlier post.

Courtesty of Joe Lambert

Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
$colours:
"red" #FF0000,
"blue" #001EFF,
"green" #00FF00,
"yellow" #F6FF00;
@each $i in $colours{
.#{nth($i, 1)}-background {
background: nth($i, 2);
}
@mpj
mpj / classless.md
Last active November 13, 2023 16:34

The future is here: Classless object-oriented programming in JavaScript.

Douglas Crockford, author of JavaScript: The Good parts, recently gave a talk called The Better Parts, where he demonstrates how he creates objects in JavaScript nowadays. He doesn't call his approach anything, but I will refer to it as Crockford Classless.

Crockford Classless is completely free of class, new, this, prototype and even Crockfords own invention Object.create.

I think it's really, really sleek, and this is what it looks like:

function dog(spec) {
WebSockets vs. Server-Sent events/EventSource
---------------------------------------------
Both WebSockets and Server-Sent Events are capable of pushing data to browsers. To me they seem to be competing technologies.
What is the difference between them? When would you choose one over the other?
Websockets and SSE (Server Sent Events) are both capable of pushing data to browsers, however they are not competing technologies.
Websockets connections can both send data to the browser and receive data from the browser.
A good example of an application that could use websockets is a chat application.
@marktopper
marktopper / install.md
Last active March 24, 2023 14:49
Install Kong + Cassandra + Java [Ubuntu 14.04]

Installing Java

We need Java in order to have Cassandra running since Cassandra 2.0 and later require Java 7 or later. And we need Cassandra in order to run Kong.

So lets start installing Java 8 (the newest one)

First we add a repository to our build in order to manage the Java 8 package, since that is not normally supported by Ubuntu.

sudo add-apt-repository ppa:webupd8team/java
@PurpleBooth
PurpleBooth / README-Template.md
Last active June 2, 2024 11:03
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites