Skip to content

Instantly share code, notes, and snippets.

@ksylvan
ksylvan / req1.md
Last active May 5, 2023 18:45
Job Requirements
View req1.md
@ksylvan
ksylvan / cuda_check.py
Created April 23, 2023 23:52 — forked from f0k/cuda_check.py
Simple python script to obtain CUDA device information
View cuda_check.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Outputs some information on CUDA-enabled devices on your computer,
including current memory usage.
It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1
from C to Python with ctypes, so it can run without compiling anything. Note
that this is a direct translation with no attempt to make the code Pythonic.
@ksylvan
ksylvan / How-to-Symbolize-MacOSX-Crash-Dump
Created December 9, 2020 16:21 — forked from jerrykrinock/How-to-Symbolize-MacOSX-Crash-Dump
How to symbolize a crash dump in Mac OS X, given a crash dump or exception log. Includes some steps and tips I've collected that are missing in Apple's TN2123. One time I tried this using lldb instead of gdb but it didn't work.
View How-to-Symbolize-MacOSX-Crash-Dump
********************************************************
*** STEPS TO SYMBOLIZE A CRASH DUMP OR EXCEPTION LOG ***
********************************************************
1) Move/copy both the crashing .app and the relevant.dSYM files into the same directory.
2) If the crash was in a framework, dynamic library, or bundle, you have position-independent code and must work out the *slide*. Otherwise, skip up to step 9 and use slide=0.
3a) If you have a crash dump, look in the *Binary Images* part of the crash log and find the framework, dynamic libray or bundle in which the crash occurred. Read the first column of the output. This is the address at which the __TEXT segment was loaded. We call it the *Actual Load Address* and denote it as *A*.
@ksylvan
ksylvan / mines.py
Last active June 11, 2020 22:46
MineSweeper
View mines.py
from random import randrange
class MinesGrid:
# Implement a sparse array to optimize space.
MINE = -1
class Row:
# Each row in the __a dict has the following
# structure a list, containing:
# [ empty_cells, {} ]
@ksylvan
ksylvan / Euler17.py
Last active May 4, 2020 00:52
Euler 17 in Python: Number to words
View Euler17.py
# 1 <= T <= 10
# 0 <= N <= 1e12
# 1e3 = Thousand
# 1e6 = Million
# 1e9 = Billion
# 1e12 = Trillion
# Project Euler 17
@ksylvan
ksylvan / linkedin.py
Created March 28, 2020 06:46
Justified Text question
View linkedin.py
# Question Description: Write a function that takes, as arguments, an integer representing line length in
# characters and a (long) string of text and returns the text with spaces and line breaks to produce a block of
# text justified to the given line length. For example, if the function were called as
# justify(25, "This is some sample text, really just enough to generate a few lines in the output to show what the text justify function is supposed to do.")
# This is some sample text,
# really just enough to
# generate a few lines in
# the output to show what
@ksylvan
ksylvan / main.py
Last active March 18, 2020 06:27
OurString and hasNext and getNext
View main.py
#
#
# _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
# | | | |
# |H| |L| |W| |D|
# |E| |O| |O| |!|
# |L| |R|
# |L|
#
@ksylvan
ksylvan / calc.py
Last active March 13, 2020 23:50
Simple Calculator
View calc.py
# You are building an educational website and want
# to create a simple calculator for students to use.
# The calculator will only allow addition and subtraction
# of non-negative integers.
# We also want to allow parentheses in our input.
# Given an expression string using
# the "+", "-", "(", and ")"
# operators like "5+(16-2)", write a function to parse the
# string and evaluate the result.
View Effective_Engineer.md
@ksylvan
ksylvan / pihole_config.sh
Last active November 28, 2019 09:42
Pi-Hole Config for pi-hole in Docker container
View pihole_config.sh
#!/bin/bash
#
# After you start your Pi-Hole in a Docker container according
# to this: https://github.com/diginc/docker-pi-hole
#
# NOTE: On the Mac, I had to add "-h $(scutil --get LocalHostName)" to
# the "docker run" command. Otherwise, the Mac hostname was being reset
# to the random hostname generated for the container.
#
# Run this to replicate Will's setup here: