Skip to content

Instantly share code, notes, and snippets.

View jbenner-radham's full-sized avatar

James Benner jbenner-radham

View GitHub Profile
{
const compose = (...fns) => (val) => fns.reduceRight((x, fn) => fn(x), val);
const sum = (result, item) => result + item;
const mult = (a, b) => a * b;
function wrap(xf){
return {
// 1. We require init as arg, so do not need here
init: function(){
throw new Error('init not supported');
@zjplab
zjplab / comparator_map.cpp
Created January 10, 2020 21:35
C++ Comparator(Custom comparison ops)
struct cmpByStringLength {
bool operator()(const std::string& a, const std::string& b) const {
return a.length() < b.length();
}
};
// ...
std::map<std::string, std::string, cmpByStringLength> myMap;
pub fn on_pointer(&mut self, state: &mut ApplicationState, position: Point2<f32>) {
let projection_matrix = create_projection_matrix(self.last_size);
let projection_inverse = projection_matrix.try_inverse().unwrap();
// Transform the window position to a 3D ray from the camera
let ray_clip = Vector3::new(
(2.0 * position.x) / self.last_size.x as f32 - 1.0,
(2.0 * position.y) / self.last_size.y as f32 - 1.0,
// Remember, inverse Z
@broskees
broskees / nocache.php
Last active January 10, 2020 22:35
A quick catch-all cache-busting WordPress plugin when having clients clear their browser cache isn't an option.
<?
/**
* Plugin Name: WordPress Catch All Cache Buster
* Description: A quick catch-all cache-busting WordPress plugin when having clients clear their browser cache isn't an option.
* Version: 1.0.0
* Author: Joseph Roberts
* Author URI: https://github.com/DigitalJoeCo
* License: MIT
* License URI: http://opensource.org/licenses/MIT
*/
@gautam678
gautam678 / .hyper.js
Last active January 10, 2020 22:35
My Hyper configuration for MacOS Catalina
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Upload Hyper to github sync settings
syncSettings: {
quiet: false,
accelerators: {
@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);
}