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
| #!/usr/bin/env ruby | |
| @parts = '' | |
| (0...100).each { |i| @parts += ',' + (i + 1).to_s } | |
| def mark(n, label) | |
| @parts.gsub! /((,\w+){#{n - 1}})(,\w+)/, "\\1,#{label}" | |
| end | |
| mark 3, 'Fizz' |
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 ( | |
| "fmt" | |
| "regexp" | |
| "strconv" | |
| "strings" | |
| ) | |
| func main() { |
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 dct | |
| import "math" | |
| func DCT(width int, height int, values []float64) (result []float64) { | |
| doubleWidth := 2.0 * float64(width) | |
| doubleHeight := 2.0 * float64(height) | |
| result = make([]float64, len(values)) |
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.HashMap; | |
| import java.util.Map; | |
| public class SymbolicLock | |
| { | |
| private final Map<String, LockEntry> lockEntries = new HashMap<String, LockEntry>(); | |
| public void synchronised(String key, Runnable runnable) | |
| { |
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 stream = /* Some System.IO.Stream */ | |
| using (var contentSource = new ChunkedStreamSerialiser(stream)) { | |
| var response = new HttpResponse(HttpStatuses.OK, "OK"); | |
| response.Headers.Set("Content-Type", "application/octet-stream"); | |
| response.Body = contentSource; | |
| /* Do something with the response ... */ | |
| } |
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 content = Encoding.UTF8.GetBytes("Hello, World!"); | |
| using (var contentSource = new ByteArraySource(content)) { | |
| var response = new HttpResponse(HttpStatuses.OK, "OK"); | |
| response.Headers.Set("Content-Type", "text/plain"); | |
| response.Body = contentSource; | |
| /* Do something with the response ... */ | |
| } |
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
| using System.Text; | |
| using System.Threading; | |
| using Naucera.Io.Http; | |
| using Naucera.Net.Http; | |
| public class HttpListenerExample | |
| { | |
| public static void Main(string[] args) | |
| { | |
| using (var listener = new HttpListener(8080, HandleRequest)) { |