Skip to content

Instantly share code, notes, and snippets.

View ksylvan's full-sized avatar

Kayvan Sylvan ksylvan

View GitHub Profile
@ksylvan
ksylvan / gist:2aacf2b466741a5468b2ea7ab475ee97
Last active August 30, 2024 04:46
Ansible playbook for fixing up a Mac Dock using dockutil
# Based on https://blog.vandenbrand.org/2016/01/04/how-to-automate-your-mac-os-x-setup-with-ansible/
#
- hosts: all
tasks:
- name: Current Dock names
shell: >
dockutil --list |
python -c 'import sys; [sys.stdout.write(line.split("\t")[0] + "\n")
for line in sys.stdin]'
register: dockitems
@ksylvan
ksylvan / current-date-and-time.applescript
Created October 10, 2023 21:58 — forked from Glutexo/current-date-and-time.applescript
AppleScript to get current date and time (YYYY-MM-DD HH:MM:SS). Usable as a Text Service in Mac OS X.
(*
The zero_pad function taken from:
http://www.nineboxes.net/2009/10/an-applescript-function-to-zero-pad-integers/
*)
on zero_pad(value, string_length)
set string_zeroes to ""
set digits_to_pad to string_length - (length of (value as string))
if digits_to_pad > 0 then
repeat digits_to_pad times
set string_zeroes to string_zeroes & "0" as string
@ksylvan
ksylvan / Join Zoom.scpt
Created October 6, 2023 01:30 — forked from JacksonChen666/Join Zoom.scpt
Join zoom at the speed of computers (AppleScript)
# It is recommended that you save this script as an application, so you don't have to open Script editor.
(*
It all started when I wanted to join zoom faster than a human could do with no prompt like how I expected like this.
I first discovered zoom.us's URL scheme to join meeting, but when I found out it doesn't work, I started to make this program.
After this all of stuff, I finally have something that is constantly updated.
After this pandemic is over, development might slow down or become discontinued.
*)
global meetingNames, meetingIDs, meetingPwds, wname
# Compiling the app will reset all your saved meetings!
property meetingNames : {}
@ksylvan
ksylvan / req1.md
Last active May 5, 2023 18:45
Job Requirements

Backend Developer:

Backend development expertise:

  • Design, implement, optimize scalable systems
  • Microservices architecture, serverless computing

Java proficiency:

  • Java knowledge, ecosystem
  • Java frameworks: Spring, Hibernate, Java EE
  • Modern Java libraries, tools, best practices
@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
#!/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.
********************************************************
*** 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
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
# 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
# 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
#
#
# _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
# |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
# | | | |
# |H| |L| |W| |D|
# |E| |O| |O| |!|
# |L| |R|
# |L|
#