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
| let url = URL(string: "https://postman-echo.com/time/valid?timestamp=2016-10-10")! | |
| struct PostmanResponse: Decodable { | |
| let valid: Bool | |
| } | |
| enum ApiError: Error { | |
| case invalidServerResponse | |
| } |
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 UIKit | |
| let url = URL(string: "http://127.0.0.1:1234")! | |
| var request = URLRequest(url: url) | |
| request.setValue("application/json", forHTTPHeaderField: "Content-Type") | |
| request.setValue("you-value-goes-here", forHTTPHeaderField: "X-API-KEY") | |
| let task = URLSession.shared.dataTask(with: request) { data, _, error in | |
| if let data = 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
| package ratelimit | |
| import ( | |
| "context" | |
| "net/http" | |
| "time" | |
| "golang.org/x/time/rate" | |
| ) |
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
| local ls = require "luasnip" | |
| local s = ls.snippet | |
| local i = ls.insert_node | |
| local t = ls.text_node | |
| local f = ls.function_node | |
| local function copyname(args) | |
| return args[1] | |
| end |
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 ( | |
| "log" | |
| "net/http" | |
| "sync/atomic" | |
| "time" | |
| ) | |
| var isBusy int32 |
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
| #include <stdio.h> | |
| #define version __STDC_VERSION__ | |
| int | |
| main (int argc, char *argv[]) | |
| { | |
| printf ("Your c version is: %ld\n", version); | |
| return 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
| function toHex(bArr) { | |
| var result = ""; | |
| for (var i = 0; i < bArr.length; i++) { | |
| let dec = bArr[i] & 0xff; | |
| var hex = Java.use("java.lang.Integer").toHexString(dec); | |
| if (hex.length % 2 == 1) { | |
| hex = "0" + hex; | |
| } | |
| result += hex; | |
| } |
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
| from cv2 import cv2 | |
| foo = cv2.imread("./foo.png") | |
| bar = cv2.imread("./bar.png") | |
| key = cv2.bitwise_xor(foo, bar) | |
| cv2.imshow("xored data", key) | |
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 wildignore+=*.pyc | |
| set guicursor= | |
| set relativenumber | |
| set nohlsearch | |
| set hidden | |
| set noerrorbells | |
| set tabstop=4 softtabstop=4 | |
| set shiftwidth=4 |
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 array1 = ["A", "B", "C"]; | |
| const array2 = ["1", "2", "3"]; | |
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce | |
| // acc is the Accumulator for our result, it starts with [] | |
| // for each element in array 1, we will use the add operator when `map` with each element in array 2. | |
| const result = array1.reduce( | |
| (acc, v) => [...acc, ...array2.map((x) => v + x)], |