Skip to content

Instantly share code, notes, and snippets.

View hugmanrique's full-sized avatar

Hugo Manrique hugmanrique

View GitHub Profile
@WesJD
WesJD / RandomTeleporter.java
Created August 3, 2016 03:27
Teleport players to random locations with efficiency from Guava
public class RandomTeleporter {
private final LoadingCache<Pair<Location, Location>, List<Pair<Integer, Integer>>> locationCache = CacheBuilder.newBuilder()
.expireAfterAccess(1, TimeUnit.MINUTES)
.maximumSize(5)
.build(new CacheLoader<Pair<Location, Location>, List<Pair<Integer, Integer>>>() {
@Override
public List<Pair<Integer, Integer>> load(Pair<Location, Location> bounds) throws Exception {
final List<Pair<Integer, Integer>> ret = new ArrayList<>();
final Location bounds1 = bounds.getLeft();
@DarkSeraphim
DarkSeraphim / VectorRotation.java
Created October 13, 2015 17:49
Vector rotation utility
private static Vector rotateZ(Vector v, double rot)
{
return new Vector(v.getX() * Math.cos(rot) - v.getY() * Math.sin(rot),
v.getX() * Math.sin(rot) + v.getY() * Math.cos(rot),
v.getZ());
}
private static Vector rotateY(Vector v, double rot)
{
return new Vector( v.getX() * Math.cos(rot) + v.getZ() * Math.sin(rot),
@yocontra
yocontra / flux.css
Created December 12, 2014 21:38
flux.css
html {
filter: brightness(0.8) sepia(0.9);
-o-filter: brightness(0.8) sepia(0.9);
-ms-filter: brightness(0.8) sepia(0.9);
-moz-filter: brightness(0.8) sepia(0.9);
-webkit-filter: brightness(0.8) sepia(0.9);
-salesforce-filter: brightness(0.8) sepia(0.9);
-dropbox-filter: brightness(0.8) sepia(0.9);
-blink-filter: brightness(0.8) sepia(0.9);
@ryansully
ryansully / optimize.sh
Created February 1, 2012 23:56 — forked from realdeprez/optimize.sh
image optimization script (pngcrush & jpegtran)
#!/bin/sh
# script for optimizing images in a directory (recursive)
# pngcrush & jpegtran settings from:
# http://developer.yahoo.com/performance/rules.html#opt_images
# pngcrush
for png in `find $1 -iname "*.png"`; do
echo "crushing $png ..."
pngcrush -rem alla -reduce -brute "$png" temp.png
@riaqn
riaqn / ResultSetAdapter.java
Created April 3, 2015 13:20
a Gson adapter to convert ResultSet to Json(writer only)
import java.io.*;
import java.sql.*;
import com.google.gson.*;
import com.google.gson.stream.*;
public class ResultSetAdapter extends TypeAdapter<ResultSet> {
public static class NotImplemented extends RuntimeException {}
private static final Gson gson = new Gson();
public ResultSet read(JsonReader reader)
throws IOException {
@mrdaemon
mrdaemon / forums.sql
Created December 8, 2011 03:43
A simple MySQL schema for some sort of forums
/* Database Schema for simple Forums
* Author: Dee the great amateur RDBS wizard
* 07 Dec 2011 - Initial Version
*/
/* NOTE: You may want to alter this according to this setup,
* especially if you are not running the script as root and
* just need the tables.
*/
@tylerneylon
tylerneylon / .block
Last active September 2, 2023 14:21
Quick js code to draw math functions in an SVG element.
license: mit
if(!(Get-Command git -ErrorAction SilentlyContinue)) {
$gitDir = "$env:LOCALAPPDATA\CustomGit"
if(Test-Path $gitDir) { Remove-Item -Path $gitDir -Recurse -Force }
New-Item -Path $gitDir -ItemType Directory
$gitLatestReleaseApi = (Invoke-WebRequest -UseBasicParsing https://api.github.com/repos/git-for-windows/git/releases/latest).Content | ConvertFrom-Json
$mingitObject = $gitLatestReleaseApi.assets `
| Where-Object {$_.name -match "MinGit-[\d.]*?-64-bit.zip"} `
| Select-Object browser_download_url
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active March 15, 2024 11:26
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@PurpleBooth
PurpleBooth / README-Template.md
Last active April 22, 2024 11:45
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites