This file contains 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
/** | |
* USB HID Keyboard scan codes as per USB spec 1.11 | |
* plus some additional codes | |
* | |
* Created by MightyPork, 2016 | |
* Public domain | |
* | |
* Adapted from: | |
* https://source.android.com/devices/input/keyboard-devices.html | |
*/ |
This file contains 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
use serde::ser::SerializeMap; | |
use serde::{Serialize, Serializer, de::Visitor, de::MapAccess, Deserialize, Deserializer}; | |
use std::fmt; | |
#[derive(Debug)] | |
struct Custom(String, u32); | |
impl Serialize for Custom { | |
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> | |
where |
This file contains 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
/** | |
* Decode URL-encoded string in place. | |
*/ | |
void urldecode(char *str) | |
{ | |
unsigned int x; | |
for (int i = 0; str[i] != 0; i++) { | |
char c = str[i]; | |
if (c == '+') { |
This file contains 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
#include <stdint.h> | |
/** | |
* Encode a code point using UTF-8 | |
* | |
* @author Ondřej Hruška <ondra@ondrovo.com> | |
* @license MIT | |
* | |
* @param out - output buffer (min 5 characters), will be 0-terminated | |
* @param utf - code point 0-0x10FFFF |
This file contains 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
<?php | |
$table = [ | |
["Hydrogen", "H", "1", "1.00794", "0.0708 (@ -253°C)", "14.01", "20.28", "79", "32", "154 (-1e)", "14.1", "14.267 (H-H)", "0.117 (H-H)", "0.904 (H-H)", "0.1815", "110.00", "2.20", "1311.3", "1, -1", "1s<sup>1</sup>", "HEX", "3.750", "1.731", "Colorless, odorless, tasteless gas", "1766 (England)", "Henry Cavendish", "Greek: hydro (water) and genes (generate)", 1, 1, 0x7FFFFFFF, 0xAAAA, 0xFFFF, 0xAAAA], | |
["Helium", "He", "2", "4.002602", "0.147 (@ -270°C)", "0.95", "4.216", "0.0", "n/a", "93", "31.8", "5.188", "n/a", "0.08", "0.152", "n/a", "n/a", "2361.3", "n/a", "1s<sup>2</sup>", "HEX", "3.570", "1.633", "Inert, colorless, odorless, tasteless gas", "1895 (Scotland/Sweden)", "Sir William Ramsey, Nils Langet, P.T.Cleve", "Greek: helios (sun).", 18, 1, 0x7FFFFFFF, 0xC000, 0x7000, 0x0], | |
["Lithium", "Li", "3", "6.941", "0.534", "553.69", "1118.15", "155", "163", "68 (+1e)", "13.1", "3.489", "2.89", "148", "84.8", "400.00", "0.98", "519.9", "1", "[He] 2s<sup>1</sup>", "BCC", "3.490", "n/a", "So |
This file contains 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 low_rgb = [ | |
'#000000', '#800000', '#008000', '#808000', '#000080', '#800080', '#008080', '#c0c0c0', | |
'#808080', '#ff0000', '#00ff00', '#ffff00', '#0000ff', '#ff00ff', '#00ffff', '#ffffff' | |
] | |
function ansi_rgb(ansi) { | |
if (ansi < 0 || ansi > 255) return '#000' | |
if (ansi < 16) return low_rgb[ansi] | |
if (ansi > 231) { |
This file contains 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
Dec Hex Char Dec Hex Char Dec Hex Char Dec Hex Char | |
-------------- -------------- -------------- -------------- | |
0 00h NUL (null) 32 20h SP 64 40h @ 96 60h ` | |
1 01h SOH (start of heading) 33 21h ! 65 41h A 97 61h a | |
2 02h STX (start of text) 34 22h " 66 42h B 98 62h b | |
3 03h ETX (end of text) 35 23h # 67 43h C 99 63h c | |
4 04h EOT (end of transmission) 36 24h $ 68 44h D 100 64h d | |
5 05h ENQ (enquiry) 37 25h % 69 45h E 101 65h e | |
6 06h ACK (acknowledge) 38 26h & 70 46h F 102 66h f | |
7 07h BEL (bell) 39 27h ' 71 47h G 103 67h g |
This file contains 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
use std::io; | |
use std::io::Write; | |
fn fibo(n:u32) -> u32 { | |
if n <= 2 { | |
1 | |
} else { | |
let mut prev1 = 1; | |
let mut prev2 = 1; | |
for _n in 2..n { |
This file contains 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
----- NEW GAME ----- | |
Secret animal is: duck | |
What animal is it? | |
> duck | |
Game ended. | |
----- NEW GAME ----- | |
Secret animal is: dog | |
Is it a duck? | |
> no |
This file contains 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
/** | |
* Weekday calculation utils. | |
* | |
* Month and weekday are 1-based, 1 is Monday. | |
* The enums may be replaced by ints at the expense of clarity. | |
* | |
* Released to the public domain | |
*/ | |
#include <stdint.h> |
NewerOlder