Skip to content

Instantly share code, notes, and snippets.

View vivitsu's full-sized avatar

Vivitsu Maharaja vivitsu

  • Amazon Web Services
  • Seattle, WA
  • X @vivitsum
View GitHub Profile
@vivitsu
vivitsu / ducky.md
Created August 16, 2020 02:58 — forked from schmich/ducky.md
Programming media keys on the Ducky One 2 Skyline

Programming Media Keys on the Ducky One 2 Skyline

To use media keys on the Ducky One 2 Skyline, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.

Example

Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.

As an example, to bind Fn+PgUp to the play/pause media function:

public class LineReader {
private final int PAGE_SIZE = 4;
// 'E' is EOF character
//private char[] data = {'a', 'z', '\n', 'd', '\n', 'c', 'f', 'e', 'E'};
private char[] data = {'a', 'z', 'd', '\n', 'c', 'f', 'e', 'b', 'r', 't', 'c', '\n', 'E'};
private int dataCursor = 0;
private char[] buffer = new char[PAGE_SIZE];
private int cursor;
private boolean EOF_REACHED = false;
# The Alerter is a simple monitoring tool, intended to help detect increases in response time for some process. It does that
# by computing a few statistics about the process across a 'window' of a certain number of runs, and alerting (returning true)
# if certain thresholds are met.
# It takes the following parameters:
# - inputs: A list of integer times for the process. This list may be very long
# - window size: how many runs long a window is, as an integer
# - allowedIncrease: how far over 'average' a window or value is allowed to be, as a percent. This is represented as a decimal value based on one, so a 50% allowable increase would be represented as 1.5
# Your Alerter should return true if either of the following conditions are met:
// See https://twitter.com/rygorous/status/1003837996515278848
#include <stdio.h>
#include <stdlib.h>
#define MAX_FACTOR 10
int tab[2 * MAX_FACTOR];
/*
* Proof for how this code works:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
int calc_num_digits(int num) {
int num_digits = 0;
while (num != 0) {
num = num / 10;
public class MinStops {
private static int initStop;
private static int endStop;
private static int numStops = 1;
private static boolean isPowerOfTwo(int n) {
return (n > 0) && ((n & (n - 1)) == 0);
}

Keybase proof

I hereby claim:

  • I am vivitsu on github.
  • I am vbm (https://keybase.io/vbm) on keybase.
  • I have a public key whose fingerprint is AD0E 4A46 756F EBBA F1DC FE3A 12A4 FCFD 6D40 3DB9

To claim this, I am signing this object:

public int singleNumber(int[] A) {
int num = 0;
for (int i = 0; i < A.length; i++) {
num ^= A[i];
}
return num;
}
public int singleNumber(int[] A) {
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < A.length; i++) {
if (map.containsKey(A[i])) {
map.put(A[i], map.get(A[i]) + 1);
} else {
map.put(A[i], 1);
}
#include<stdlib.h>
#include<stdio.h>
int is_power_of_two(int a) {
if (a < 0)
return -1;
int count = 0;