Skip to content

Instantly share code, notes, and snippets.

--- a/socket.io/lib/manager.js Mon Nov 28 10:46:16 2011 -0500
+++ b/socket.io/lib/manager.js Mon Nov 28 10:49:24 2011 -0500
@@ -466,12 +466,13 @@
* @api private
*/
-Manager.prototype.onClientDisconnect = function (id, reason) {
+Manager.prototype.onClientDisconnect = function (id, reason, local) {
for (var name in this.namespaces) {
this.namespaces[name].handleDisconnect(id, reason, typeof this.roomClients[id][name] !== 'undefined');
@yitznewton
yitznewton / websockets_ajax_0.md
Created June 10, 2014 11:10
WebSockets and AJAX: an initial comparison

WebSockets and AJAX: an initial comparison

AJAX (i.e. HTTP) advantages

  • namespacing (URL)
    • WebSockets only have global events
      • might actually be global ("shut down server")
      • might be context-sensitive ("add an item to the current to-do list")
  • request & response cycle, with semantics
  • WebSockets only have one-off messages
@yitznewton
yitznewton / palindrome.hs
Created May 29, 2014 13:12
Detecting a palindrome in Haskell
isPalindrome :: Eq a => [a] -> Bool
isPalindrome [] = True
isPalindrome (_:[]) = True
isPalindrome (x:xs)
| x == last xs = isPalindrome $ init xs
| otherwise = False
@yitznewton
yitznewton / .travis.yml
Created May 7, 2014 14:57
Multilang Travis config
php:
- 5.5
before_script:
- ./travis/before_script.sh
- make composer-install
- make frontend-install
- phpenv config-add tests/php-custom-$TRAVIS_PHP_VERSION.ini
cache:
@yitznewton
yitznewton / mad_haskell.hs
Created March 3, 2014 16:34
Mad haskell
bmiTell :: (RealFloat a) => a -> a -> String
bmiTell weight height
| bmi <= skinny = "You're underweight, you emo, you!"
| bmi <= normal = "You're supposedly normal. Pffft, I bet you're ugly!"
| bmi <= fat = "You're fat! Lose some weight, fatty!"
| otherwise = "You're a whale, congratulations!"
where bmi = weight / height ^ 2
skinny = 18.5
normal = 25.0
fat = 30.0
#!/bin/bash
find . -name '*.php' -type f | while read files
do
sedtest=$(sed -n '/^/,/$/p' "${files}" | sed -n '/<?php/p')
if [ "${sedtest}" ]
then
echo ${files}
@yitznewton
yitznewton / st_tng.md
Last active January 4, 2016 20:09
ST:TNG eps

Star Trek: The Next Generation episodes

  • inner light - flute probe
  • cause and effect - time loop, enterprise destroyed
  • first duty - cadets crash
  • the game
  • best of both worlds
  • yesterday's enterprise
  • parallels
  • timescape
@yitznewton
yitznewton / php-cs-fixer.sh
Created December 4, 2013 00:33
php-cs-fixer for BCBSMA
php-cs-fixer fix app/extensions/ --fixers=linefeed,trailing_spaces,unused_use,extra_empty_lines,elseif
[user]
name = yitznewton
email = [email protected]
[alias]
ci = commit
st = status
co = checkout
br = branch
pur = pull --rebase
subup = submodule update --init
@yitznewton
yitznewton / int_to_roman.rb
Created October 23, 2013 16:42
Integer to Roman. Assumes n >= 0
ROMANS = {
1 => "I",
4 => "IV",
5 => "V",
10 => "X",
40 => "XL",
50 => "L",
90 => "XC",
100 => "C",
400 => "CD",