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
| # Author: Pieter Noordhuis | |
| # Description: Simple demo to showcase Redis PubSub with EventMachine | |
| # | |
| # Update 7 Oct 2010: | |
| # - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
| # the WebSocket protocol implementation in the cramp gem does not work | |
| # well with Chrome's (newer) WebSocket implementation. | |
| # | |
| # Requirements: | |
| # - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
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
| import http.client | |
| import json | |
| import time | |
| conn = http.client.HTTPSConnection('uinames.com', 443) | |
| def request(): | |
| conn.request('GET', '/api/') | |
| res = conn.getresponse() |
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
| const https = require('https'); | |
| const url = 'https://uinames.com/api/'; | |
| function request(url) { | |
| return new Promise((resolve, reject) => { | |
| let data = ''; | |
| https | |
| .get(url, (res) => { | |
| res.on('data', (chunk) => data += chunk); |
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
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "net/http" | |
| "sync" | |
| "time" | |
| ) |
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 buildGrid(nodeNum, nodeDists) { | |
| const grid = []; | |
| for (let i = 0; i < nodeNum; i++) { | |
| const row = []; | |
| for (let j = 0; j < nodeNum; j++) { | |
| if (j <= i + nodeDists[i] && j >= i - nodeDists[i]) { | |
| row[j] = i + nodeDists[i] <= nodeNum - 1 ? i + nodeDists[i] : nodeNum - 1; | |
| } else { | |
| row[j] = -1; | |
| } |
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 randomObject(level) { | |
| const obj = {}; | |
| for (let i = 97; i <= 110; i++) { | |
| const dice = Math.random(); | |
| const key = String.fromCharCode(i); | |
| if (dice < 0.33) { | |
| obj[key] = i; | |
| } else if (dice < 0.66) { | |
| obj[key] = () => {}; | |
| } else { |
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
| class Vertex: | |
| def __init__(self, name, email, adj = []): | |
| self.name = name | |
| self.email = email | |
| self.adj = adj | |
| self.marked = False | |
| def add_adj(self, v): | |
| if v not in self.adj: | |
| self.adj.append(v) |
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
| import java.util.*; | |
| public class MyClass { | |
| public static void main(String[] args) { | |
| User user = new User("Michael"); | |
| Robot robot = new Robot("Lisa"); | |
| ArrayList<Scorable> players = new ArrayList<Scorable>(); | |
| players.add(user); | |
| players.add(robot); |
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 Square({ value, style, onClick }) { | |
| return ( | |
| <button className="square" onClick={onClick} style={{background: style}}> | |
| {value} | |
| </button> | |
| ); | |
| } | |
| function Board({ squares, winner, onClick }) { | |
| function renderSquare(i) { |