Skip to content

Instantly share code, notes, and snippets.

View karlding's full-sized avatar
🤔

Karl Ding karlding

🤔
View GitHub Profile
@karlding
karlding / hipchat-hide-previews.user.js
Created July 22, 2015 01:29
Hide media previews (video and images) in the HipChat web client
// ==UserScript==
// @name HipChat Hide Media Previews
// @namespace github.com/karlding
// @version 0.1.0
// @description Hide Media Previews (video and images) in the HipChat web client
// @author Karl Ding
// @match https://*.hipchat.com/chat/*
// @license MIT
// ==/UserScript==
@karlding
karlding / DisableNarrator.reg
Created September 25, 2015 16:13
Prevent Narrator (and Windows Assistive Technology Manager) From Starting
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Narrator.exe]
"Debugger"="%1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\AtBroker.exe]
"Debugger"="%1"
@karlding
karlding / reddit-legacy-search.user.js
Created September 30, 2015 06:00
Force reddit to use the Legacy Search mode (by adding the feature=legacy_search URI parameter) to reddit searches.
// ==UserScript==
// @name reddit Legacy Search
// @namespace http://github.com/karlding
// @version 0.1
// @description Force the Legacy Search mode by adding the `feature=legacy_search` URI parameter to reddit searches
// @author Karl Ding
// @match *://*.reddit.com/*
// @grant none
// ==/UserScript==
@karlding
karlding / xkcd-enhancements.user.js
Last active October 22, 2015 21:27
Allows you to use arrow keys to navigate on XKCD
// ==UserScript==
// @name XKCD Arrow Keys
// @namespace http://github.com/karlding
// @version 0.1
// @description Allows you to use arrow keys to navigate on XKCD
// @author Karl Ding
// @match http*://xkcd.com/*
// @grant none
// ==/UserScript==
#include <stdint.h>
#include <stdbool.h>
int main() {
union {
struct {
bool bit0 : 1;
bool bit1 : 1;
bool bit2 : 1;
bool bit3 : 1;
@karlding
karlding / Makefile
Created November 29, 2015 04:58
generic annotated Makefile
# set the compiler name
CXX = g++
# set the compiler flags
# Wall: show all warnings
# MMD: create dependency files
# g: compile binaries with debugging info
CXXFLAGS = -Wall -MMD -g
# object files
@karlding
karlding / disable-narrator.reg
Created January 14, 2016 19:05
Disable Narrator
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Narrator.exe]
"Debugger"="%1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\AtBroker.exe]
"Debugger"="%1"
@karlding
karlding / zigzagarray.cc
Created January 22, 2016 22:39
Because I'm silly and tried to use std::swap and make some "smart" optimizations without thinking on a HackerRank problem :(
// print out array in zigzag format
// time: O(n log n) = O(n log n) + O(n log n) + O(n)
// space: O(3n)
std::vector<int> zigZagArray(std::vector<int> intArray) {
std::vector<int> v(intArray);
// sort descending order
std::sort(intArray.rbegin(), intArray.rend());
// sort asc
std::sort(v.begin(), v.end());
@karlding
karlding / stackitup.cc
Created January 22, 2016 22:59
Stacks on stacks (implement a program that reads in push, pop, and inc operations, output the top of the stack at the end of each operation, prevent errors)
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
int main() {
string s;
stack<int> st;
while (cin >> s) {
int i;
@karlding
karlding / mips.h
Created February 7, 2016 05:21
Register map for the subset of MIPS used in CS 241
// register map
#define ADD 0x20
#define SUB 0x22
#define MULT 0x18
#define MULTU 0x19
#define DIV 0x1a
#define DIVU 0x1b
#define MFHI 0x10
#define MFLO 0x12
#define LIS 0x14