Skip to content

Instantly share code, notes, and snippets.

View spencergritton's full-sized avatar

Spencer Gritton spencergritton

  • San Diego, CA
View GitHub Profile
@Zyndoras
Zyndoras / rotate.js
Last active April 29, 2024 11:41
Rotate base64 image (Javascript)
function rotate(srcBase64, degrees, callback) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const image = new Image();
image.onload = function () {
canvas.width = degrees % 180 === 0 ? image.width : image.height;
canvas.height = degrees % 180 === 0 ? image.height : image.width;
ctx.translate(canvas.width / 2, canvas.height / 2);
@RealDeanZhao
RealDeanZhao / parse-inputstream-to-jsonobject.md
Created April 10, 2017 06:00
Parse InputStream to JsonObject
JsonObject json;
  try {
    JsonElement element = new JsonParser().parse(
    new InputStreamReader(responseEntity.getBody().getInputStream())
  );
  json = element.getAsJsonObject();
} catch (IOException e) {
  throw new RuntimeException(e.getLocalizedMessage());
}