Skip to content

Instantly share code, notes, and snippets.

@maxmarchuk
maxmarchuk / jama.xml
Created September 11, 2018 17:37
jama intellij live templates
<!--
This file should go under ~/Library/Preferences/<intellij_version>/templates
This exposes some live templates / shortcuts for react component development, jasmine tests, and a react + enzyme test skeleton.
Jasmine templates: https://github.com/gbritting/jasmine-jetbrains-live-templates
React templates: https://github.com/minwe/jetbrains-react
react + enzyme test: just type `enzymetest` and hit tab to expand
-->
<templateSet group="jama">
<template name="enzymetest" value="import React from 'react';&#10;import { shallow, mount } from 'enzyme';&#10;import $componentName$ from './$componentName$';&#10;&#10;describe('$componentName$', () =&gt; {&#10; it('$specDesc$', () =&gt; {&#10; const subject = shallow(&lt;$componentName$ /&gt;);&#10; expect(subject$END$);&#10; });&#10;});&#10;" description="" toReformat="false" toShortenFQNames="true">
<variable name="componentName" expression="" defaultValue="substringBefore(fileName(),&quot;.&quot;)" alwaysStopAt="false" />
@maxmarchuk
maxmarchuk / ShowTabFocus.js
Last active March 1, 2021 09:14
This is a little script for running in TamperMonkey that renders a tooltip (if jquery tooltips are available) and sets a red border around any element that is tabbed to. Nothing too special, but it helped me troubleshoot and improve some keyboardability issues. If you want to try this out, just install the TamperMonkey plugin and paste this in. …
// ==UserScript==
// @name Show Tab Indices
// @namespace http://tampermonkey.net/
// @version 0.1
// @description render a jquery tooltip with the current index on every keypress for the active element
// @author Max Marchuk
// @match *://*/*
// @grant none
// @require http://code.jquery.com/jquery-3.3.1.js
// @require https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js
@maxmarchuk
maxmarchuk / CKEditor specialChar description getter
Last active January 31, 2017 23:50
A python script for getting the descriptions of special characters (such as greek letters or math symbols) by parsing http://www.dionysia.org/html/entities/symbols.html. The output is in a format used for CKEditor's specialChars configuration to use the description as the tooltip for the characters.
#!/usr/local/bin/python3
from lxml import html
import requests
try:
file = open("./symbols.txt")
file_string = file.read().split()
except:
file_string = 'Α α Β β Γ γ Δ δ Ε ε Ζ ζ Η η Θ θ Ι'.split()
@maxmarchuk
maxmarchuk / T9_phone_keypad_presses.py
Created May 31, 2016 22:48
A simple Python script to get the number of key presses that would be required to type a certain phrase on a T9-style phone keyboard.
def presses(phrase):
mapping = {
"*": "*",
"#": "#",
0: " 0",
1: "1",
2: "ABC2",
3: "DEF3",
4: "GHI4",
5: "JKL5",
@maxmarchuk
maxmarchuk / .bashprofile
Last active May 31, 2016 22:50
My very messy bash profile
source ~/.bash_aliases
source ~/.git-prompt.sh
export PS1="\[\e[00;36m\]\u\[\e[0m\]\[\e[00;37m\]@\[\e[0m\]\[\e[00;36m\]\h\[\e[0m\]\[\e[00;37m\]:\[\e[0m\]\[\e[00;35m\]\w\[\e[0m\]\[\e[00;37m\]> \[\e[0m\]"
#Get the current VCS branch name (git, mercurial, svn)
function be_get_branch {
local dir="$PWD"
local vcs
local nick
while [[ "$dir" != "/" ]]; do
@maxmarchuk
maxmarchuk / vimrc
Last active May 31, 2016 22:50
My configuration for vim
syntax on " syntax highlighting
filetype indent on " activates indenting for files
set number " line numbers
colorscheme elflord " set the text/background color scheme
set autoindent "use the indentation level of previous line for the new line
set smartindent "i don't know. make autoindent smarter or something
set expandtab "pressing tab produces spaces
set tabstop=4 "tab expands to 4 spaces
set shiftwidth=4 "when shifting text, shift it over 4 spaces
set hlsearch "highlight text when performing a search