This is a fairly common question, and there isn't a One True Answer.
These are the most common techniques:
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <title>Canvas Hexagonal Map</title> | |
| <style type="text/css"> | |
| canvas { | |
| border:0; | |
| display:block; | |
| margin:0 auto; |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
| license: gpl-3.0 |
| @echo off | |
| :: Path to Sublime Text installation dir. | |
| SET stPath=%~dp0sublime_text.exe | |
| SET stPathOnly=%~dp0 | |
| :: Key name for the registry entries. | |
| SET UserEntry=Sublime Text | |
| SET AdminEntry=Sublime Text As Admin | |
| :: Context menu texts. | |
| SET "UserMenuText=Open with Sublime(&-)" | |
| SET "AdminMenuText=Open with Sublime As Admin(&+)" |
| # We use the global settings as a shortcut to define our own separator. | |
| # Based on the default i3blocks config file. | |
| full_text=〉 | |
| align=center | |
| color=#666666 | |
| separator=false | |
| separator_block_width=7 | |
| [volume] | |
| command=/usr/libexec/i3blocks/volume |
| // Fast and easy way to combine (additive mode) two RGBA colors with JavaScript. | |
| // [red, green, blue, alpha] based on these maximul values [255, 255, 255, 1]. | |
| var base = [69, 109, 160, 1]; | |
| var added = [61, 47, 82, 0.8]; | |
| var mix = []; | |
| mix[3] = 1 - (1 - added[3]) * (1 - base[3]); // alpha | |
| mix[0] = Math.round((added[0] * added[3] / mix[3]) + (base[0] * base[3] * (1 - added[3]) / mix[3])); // red | |
| mix[1] = Math.round((added[1] * added[3] / mix[3]) + (base[1] * base[3] * (1 - added[3]) / mix[3])); // green | |
| mix[2] = Math.round((added[2] * added[3] / mix[3]) + (base[2] * base[3] * (1 - added[3]) / mix[3])); // blue |
| function mapValues(obj, fn) { | |
| return Object.keys(obj).reduce((result, key) => { | |
| result[key] = fn(obj[key], key); | |
| return result; | |
| }, {}); | |
| } | |
| function pick(obj, fn) { | |
| return Object.keys(obj).reduce((result, key) => { | |
| if (fn(obj[key])) { |
| // sending to sender-client only | |
| socket.emit('message', "this is a test"); | |
| // sending to all clients, include sender | |
| io.emit('message', "this is a test"); | |
| // sending to all clients except sender | |
| socket.broadcast.emit('message', "this is a test"); | |
| // sending to all clients in 'game' room(channel) except sender |
| from discord.ext import commands | |
| description = '''An example bot to showcase the discord.ext.commands extension | |
| module. | |
| There are a number of utility commands being showcased here.''' | |
| # this specifies what extensions to load when the bot starts up | |
| startup_extensions = ["members", "rng"] |