Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃

Hugo Manrique hugmanrique

🙃
View GitHub Profile
@hugmanrique
hugmanrique / MapOrderer.java
Last active June 11, 2016 06:38
Method used to order a Map<K, V extends Comparable>. Asked by @MxJesusDiaz at Twitter
View MapOrderer.java
/**
* Orders a {@code Map<K, V>}
* @param map The {@link Map} that will be ordered (The value types must extend {@link Comparable})
* @param <K> The {@code K} value. Any type is supported
* @param <V> The {@code V} value. Must extend {@link Comparable}
* @return The sorted {@link Map} ordered by values with {@link Comparable#compareTo(Object)}
* @author Hugmanrique <contact@hugmanrique.me>
* @see {@link Collections#sort(List)} to order the values
*/
public static <K, V extends Sort.Comparable> Map<K, V> orderMapByValues(Map<K, V> map){
View keybase.md

Keybase proof

I hereby claim:

  • I am Hugmanrique on github.
  • I am hugmanrique (https://keybase.io/hugmanrique) on keybase.
  • I have a public key whose fingerprint is 2C46 1B04 D946 B422 80F3 95C1 78E9 8DD2 FA2B 9E20

To claim this, I am signing this object:

@hugmanrique
hugmanrique / Octicons with Handlebars.js
Last active October 2, 2016 15:27
Node.js script to render octicons with a Handlebars template custom helper
View Octicons with Handlebars.js
const handlebars = require('express-handlebars');
const express = require('express');
// Directory where your compiled octicons are,
// more info on this @ https://github.com/primer/octicons#usage
const octicons = require('/home/nodeassets/octicons/index.js');
function loadServer(){
// Load express here
var app = express();
@hugmanrique
hugmanrique / Gravity.java
Last active January 14, 2017 04:23
Apply gravity to your placed blocks in Minecraft
View Gravity.java
public class Gravity implements Listener {
private static final Vector GRAVITY = new Vector(0, -9.81F, 0);
private JavaPlugin plugin;
public Gravity(JavaPlugin plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@hugmanrique
hugmanrique / Cinematic.java
Last active January 14, 2017 04:40
Bukkit API to create smooth cinematics
View Cinematic.java
public class Cinematic {
private JavaPlugin plugin;
private World world;
private List<CinematicView> views;
public Cinematic(JavaPlugin plugin, List<CinematicView> views, World world) {
this.plugin = plugin;
this.views = views;
this.world = world;
View regionBlockspom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.hugmanrique</groupId>
<artifactId>regionblocks</artifactId>
<version>1.0.0</version>
@hugmanrique
hugmanrique / setting-the-node-env-variable.md
Last active June 30, 2018 22:46
How to setup the NODE_ENV variable
View setting-the-node-env-variable.md

NODE_ENV works like any other environment variable (e.g. PATH) and it depends on your platform how to set it:

  • Linux and OSX use the simple format NODE_ENV=production
  • Windows uses the SET NODE_ENV=production

You can explicitly set it before starting your npm run script by prepending the previous format:

package.json

{
@hugmanrique
hugmanrique / index.js
Last active July 1, 2018 20:18
Async Express middleware (for @exception)
View index.js
import http from 'http';
import express from 'express';
import testMiddleware from './middleware';
const app = express();
const server = http.createServer(app);
app.use(testMiddleware);
@hugmanrique
hugmanrique / InstanceofTest.java
Last active July 31, 2018 19:28
Instanceof tests for private project (shared with @theminecoder)
View InstanceofTest.java
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* @author Hugo Manrique
* @since 31/07/2018
*/
public class InstanceofTest extends PatchTest {
@hugmanrique
hugmanrique / detectMath.js
Created December 30, 2018 21:59
Next.js MathML feature detection + polyfill
View detectMath.js
import Router from 'next/router';
const namespaceURI = 'http://www.w3.org/1998/Math/MathML';
let supports = false;
let inserted = false;
function supportsMathML() {
const div = document.createElement('div');
div.innerHTML = '<math><mspace height="23px" width="77px" /></math>';