Skip to content

Instantly share code, notes, and snippets.

function createWebSocket () {
var connection = new WebSocket();
var attempts = 1;
connection.onopen = function () {
// reset the tries back to 1 since we have a new connection opened.
attempts = 1;
// ...Your app's logic...
}
@AmaanC
AmaanC / retro-gravatar.user.js
Last active August 29, 2015 13:58
Replaces all of the default identicon gravatar images on SO Chat with retro gravatar images. Click raw, and drag and drop in Extensions to install in Chrome.
// ==UserScript==
// @name Retro Gravatar
// @author Amaan Cheval
// @description Use retro gravatars instead of the indenticon ones
// @include http://chat.stackexchange.com/rooms/*
// @include http://chat.stackoverflow.com/rooms/*
// ==/UserScript==
var update = function () {
[].forEach.call(document.querySelectorAll('.avatar > img'), function (elem) {
Sid Meier's 10 Rules of Game Design
1. Choose a topic you have a passion for. Game Design is about creativity.
2. Do research after the game is done. Tap into the player’s brain.
3. Define your axioms, refine your axioms. Prototype, prototype, prototype; sit in all the chairs.
4. Double it or cut it in half. You are more wrong than you think.
@AmaanC
AmaanC / 6.c
Created December 11, 2011 12:40
Project Euler Solution 6 using C
#include <stdio.h>
main(){
int i, sumOfSquares = 0, squareOfSum, sum = 0;
for(i = 1; i <= 100; i++){
sumOfSquares += i * i;
sum += i;
}
squareOfSum = sum * sum;
printf("%d\n", squareOfSum - sumOfSquares);
@AmaanC
AmaanC / gist:1472190
Created December 13, 2011 13:52 — forked from rlemon/gist:1472061
u mad bro?
/*
█░░░░░█░░░░░░░░░░░░░░░░░░░░░█░░█░░░░░░░░░░░░░░█▀▀█
█░█▀█░█░░█░█░░█▀█▀█░█▀▀█░█▀▀█░░█▀▀█░█▀▀░█▀▀▀█░░░░█
█░█░█░█░░█░█░░█░█░█░█▀▀█░█░░█░░█░░█░█░░░█░░░█░░▀▀▀
▀░▀▀▀░▀░░▀▀▀░░▀░░░▀░▀░░▀░▀▀▀▀░░▀▀▀▀░▀░░░▀▀▀▀▀░░█░░
*/
@AmaanC
AmaanC / websockets-server.js
Created September 4, 2012 16:23 — forked from bradwright/websockets-server.js
Pure Node.js WebSockets server
/*
* node-ws - pure Javascript WebSockets server
* Copyright Bradley Wright <brad@intranation.com>
*/
// Use strict compilation rules - we're not animals
'use strict';
var net = require('net'),
crypto = require('crypto');
@AmaanC
AmaanC / gist:4001526
Created November 2, 2012 14:02 — forked from Zirak/gist:1490195
Basic DOM element manipulation
//creating an element is easy peasy
var divElem = document.createElement( 'div' );
//divElem is now a div element. it's not related to the any other element or
// node, it's free-range.
//to add it to the body element, for example:
document.body.appendChild( divElem );
//splendidsimo!
@AmaanC
AmaanC / gist:4007749
Created November 3, 2012 16:05
Interesting stuff for dievardump
1. Zirak likes babies.
@AmaanC
AmaanC / corporate-eula.md
Created November 6, 2012 16:52 — forked from rlemon/corporate-eula.md
EULA corporate

End User License Agreement.

  1. You have no rights
  2. Please read carefully 1

Last updated November 1st, 2012.

@AmaanC
AmaanC / google-so-chat.user.js
Created November 8, 2012 19:20
Google button on SO chat
var button = document.createElement('button');
button.className = 'button';
button.appendChild(document.createTextNode('Google'));
button.addEventListener('click', function (){
window.open('https://www.google.com/search?q=' + document.getElementById('input').value);
}, false);
document.getElementById('sayit-button').insertAdjacentElement('afterend', button);