Skip to content

Instantly share code, notes, and snippets.

@AJLeonardi
AJLeonardi / JS_Grid_Sort.js
Last active September 2, 2022 16:30
A Javascript class that sorts Grids by clicking on the column header. Specifically this one was created to sort grids created using MaterializeCSS Collections. Sorting supports strings, numbers, and dates and will sort ascending and descending. Demo here: https://jsfiddle.net/AJLeonardi/etjwq7uc/
/*
Supports grids created with ordered and unordered lists. Specifically this was created to support sorting
1. In your ul, include a list of dictionaries in this format - representing the sortable items: [{"name": "<key name of your column e.g. 'Date_of_Birth'>", "data_type": "<number, string, or date>"}, ....]
2. Within the li containing your column headers, each html element representing the header of a sortable column should have a "data-header" attribute which is set to the corresponding "name" <div class="column" data-header="Date_of_Birth">
3. Within each subsequent li, the li should contain a data attribute for each sortable item's value in this format: <li class='item' data-Date_of_Birth='10/10/2001'>
4. make a ul sortable by instantiating with: new SortedGrid(ul_obj, "<the column 'name' that is sorted by default>", "<the name of your ascending sort css class for your column header>", "<the name of your ascending sort css class for your column header>");
Full working demo here: https://jsfiddle.ne
@AJLeonardi
AJLeonardi / Item_Search.js
Created July 18, 2018 12:16
a simple javascript class to enable client-side searching across a list of elements on a page.
/*
Setup:
1. Add a unique class to the "container" of the list of items you'll be searching across. The Container must be the closest parent to the elements (e.g. an unordered list)
2. Ensure that each element that will be considered for search has a unique ID
3. Add the class 'search-item' to each element that will be considered for search
4. Add the data-search-string attribute to each element that will be considered for search. This attribute should contain the text that users would search on.
5. ItemSearch assumes the search will be done through user input via an input field. Give your input field a unique ID.
Get it Working On your Page:
@AJLeonardi
AJLeonardi / MiniVan_Layout.json
Last active January 31, 2022 18:42
My current layout for my miniVan 40% keyboard
{"id":"lowwriter_rev2","config":{"vendorId":"0xFEAE","productId":"0x8847","deviceVersion":"0x0001","manufacturer":"TheVan Keyboards","product":"LowWriter","description":"LowWriter MiniVan 40%","matrixRowPins":["D7","B5","F7","D4"],"matrixColumnPins":["D2","D3","D5","D6","B4","B6","F6","F5","F4","F1","F0","B3"],"diodeDirection":"COL2ROW","matrixHasGhost":false,"backlightLevels":1,"backlightPin":"B7","usbMaxPowerConsumption":100,"debouncingDelay":5,"tappingTerm":175,"lockingSupportEnabled":true,"lockingResyncEnabled":true,"commandKeyCombination":"keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))","debugEnabled":true,"printEnabled":true,"actionLayerEnabled":true,"actionTappingEnabled":true,"actionOneShotEnabled":true,"actionMacroEnabled":true,"actionFunctionEnabled":true},"rules":{"mcu":"atmega32u4","processorFrequency":16000000,"architecture":"AVR8","inputClockFrequency":16000000,"bootloaderSize":4096,"bootmagicEnabled":true,"mousekeyEnabled":true,"extrakeyEnabled":true,"consoleEnabled":false,"
[
{
"name": "Mini Van Standard Layout."
},
[
{
"c": "#968e85",
"a": 7,
"f": 4
},
@AJLeonardi
AJLeonardi / boto3_CORS_config.py
Created April 18, 2018 12:19
DreamObjects boto3 CORS config for fonts
import boto3
session = boto3.session.Session()
connection = session.resource(
's3',
aws_access_key_id= '...', #dreamObjects key
aws_secret_access_key= '...', #dreamObjects secret key
endpoint_url= 'https://objects-us-west-1.dream.io',
)
client = connection.meta.client
@AJLeonardi
AJLeonardi / btn_group.css
Created March 20, 2018 16:52
Simple Button Group for Materialize
.btn-group {
position: relative;
display: -ms-inline-flexbox;
display: inline-flex;
vertical-align: middle;
}
.btn-group>.btn:first-child:not(:last-child) {
border-top-right-radius: 0;
border-bottom-right-radius: 0;