Skip to content

Instantly share code, notes, and snippets.

@sunapi386
sunapi386 / duplicates.rb
Created January 30, 2017 22:39
Ruby script for checking duplicate file names
## Jason Sun <[email protected]>
## Jan 30, 2017
##
## Lists the duplicate files in the two given directories.
## Simple, only compares names. Case sensitive.
## Options:
## - filter by file extension
## - list the non-duplicate files
## - show the list (vs just stats)
@sunapi386
sunapi386 / comments.sh
Created February 9, 2017 03:08
train stats
bash-3.2$ find . \( -iname "*.h" -o -iname "*.c" \) -exec /bin/echo {} + | xargs awk -f lc.awk
--------------------------------File---Code---Comments---Raw Lines
-------------- ./include/kernel/scheduler.h 68 11 93
./user/sensor.c 154 25 190
./track/new/track_data_new.c 2352 1 2357
./include/user/clock_drawer.h 4 0 6
./include/utils.h 36 0 46
./include/user/parser.h 5 0 6
@sunapi386
sunapi386 / coins.py
Created February 22, 2017 03:41
Dynamic Programming: Taking Coins
# DP practice problem.
# Feb 21, 2017.
# Jason Sun sunapi386.ca
#
# Problem
#
# You are a given collection of coins, where each stack of coins is of h height, and there are s stacks.
# Take exactly h coins, such that the sum of the coins is the maximum possible.
# Caveat: if you take a coin from a stack, all the coins above it must be taken too.
#
@sunapi386
sunapi386 / PP15S-1.68.txt
Last active April 13, 2017 19:48
cambrionix
>> help
mode <m> [p] Set mode <m> for port [p] or all ports
mode c p f Set charge mode for port p using profile f if attached
state [p] Show state for port [p] or all ports
system Show hardware and firmware information
health Show voltages, temperature, error & boot flag
cef Clear error flags
sef <flag> Set error flag. One of: 5UV 5OV 12UV 12OV OT
crf Clear rebooted flag
limits Show voltage & temperature limits

FWIW: I didn't produce the content present here. I've just copy-pasted it from somewhere over the Internet, but I cannot remember exactly the original source. I was also not able to find the author's name, so I cannot give him/her the proper credit.


Effective Engineer - Notes

What's an Effective Engineer?

@sunapi386
sunapi386 / x11vnc-start
Created January 15, 2018 23:56 — forked from tavinus/x11vnc-start
Starts VNC server for the current session
#!/bin/bash
###########################################################################
# /usr/local/bin/x11vnc-start
# Starts VNC server for the current session
#
# Gustavo Neves - 4th Jul 2016
#
# Install x11vnc:
# sudo apt-get install x11vnc
@sunapi386
sunapi386 / register_monitor.py
Last active January 24, 2018 07:21
Sets a windows registry `key` in `path` every `duration` seconds to `value`.
# Jason Sun [email protected]
# Jan 22, 2018.
# Sets a registry `key` in `path` every `duration` seconds to `value`.
# E.g. Add/update a registry DWORD entry, set NC_ShowSharedAccessUI = 1
# Can be compiled to exe with:
# pyinstaller --onefile register_moniter.py
# See reference https://pythonhosted.org/PyInstaller/usage.html
from time import sleep
import winreg
import ctypes
@sunapi386
sunapi386 / SimpleRasbian.sh
Last active June 23, 2018 22:39
Clean minimal Raspbian
#!/usr/bin/env bash
# Given a fresh install of a Raspian OS, install the necessary tools.
# This is only meant to run once to setup a brand new fresh OS install.
#
# Author: Jason Sun
# Date: Feb 01, 2018
#
packages(){
sudo apt update
@sunapi386
sunapi386 / record_screen.sh
Created February 3, 2018 05:57
Record screen
#!/bin/bash
record_screen() {
SCREEN_RES=$(xrandr -q --current | grep '*' | awk '{print$1}')
DATE=$(date '+%Y-%m-%d-%H:%M:%S')
echo "saving to recording_$DATE.mkv"
echo "Ctrl-C to exit"
ffmpeg -loglevel panic -f x11grab -s $SCREEN_RES -i :0.0 -r 25 -vcodec libx264 "recording_$DATE.mkv"
}
record_screen