Skip to content

Instantly share code, notes, and snippets.

View FrankFonts's full-sized avatar
🏠
Working from home

Frank Fonts FrankFonts

🏠
Working from home
View GitHub Profile
@FrankFonts
FrankFonts / Context Aware Delimiter_030.py
Created April 14, 2015 20:21
Context Aware Delimiter_030.py
dict={
'cap' : 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' '),
'lowercase' : 'a b c d e f g h i j k l m n o p q r s t u v w x y z'.split(' ')
}
def find(this, dictionary):
for key in dictionary.keys():
if this in dictionary[key]:
return key
@FrankFonts
FrankFonts / Command Line Arguments
Created April 22, 2015 11:34
Command Line Arguments
#!/usr/bin/python
import sys
# it's easy to print this list of course:
print sys.argv
# or it can be iterated via a for loop:
for i in range(len(sys.argv)):
@FrankFonts
FrankFonts / Path in Python
Created April 22, 2015 14:18
Path in Python
import os
print("Path at terminal when executing this file")
print(os.getcwd() + "\n")
print("This file path, relative to os.getcwd()")
print(__file__ + "\n")
print("This file full path (following symlinks)")
full_path = os.path.realpath(__file__)
# design settings
gutter = 60
radius = 6
pageW = 1600
# draw filled outline or contours
contour = False
# draw nodes and bluezones and vertical metrics?
@FrankFonts
FrankFonts / simple-html-table-blueprint.html
Created May 20, 2022 11:17
Simple HTML Table blueprint
<table>
<!-- We may add a caption to our table -->
<caption>Caption may come here</caption>
<!-- Styling with <col> -->
<colgroup>
<col>
<col>
<col style="background-color: yellow">
</colgroup>
@FrankFonts
FrankFonts / window-width-and-height.js
Created May 25, 2022 11:41
Best way to query the REAL window width and height (scrollbars included if there is any)
let width = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
let height = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
@FrankFonts
FrankFonts / camelise.js
Last active May 28, 2022 11:48
camelise(str) JS function
// The function camelise(str) changes dash-separated words
// like “my-short-string” into camel-cased “myShortString”.
// Removes all dashes, each word after dash becomes uppercased.
function camelize(str) {
return str.split('-').reduce((a, b) => {
return a + b[0].toUpperCase()+b.slice(1);
});
}
@FrankFonts
FrankFonts / js-upon-pageload.js
Last active June 9, 2022 07:48
Ways to run .js after page has loaded
// vanilla JS solution
window.onload = function(){
CODE HERE;
};
// vanilla JS solution, equivalent to the code above
window.addEventListener("load", function() {
CODE HERE;
@FrankFonts
FrankFonts / css-selectors.scss
Last active June 14, 2022 10:43
CSS Selectors
**.class** .intro
/* Selects all elements with class="intro" */
**.class1.class2** .name1.name2
/* Selects all elements with both name1 and name2 set within its class attribute */
**.class1 .class2** .name1 .name2
/* Selects all elements with name2 that is a descendant of an element with name1 */
**#id** #firstname
@FrankFonts
FrankFonts / get-property-value.js
Created June 14, 2022 12:06
getPropertyValue in JS
let tabs = document.querySelector('.tab__links');
let tabsPaddingLeft = parseInt(window.getComputedStyle(tabs, null).getPropertyValue('padding-left'));