Skip to content

Instantly share code, notes, and snippets.

@readingtype
readingtype / fix_lc_all.md
Created January 9, 2024 18:15
Resolve issue in Ubuntu 22.04 desktop where LC_ALL was set for desktop apps so numbers and dates were incorrectly formatted for the chosen locale

Something was setting LC_ALL in my Ubuntu 22.04 desktop environment. Terminals were unaffected but desktop apps were apparently using the default C locale with 'US style' date formatting. There were also numerous log entries like this:

snapd-desktop-integration.snapd-desktop-integration[5623]: /bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8)

According to sources online, LC_ALL shouldn't be set. I looked for the source of the command. There was nothing in any of the scripts in my $HOME (such as .profile, .bashrc). I created a brand new user and the same issues were there when logged into their account's desktop. I looked in /etc/profile.d which contains system defaults for user profile settings.

To find out what files in the profile directory were installed by a package:

$ for file in `ls /etc/profile.d/`; do dpkg --search $file; done

base-files: /etc/profile.d/01-locale-fix.sh

@readingtype
readingtype / flex_with_autoscroll.html
Created October 16, 2015 12:24
A CSS flexbox layout with a fixed header, a fixed footer, and an expanding centre section which scrolls if its content height is greater than its own height.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test fixed and scrolling divs in a flexbox layout</title>
<style media="screen">
* {
border: 0;
margin: 0;
padding: 0;

Keybase proof

I hereby claim:

  • I am readingtype on github.
  • I am benweiner (https://keybase.io/benweiner) on keybase.
  • I have a public key whose fingerprint is 8322 5FD0 1BA7 2745 E26B B185 9976 A053 704F 84D2

To claim this, I am signing this object:

@readingtype
readingtype / base64encode_png.py
Created August 21, 2013 16:44
Make a base64 encoded PNG in Python 2. The URI format for an img element's src attribute is data:image/png;base64 followed by a comma, followed by the content of the base64 encoded text file.
import base64
raw = open("path/to/image.png","rb")
encoded = open("path/to/image.png.base64.txt", "w")
encoded.write(base64.b64encode(raw.read()))
exit()
@readingtype
readingtype / col-widther-css.rb
Last active December 15, 2015 20:40
Moar silliness. Generate a set of CSS styles for grid columns. Fixed-width for the moment. ruby col-widther-css.rb, copy and paste.
@colwidth = 100
@margin = 10
@total = 0
@numbers = ["none", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "twenty_one", "twenty_two", "twenty_three", "twenty_four", "twenty_five", "twenty_six", "twenty_seven", "twenty_eight", "twenty_nine", "thirty", "thirty_one", "thirty_two"]
def spanwidth(cols)
[(cols * @colwidth.to_i), (@margin.to_i * (cols-1))]
@colwidth = 100
@margin = 10
@total = 0
def spanwidth(cols)
[(cols * @colwidth.to_i), (@margin.to_i * (cols-1))]
end
@readingtype
readingtype / rss_suparchive.php
Created March 1, 2012 19:47
Modify Textpattern plugin, http://www.wilshireone.com/textpattern-plugins/rss-suparchive. Format the excerpt with Textile if appropriate
// rss_suparchive article listing plugin
// by Rob Sable
// http://www.wilshireone.com
// Version 0.1 - 11/02/2004
// Full revision history at http://www.wilshireone.com/textpattern-plugins/rss-suparchive
// Version 0.16.1 - 01/09/2006 - Fix broken file downloads. Fix inadvertent date filtering on article pages.
// Version 0.17 - 08/08/06 - Change categories to display title instead of name.
// Version 0.18 - 08/09/06 - Add showcommentscount, showzerocount, countprefix, countsuffix to suparchive and suparchive_bycat. Change to use strftime for date formatting to allow for localization. Add wildcard and exclude format for section attribute on all 3 tags. (thanks Andrew).
// 20120301 BW Add ability to decode Textile markup in excerpts. * if other markup is used this probably won't work, but if USE_TEXTILE is false it will return the raw text. See rss_format() below *