Skip to content

Instantly share code, notes, and snippets.

@homolumo
homolumo / lodash.hpp
Created February 5, 2020 02:14 — forked from quark-zju/lodash.hpp
Little C++ header inspired by Ruby and Lo-dash
// compile with -std=c++1y
#include <algorithm>
#include <functional>
#include <iterator>
#include <vector>
namespace LoDash {
using std::begin;
@homolumo
homolumo / install-oracle-jdk-centos.md
Last active March 7, 2018 03:34 — forked from skanjo/install-oracle-jdk-centos.md
Install Oracle JDK on CentOS

Install Oracle Java 8 JDK

Note: If you would like to install a different release of Oracle Java 8 JDK, go to the Oracle Java 8 JDK Downloads Page, accept the license agreement, and copy the download link of the appropriate Linux .rpm package. Substitute the copied download link in place of the highlighted part of the wget command.

Change to your home directory and download the Oracle Java 8 JDK RPM with these commands:

cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-x64.rpm"

Then install the RPM with this yum command (if you downloaded a different release, substitute the filename here):

#!/bin/bash
# Copyright 2017 Théo Chamley
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
@homolumo
homolumo / line-intersect.js
Created February 23, 2017 06:47
计算两条线段是否交叉
let det = function(x1, x2, y1, y2) // 行列式
{
return (x1*y2-x2*y1);
}
let intersect = function(p1, p2, p3, p4)
{
const delta = det(p2[0]-p1[0], p3[0]-p4[0], p2[1]-p1[1], p3[1]-p4[1]);
if ( Math.abs(delta) <= 1e-6 ) return false;