This file contains hidden or 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 http = require("http"), | |
| url = require("url"), | |
| path = require("path"), | |
| fs = require("fs") | |
| port = process.argv[2] || 8888; | |
| http.createServer(function(request, response) { | |
| var uri = url.parse(request.url).pathname | |
| , filename = path.join(process.cwd(), uri); |
This file contains hidden or 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 util = require('util'), | |
| http = require('http'), | |
| events = require('events'); | |
| var Twitter = function(opts) { | |
| this.username = opts.username; | |
| this.password = opts.password; | |
| this.track = opts.track; | |
| this.data = ''; | |
| }; |
This file contains hidden or 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 events = require('events') | |
| ,util = require('util') | |
| ,_ = require('underscore') | |
| ,http = require('http') | |
| function StreamConsumer(options){ | |
| events.EventEmitter.call(this); | |
| this.reEot = /.+\r\n/gm; | |
| this.req = null; |
This file contains hidden or 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
| LINK_DETECTION_REGEX = /(([a-z]+:\/\/)?(([a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(\s+|$)/gi | |
| EMOJI_DIRECTORY = "/path/to/assets/emoji/20x20" | |
| # Handlebars is presumed, but you could swap out | |
| ESCAPE_EXPRESSION_FUNCTION = Handlebars.Utils.escapeExpression | |
| MARKSAFE_FUNCTION = (str) -> new Handlebars.SafeString(str) | |
| # Emoji unicode chars become images. |
This file contains hidden or 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-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); | |
| }); |
This file contains hidden or 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 page = require('webpage').create(); | |
| page.open('http://twitter.com/ID_AA_Carmack', function (status) { | |
| if (status !== 'success') { | |
| console.log('Unable to access network'); | |
| } else { | |
| var hitRockBottom = false; | |
| while (!hitRockBottom) { | |
| //scroll the page (not sure if this is the best way to do so...) |
This file contains hidden or 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
| # Show message box popup. | |
| Add-Type -AssemblyName System.Windows.Forms | |
| $result = [System.Windows.Forms.MessageBox]::Show("My message", "Window Title", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::None) | |
| # Show input box popup. | |
| Add-Type -AssemblyName Microsoft.VisualBasic | |
| $inputText = [Microsoft.VisualBasic.Interaction]::InputBox("Enter some value:", "Window Title", "Default value") | |
| # Show an Open File Dialog and return the file selected by the user. | |
| function Read-OpenFileDialog([string]$InitialDirectory, [switch]$AllowMultiSelect) |
This file contains hidden or 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
| $(function(){ | |
| var socket = io.connect('http://localhost:8080'); | |
| socket.on('tweet', function(tweet) { | |
| $('body').append('<div class="tweet">' + tweet.text + '</div>'); | |
| }); | |
| }); |
This file contains hidden or 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
| fabric.SVGText = fabric.util.createClass(fabric.Object, { | |
| type :'text-block', | |
| text :'', | |
| fontSize :14, | |
| color :undefined, | |
| lineColors :undefined, | |
| selectedLine:0, | |
| realWidth :0, | |
| realHeight :0, |
This file contains hidden or 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
| $Hso = New-Object Net.HttpListener | |
| $Hso.Prefixes.Add("http://+:8000/") | |
| $Hso.Start() | |
| While ($Hso.IsListening) { | |
| $HC = $Hso.GetContext() | |
| $HRes = $HC.Response | |
| $HRes.Headers.Add("Content-Type","text/plain") | |
| $Buf = [Text.Encoding]::UTF8.GetBytes((GC (Join-Path $Pwd ($HC.Request).RawUrl))) | |
| $HRes.ContentLength64 = $Buf.Length | |
| $HRes.OutputStream.Write($Buf,0,$Buf.Length) |
OlderNewer