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 diffObjects(x, y) { | |
if (x === y) return null; | |
if (x !== x) return y !== y ? null : y; | |
if (typeof x !== typeof y) return y; | |
if (typeof x !== 'object') return y; | |
var typeX = getType(x); | |
var typeY = getType(y); | |
if (typeX !== typeY) return y; | |
if (typeX === 'date' ) return +x === +y ? null : y; | |
if (typeX === 'array' ) return deepDiffArray(x, y); |
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
ENV CA_PATH="/etc/pki/ssl/ca" | |
RUN mkdir -p ${CA_PATH} | |
RUN curl -s -L "http://curl.haxx.se/ca/cacert.pem" -o "${CA_PATH}/mozilla.pem" | |
RUN openssl s_client -connect github.com:443 -CAfile ${CA_PATH}/mozilla.pem > ${CA_PATH}/github.pem | |
RUN curl --cacert ${CA_PATH}/github.pem -L -v https://github.com |
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
@Grab(group = 'com.fasterxml.jackson.core', module = 'jackson-databind', version = '2.10.1') | |
@Grab(group = 'org.springframework.boot', module = 'spring-boot-starter-amqp', version = '2.2.2.RELEASE') | |
import org.springframework.amqp.rabbit.core.RabbitTemplate | |
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory | |
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter | |
def cf = new CachingConnectionFactory(new URI('amqp://guest:guest@localhost:5672')) | |
def template = new RabbitTemplate(cf) | |
template.messageConverter = new Jackson2JsonMessageConverter() |
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 | |
# foureights.rb : "8-((8+8)/8)" Puzzle | |
# by takehikom | |
# see also: https://takehikom.hateblo.jp/entry/2020/01/11/062120 | |
# 環境変数LANGの値がja_JP.UTF-8などのときは, | |
# 日本語文字で出力する(実行時オプションで変更可能) | |
$option_zenkaku = /jp/i === ENV["LANG"] |
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
use core::future::Future; | |
async fn foo() -> u64 { | |
10 | |
} | |
async fn bar(x: impl Future<Output = u64>) { | |
println!("{}", x.await); | |
} |
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
use std::fs; | |
fn main() { | |
let paths = fs::read_dir("./").unwrap(); | |
for path in paths { | |
println!("Name: {}", path.unwrap().path().display()) | |
} | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
// [email protected] | |
fn error() -> ! { | |
eprintln!("modexp: usage: modexp <x> <y> <m> where x, y are nonnegative, m is positive, and all less than 2^32"); | |
// NB this does not trigger a panic | |
std::process::exit(1); | |
} | |
#[test] |
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
/** \brief queries to sum a given number K in subintervals and returning the maximum number in the array | |
Strategy: given i, j and K, the first and last number of the interval, included, and the number | |
to be summed, it is smarter just to sum the first position of the subinterval | |
v[i] += K | |
and the next position in the vector, if any, decreses in K to indicate that all the numbers onwards | |
will be subtracted by K. | |
In a nutshell, the i-th position in the vector, its value is calculated as follows: | |
v[i] = v[1] + v[2] + ... + v[i-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
use futures::Stream; | |
use futures::task::{Context, Poll}; | |
use std::pin::Pin; | |
use pin_project::pin_project; | |
// ------------------------------------ | |
// Stream uses pin_project | |
#[pin_project] | |
pub struct StreamPinProject<S> { |