Skip to content

Instantly share code, notes, and snippets.

View jbenner-radham's full-sized avatar

James Benner jbenner-radham

View GitHub Profile
@hrishikeshs
hrishikeshs / object-diff.js
Last active January 11, 2020 00:07
diff two objects and return values/path which are different, null if there is no diff.
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);
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
@jmigueprieto
jmigueprieto / amqp_send_json_message.groovy
Created January 10, 2020 21:18
Groovy Script to send a JSON message to a Rabbitmq broker
@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()
@takehiko
takehiko / foureights.rb
Last active January 11, 2020 01:28
Four-8 Puzzle
#!/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"]
@rust-play
rust-play / playground.rs
Created January 10, 2020 21:17
Code shared from the Rust Playground
use core::future::Future;
async fn foo() -> u64 {
10
}
async fn bar(x: impl Future<Output = u64>) {
println!("{}", x.await);
}
@rust-play
rust-play / playground.rs
Created January 10, 2020 21:13
Code shared from the Rust Playground
use std::fs;
fn main() {
let paths = fs::read_dir("./").unwrap();
for path in paths {
println!("Name: {}", path.unwrap().path().display())
}
}
@vvbaby1122
vvbaby1122 / PY0101EN-3-3-Functions.ipynb
Created January 10, 2020 21:13
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rust-play
rust-play / playground.rs
Created January 10, 2020 21:11
Code shared from the Rust Playground
// [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]
@natanro-zz
natanro-zz / arrayManipulation.cpp
Created January 10, 2020 21:09
Array Manipulation -- Hackerrank
/** \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]
@rust-play
rust-play / playground.rs
Created January 10, 2020 21:00
Code shared from the Rust Playground
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> {