Skip to content

Instantly share code, notes, and snippets.

@Michael0x2a
Michael0x2a / Logoff-Inactive.ps1
Last active April 23, 2024 15:32
Logoff-Inactive
<#
.SYNOPSIS
Logs out inactive users.
.DESCRIPTION
Logs out inactive users, except for specific users that
have been manually approved and are allowed to stay logged
in for indefinite periods of time.
You can run this script directly on Powershell:
@Michael0x2a
Michael0x2a / minimal-template.tex
Last active March 14, 2024 06:32
Minimal LaTeX template
\documentclass{article}
% General document formatting
\usepackage[margin=0.7in]{geometry}
\usepackage[parfill]{parskip}
\usepackage[utf8]{inputenc}
% Related to math
\usepackage{amsmath,amssymb,amsfonts,amsthm}
\begin{document}
@Michael0x2a
Michael0x2a / cse-143-16au-study-guide.md
Last active February 19, 2024 04:50
CSE 143 16au study guide

CSE 143 16au study guide

How to study

Programming, to a large extent, is about applied problem-solving, and is not about memorization. This means that the best way to prep for programming exams isn't to sit down and read through the slides -- it's by solving a lot of problems.

As a result, I strongly recommend you do the following when preparing:

@Michael0x2a
Michael0x2a / gist:92a6943f26c7ab6e2f4a
Last active January 11, 2021 18:39
Guide to printf (CSE 142)

Quick guide to printf

Using printf is almost identical to using print. They both print out whatever string you give it, they both don't include a newline, etc. There's just one key difference: printf has some extra features that lets you substitute and format values inside whatever you're printing.

Pragmatically, in CSE 142/143, the only time you'd use printf is if you want to round numbers. Here's an example:

double someNumber = 3.33333333333
System.out.printf("Here's a number: %.2f", someNumber);
@Michael0x2a
Michael0x2a / utilities.py
Created March 6, 2013 00:45
Example code of drawing graphs and such
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division
import sympy
import matplotlib
import matplotlib.pyplot as pyplot
S = sympy.sympify
@Michael0x2a
Michael0x2a / reconstructing-tree.md
Last active June 30, 2020 22:42
Reconstructing tree

Reconstructing a Binary Tree

Problems 0 and 1 on the section handout today were all about writing out and reading in a tree (serializing and deserializing). Problem 0 asked you to take an existing tree and print it out into text form, and problem 1 asked you to read that output back in again using a Scanner, and reconstruct the tree.

Just as a reminder, here's the code on the solution sheet for problems 0 and 1:

// Problem 0
public void writeTree() {
    this.writeTreeHelper(this.root);
@Michael0x2a
Michael0x2a / convert_stubs.py
Created April 11, 2019 19:27
A quick and dirty script to make stub files use variable annotations
"""
convert_stubs.py
Modifies stub files to use variable annotations instead of type comments.
To run, pass in a path to the directory containing stubs. This script will
recursively traverse it and modify all .pyi files:
$ python3 convert_stubs.py path/to/stubs
__________________________ testMetaclassOpAccessAny ___________________________
[gw1] win32 -- Python 3.6.3 c:\python3.6\python.exe
data: C:\Users\Michael\Dropbox\Projects\Code\Programs\mypy\mypy\test-data\unit\pythoneval.test:1206:
..\..\..\..\Dropbox\Projects\Code\Programs\mypy\mypy\mypy\test\testpythoneval.py:42: in run_case
test_python_evaluation(testcase, os.path.join(self.cache_dir.name, '.mypy_cache'))
..\..\..\..\Dropbox\Projects\Code\Programs\mypy\mypy\mypy\test\testpythoneval.py:97: in test_python_ev
aluation
testcase.file, testcase.line))
..\..\..\..\Dropbox\Projects\Code\Programs\mypy\mypy\mypy\test\helpers.py:111: in assert_string_arrays
_equal
_________________________ testTypeTypeComparisonWorks _________________________
[gw2] win32 -- Python 3.6.3 c:\python3.6\python.exe
data: C:\Users\Michael\Dropbox\Projects\Code\Programs\mypy\mypy\test-data\unit\check-classes.test:3251:
SystemExit: 1
---------------------------- Captured stdout call -----------------------------
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 8, in <module>
File "c:\python3.6\lib\site-packages\execnet\gateway_base.py", line 1534, in serve
SlaveGateway(io=io, id=id, _startcount=2).serve()
usage: mypy [-h] [-v] [-V] [more options; see below]
[-m MODULE] [-p PACKAGE] [-c PROGRAM_TEXT] [files ...]
Mypy is a program that will type check your Python code.
Pass in any files or folders you want to type check. Mypy will
recursively traverse any provided folders to find .py files:
$ mypy my_program.py my_src_folder