Skip to content

Instantly share code, notes, and snippets.

@cyrusn
cyrusn / .vimrc
Created May 22, 2023 23:31 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" TODO: Load plugins here (pathogen or vundle)
" Turn on syntax highlighting
syntax on
from urllib import request
from json import load
from datetime import datetime, timezone, timedelta
from os import system
from time import sleep
routes = [
'32', '36', '40E', '40P', '40X', '46P', '46X', '47A',
'47X', '48X', '73D', '73P', '73X', '936', 'N36', 'N48',
@cyrusn
cyrusn / word.py
Last active November 9, 2022 06:41
basic word for students exercise
words = [
"complete",
"notice",
"common",
"surface",
"pattern",
"tiny",
"care",
"addition",
"check",
@font-face {
font-family:"Cubic 11";
src: url("https://github.com/ACh-K/Cubic-11/blob/main/fonts/web/Cubic_11_1.010_R.woff2?raw=true") format("woff2");
}
/* cyrillic-ext */
@font-face {
font-family: 'Press Start 2P';
font-style: normal;
font-weight: 400;
@cyrusn
cyrusn / index.js
Last active February 15, 2022 12:13
bookmarklet to sort school journal by classcode
javascript:(function(){
let tables = document.getElementsByTagName("table");
for (let table of tables) {
let stores = [];
const rows = table.tBodies[0].children;
for (let row of rows) {
const rowValue = row.children[0].innerText;
const matches = rowValue.match(
/^ +(\S+) +(\S+) +(\S+|\d\S\s{2}\S+) +(\d{1,2}\/\d{1,2}) .+(\d{2}-\d{2}) +(\d{2}:\d{2})$/,
);
@cyrusn
cyrusn / convertWordFile2PDF.js
Last active October 7, 2021 02:06
macOS JXA script to convert word files (docx) to pdf. Change the file to executable `chmod 777 ./convertWordFile2PDF.js` and run it by `./convertWordFile2PDF.js`.
#!/usr/bin/env osascript -l JavaScript
/*
* [resource](https://github.com/JXA-Cookbook/JXA-Cookbook/wiki)
*/
const app = Application.currentApplication();
// allow to use `chooseFile` and `chooseFolder` methods
app.includeStandardAdditions = true;
@cyrusn
cyrusn / index.js
Created September 21, 2021 05:54
bookmarklet to sort table in e journal system
javascript:(function sortTable(){
let tables = document.getElementsByTagName("table");
for (let table of tables) {
let stores = [];
const rows = table.tBodies[0].children;
for(let row of rows){
const rowValue = row.children[0].innerText;
const matches = rowValue.match(
/^ +(\S+) +(\S+) +(\S+|\d\S\s{2}\S+) +(\d{1,2}\/\d{1,2}) .+(\d{2}-\d{2}) +(\d{2}:\d{2})$/,
);
@cyrusn
cyrusn / split_pdf.fish
Last active July 18, 2021 11:02
Split PDF with fish shell and imagick
function split_pdf -a pdf -d "split a PDF file"
set -l options (fish_opt -s n -l noOfPages --required-val)
set options $options (fish_opt -s l -l list --required-val)
set options $options (fish_opt -s d -l dpi --required-val)
set options $options (fish_opt -s h -l help)
argparse --name="split_pdf" $options -- $argv
or return
if set -q _flag_help
@cyrusn
cyrusn / main.py
Last active March 10, 2021 05:59
GY906
from smbus2 import SMBus
from time import sleep
# datasheet: https://www.sparkfun.com/datasheets/Sensors/Temperature/MLX90614_rev001.pdf
class GY906():
AMBIENT_TEMP_REGISTER = 0x06
OBJECT1_TEMP_REGISTER = 0x07
def __init__(self, bus, address):
self.bus = bus
@cyrusn
cyrusn / gameof15.py
Last active December 22, 2020 03:51
Game of 15
from os import system
board = [[15, 14, 13, 12], [11, 10, 9, 8], [7, 6, 5, 4], [3, 1, 2, 0]]
answer = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0]]
r, c = 3, 3
step = 0
def print_row(row):
for cell in row:
if cell != 0: