Skip to content

Instantly share code, notes, and snippets.

View SitanHuang's full-sized avatar

Sitan SitanHuang

  • Vanderbilt University
  • Nashville, TN / Las Vegas, NV
View GitHub Profile
@SitanHuang
SitanHuang / typeracer.hack.js
Last active April 1, 2024 05:26
Typeracer 100% hack (Version 2 - Aadaptive Mode - Types at minimum speed required to win)
function triggerKeyboardEvent(el, keyCode, type)
{
var eventObj = document.createEventObject ?
document.createEventObject() : document.createEvent("Events");
if(eventObj.initEvent){
eventObj.initEvent(type, true, true);
}
eventObj.keyCode = keyCode;
@SitanHuang
SitanHuang / .rb
Created June 9, 2018 21:22
Ruby Pagination Algorithm HTML Generator
module PaginationHelper
def paginate(current, max, template, delta: 2)
left = current - delta
right = current + delta + 1
range = []
range_with_dots = []
l = nil
max.times do |_i|
i = _i + 1
if i == 1 || i == max || i >= left && i < right
@Mariovc
Mariovc / ImagePicker.java
Last active February 7, 2024 23:33
Utility for picking an image from Gallery/Camera with Android Intents
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@bertvv
bertvv / pandoc.Makefile
Last active November 24, 2022 08:55
Makefile for Markdown -> PDF using pandoc
# Generate PDFs from the Markdown source files
#
# In order to use this makefile, you need some tools:
# - GNU make
# - Pandoc
# - LuaLaTeX
# - DejaVu Sans fonts
# Directory containing source (Markdown) files
source := src