Skip to content

Instantly share code, notes, and snippets.

View Jerrylum's full-sized avatar
👀
Given enough eyeballs, all bugs are shallow.

Jerry Lum Jerrylum

👀
Given enough eyeballs, all bugs are shallow.
  • Hong Kong Joint School Technology Education Association
  • Hong Kong
  • 17:36 (UTC +08:00)
  • X @jerrylum10
View GitHub Profile
@Jerrylum
Jerrylum / initialize.cpp
Last active June 12, 2019 19:52
PROS, auton selector with LLEMU
//
// Copyright (c) 2018 by CMASS Robotics team. All Rights Reserved.
//
#include "main.h"
#include <string>
#include <cstdarg>
#include <memory>
short _auto_selected_id = 1;
@Jerrylum
Jerrylum / main.cpp
Last active November 22, 2023 07:09
auton selector on VCS
#include "robot-config.h"
void make_button(int x, int y, int tx, int ty, char *title, vex::color c, int w = 80, int h = 40) {
Brain.Screen.drawRectangle(x,y,w,h,c);
Brain.Screen.setFillColor(c);
Brain.Screen.printAt(x+tx,y+ty,title);
}
bool is_clicked(int bx, int by, int w = 80, int h = 40) {
int x = Brain.Screen.xPosition();
@Jerrylum
Jerrylum / pros_lvgl_canvas_image_test.cpp
Last active June 1, 2019 06:47
A display test for BMP file (includes 24bit RGB and 32bit RGBA) using LVGL Canvas function
#include "main.h"
void drawBmp(lv_obj_t* canvas, const char* filename){
printf("Start: %d\n",pros::millis());
FILE* f = fopen(filename, "rb");
unsigned char info[54];
fread(info, sizeof(unsigned char), 54, f); // read the 54-byte header
// extract image height and width from header
@Jerrylum
Jerrylum / BasicRestfulApi.js
Last active August 26, 2020 02:55
Create a gist so I can download it and use it later :P
'use strict';
function getTargetUrl() {
return window.location.origin;
}
function to(url) {
window.location.href = url;
}
@Jerrylum
Jerrylum / logger.js
Last active August 14, 2020 18:36
This is a very simple and beautiful logger
'use strict';
var RESET = '';
var SAFE = '';
var WARN = '';
var ERROR = '';
var VERBOSE = '';
const join = function(source, to) {
for (const [key, value] of Object.entries(source))
@Jerrylum
Jerrylum / curious
Last active August 14, 2020 20:19
A shell script that can help you execute a command [as the superuser | on a new GNOME terminal]
#!/usr/bin/bash
# Usage:
# curious [--sudo | -s | --terminal | -t] <command>
#
# For example:
# curious notify-send "hello world"
# curious -t notify-send "hello world"
# curious -s -t notify-send "hello world"
@Jerrylum
Jerrylum / Dockerfile
Created August 23, 2020 09:55
XAMPP in Docker
FROM ubuntu:20.10
MAINTAINER Jerry Lum<serverofjerry (at) gmail (dot) com>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update --fix-missing
# curl is needed to download the xampp installer, net-tools provides netstat command for xampp
RUN apt-get -y install curl net-tools
RUN curl -o xampp-linux-installer.run "https://downloadsapachefriends.global.ssl.fastly.net/xampp-files/7.2.33/xampp-linux-x64-7.2.33-0-installer.run?from_af=true"
@Jerrylum
Jerrylum / timetest.c
Created October 26, 2021 10:42
Lazy time test macro
#define TIMETEST(name, content) struct timeval tval_before_##name, tval_after_##name, tval_result_##name; \
gettimeofday(&tval_before_##name, NULL); \
content \
gettimeofday(&tval_after_##name, NULL); \
timersub(&tval_after_##name, &tval_before_##name, &tval_result_##name); \
printf(#name " %ld.%06ld\n", (long int)tval_result_##name.tv_sec, (long int)tval_result_##name.tv_usec);
import json
import random
from typing import Dict, Tuple
from xmlrpc.client import ProtocolError
import requests
from twisted.python import failure
from twisted.internet import reactor
from quarry.types.uuid import UUID
from quarry.net.proxy import UpstreamFactory, Upstream, DownstreamFactory, Downstream, Bridge
@Jerrylum
Jerrylum / remote-ssh-steps.md
Created July 10, 2022 20:20
How to program your robot via remote SHH.
  1. Connect your Jetson / Raspberry PI to your laptop computer via ethernet cable.

  2. Find your Jetson / Raspberry Pi's internal IP address by typing the command arp -a on Windows. For example, the highlighted IP in the image below is the connected Raspberry Pi. It usually comes with the type dynamic. image

  3. Install the extension Remote - SSH on your computer. You are also recommended to install the following extensions. image

  4. Follow the instruction on https://code.visualstudio.com/docs/remote/ssh#_connect-to-a-remote-host, step 2 to step 6. The SSH Host should be the user name + the IP address, like: cityurbc@169.254.56.141