Skip to content

Instantly share code, notes, and snippets.

def count_upper_words(str):
words = str.split(' ');
print('\n\n---- %s ----' % str)
return sum([word.isupper() for word in words])
print(count_upper_words('Fast'))
print(count_upper_words('SLOW'))
print(count_upper_words('first MIDDLE Last'))
@jlewin
jlewin / word_capitals.py
Created March 2, 2020 18:23
Test words for casing
def capital_chars(word):
return [c.isupper() for c in word]
def analyze(str):
has_words = ' ' in str
if has_words:
words = str.split(' ');
for word in words:
import os
from os import path
def import_settings(file_path):
with open(file_path) as gcode_file:
all_lines = gcode_file.readlines()
# Filter to comments with equals
comments = [comment for comment in all_lines if comment.startswith('; ') and len(comment.split('=')) == 2]
import os
from os import path
def import_settings(file_path):
with open(file_path) as gcode_file:
all_lines = gcode_file.readlines()
# Filter to comments with equals
comments = [comment for comment in all_lines if comment.startswith('; ') and len(comment.split('=')) == 2]
@jlewin
jlewin / AddTitlesToIcons.js
Created October 14, 2019 01:34
Quick preview for icon names
// https://octicons.github.com/
jQuery('.js-icon-item').each(function(f) {
var el = $(this);
el.attr('title', el.attr('data-name').replace('octicon-', ''));
});
@jlewin
jlewin / build-dictionary.md
Last active June 25, 2019 23:11
Rebuild list as dictionary

Search

new [^\(](null, ([^,]+), ("[^"]+").?(?:\r)

Replace

[$2] = $0z

Against

@jlewin
jlewin / extract-sample-files-to-zip.sh
Created February 5, 2019 16:50
Extract SVG sample files
docker run -it ubuntu
apt install wget
apt install zip
# perform the download - stackoverflow:https://stackoverflow.com/questions/23446635/
wget -r -np -nH --cut-dirs=3 -R index.html https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/
# zip the content
cd /samples/svg-files
zip -r svg.zip .
string filePath = Path.Combine(path, mode + ".json");
var theme = JsonConvert.DeserializeObject<ThemeSet>(
File.ReadAllText(filePath);
if (theme.AccentColors == null || theme.AccentColors.Count <= 0)
{
theme.AccentColors = this.Colors;
File.WriteAllText(
filePath,
foreach(var mode in item.Value.Modes)
{
string directory = $@"c:\temp\themes\{item.Key}";
Directory.CreateDirectory(directory);
var theme = item.Value.GetTheme(mode, item.Value.DefaultColor);
theme.ThemeName = $"{item.Key} {mode}";
File.WriteAllText(
Path.Combine(directory, $"{item.Key}-{mode}.json"),
var xxx = new Dictionary<string, Color>()
{
{ "Red - Dark", new Color(172, 25, 61) },
{ "Pink - Dark", new Color(220, 79, 173) },
{ "Orange - Dark", new Color(255, 129, 25) },
{ "Green - Dark", new Color(0, 138, 23) },
{ "Blue - Dark", new Color(0, 75, 139) },
{ "Teal - Dark", new Color(0, 130, 153) },
{ "Light Blue - Dark", new Color(93, 178, 255) },
{ "Purple - Dark", new Color(70, 23, 180) },