-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
191 lines (185 loc) · 8.49 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>TIL</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<h2 id="til">TIL</h2>
<p>2020-08-04</p>
<h4 id="make-a-floating-label-in-ionic">Make a floating label in Ionic</h4>
<p>Set the value of the <code>position</code> attribute of <code>ion-label</code> to <code>floating</code>:</p>
<pre><code><ion-label>
<ion-label position="floating">...</ion-label>
<ion-input></ion-input>
</ion-label>
</code></pre>
<p>other possible values vor <code>position</code> are <code>stacked</code> (this will place the label above the input element), <code>fixed</code>, and undefined (inline).</p>
<p>#ionic</p>
<hr />
<p>2020-07-28</p>
<h4 id="insert-current-date-in-emacs-buffer">Insert current date in Emacs buffer</h4>
<pre><code>(defun insert-date ()
"Insert the current date in ISO 8601 format (like \"%Y-%m-%d\")"
(interactive)
(insert (format-time-string "%F\n" (current-time))))</code></pre>
<p>See <code>C-h f format-time-string</code> for other formatting options.</p>
<p>#emacs</p>
<hr />
<p>2020-07-15</p>
<h4 id="obs-setup-for-live-code-streaming">OBS Setup for Live Code Streaming</h4>
<ul>
<li><a href="https://jordanlewis.org/posts/twitch-live-coding/">How to Run a Live Coding Stream on Twitch using OBS</a></li>
<li><a href="https://news.ycombinator.com/item?id=23835624">Some Discussion</a></li>
</ul>
<p>#obs #screensharing #bookmarks</p>
<hr />
<p>2020-07-12</p>
<h4 id="length-of-strings-and-list-like-data-structures-in-different-programming-languages">Length of strings and list-like data structures in different programming languages</h4>
<p>Python:</p>
<pre><code>a = [1, 2, 3, 4]
t = 1, 2, 3, 4
s = "blub"
print(len(a))
print(len(s))
print(len(t)) # length of a tuple</code></pre>
<p>Perl:</p>
<pre><code>my @a = (1, 2, 3, 4);
my $s = "blub";
say scalar @a;
say length $s;
# list assignment, in scalar context, returns number of scalars on RHS
my $length = () = (1, 2, 3);
say $length;
# In one line
say scalar(() = (1, 2, 3));
</code></pre>
<p>See <a href="https://stackoverflow.com/a/57336399">here</a>, <a href="https://stackoverflow.com/a/54564429">here</a>, and <a href="https://metacpan.org/pod/distribution/perlsecret/lib/perlsecret.pod#Goatse">here</a>.</p>
<p>Elisp:</p>
<pre><code>(length '(1 2 3))
(length "blub")</code></pre>
<p>Javascript:</p>
<pre><code>"blub".length;
[1, 2, 3, 4].length;</code></pre>
<p>Swift:</p>
<pre><code>"blub".count
[1, 2, 3, 4].count
</code></pre>
<p>#python #perl #elisp #javascript #swift</p>
<hr />
<p>2020-07-10</p>
<h4 id="given-an-email-address-get-the-uid-of-the-corresponding-firebase-user">Given an email address, get the UID of the corresponding Firebase user</h4>
<pre><code>#!/usr/bin/env python
import sys
import firebase_admin
from firebase_admin import auth
from email_validator import validate_email, EmailNotValidError
import google.auth.exceptions
cred = firebase_admin.credentials.Certificate(
'SERVICE_ACCOUNT.json'
)
firebase_admin.initialize_app(cred)
if len(sys.argv) != 2:
print("Usage: " + sys.argv[0] + " EMAIL")
sys.exit(1)
email = sys.argv[1]
# make a syntax-only check if the mail address is valid
try:
validate_email(email, check_deliverability=False)
except EmailNotValidError as e:
print(email + " is not a valid email address")
print(str(e))
sys.exit(1)
try:
user = auth.get_user_by_email(email)
print(user.uid)
except google.auth.exceptions.TransportError:
print("TransportError - do you have a working internet connection?")
except firebase_admin._auth_utils.UserNotFoundError:
print("UserNotFoundError - no Firebase user with email " + email + " found in this instance")</code></pre>
<p>#python #firebase</p>
<hr />
<p>2020-07-09</p>
<h4 id="validate-an-email-address-with-python">Validate an email address with Python</h4>
<p>The <code>email_validator</code> module by Joshua Tauberer is simple to use and provides good error messages.</p>
<p>Install with</p>
<pre><code>pip install email_validator</code></pre>
<p>Then use like this for email syntax check:</p>
<pre><code>from email_validator import validate_email, EmailNotValidError
try:
validate_email('EMAIL_TO_VALIDATE', check_deliverability=False)
except EmailNotValidError as e:
print(str(e)) # nice error message</code></pre>
<p>#python</p>
<hr />
<p>2020-07-08</p>
<h4 id="focus-tip-brain.fm-and-selfcontrol-apps">Focus tip: Brain.fm and SelfControl apps</h4>
<p>As preparation, before high concentration is required:</p>
<ol type="1">
<li>Put on headphones</li>
<li>Start the <a href="https://www.brain.fm/">Brain.fm</a> app, select one of the ‘Focus’ tracks.</li>
<li>Will you be able to work without internet for 15-30min? And are you on a Mac? Then use the <a href="https://selfcontrolapp.com/">SelfControl</a> app in whitelist mode.</li>
</ol>
<p>If you think 2 and 3 contradict each other (not able to use Brain.fm if no internet): I use the Brain.fm iOS app and use SelfControl on the Mac.</p>
<p>#focus</p>
<hr />
<p>2020-07-07</p>
<h4 id="generate-an-image-with-imagemagick">Generate an image with Imagemagick</h4>
<pre><code>convert -size 1000x1000 canvas:tomato canvas_tomato.png</code></pre>
<p><a href="http://www.imagemagick.org/Usage/canvas/#solid">Reference</a></p>
<p>#imagemagick</p>
<hr />
<h4 id="follow-redirects-with-curl">Follow redirects with curl</h4>
<pre><code>curl -L</code></pre>
<p>or <code>curl --location</code>. Mnemonic: the <code>Location:</code>-header together with a <code>3xx</code> response code is set if a redirect is active.</p>
<p>#curl</p>
<hr />
<h4 id="set-the-standard-board-in-the-trello-mac-app">Set the standard board in the Trello Mac app</h4>
<pre><code>Shift-Cmd-d</code></pre>
<p>The standard board is loaded when the Mac app is started, you can also quickly switch to it via <code>Cmd-d</code>.</p>
<p>#trello</p>
<hr />
<h4 id="good-favicon-generator-checker">Good favicon generator / checker</h4>
<p><a href="https://realfavicongenerator.net/">RealFaviconGenerator</a></p>
<p>#bookmarks</p>
<hr />
<h4 id="print-the-default-html-template-for-pandoc">Print the default Html template for Pandoc</h4>
<pre><code>pandoc --print-default-template html</code></pre>
<p>Redirect it to a file, then adapt the template (e.g. to add a favicon). Then later include the template with</p>
<pre><code>pandoc --template=FILE</code></pre>
<p>#pandoc</p>
<hr />
<h4 id="tell-emacs-to-make-script-files-executable-upon-saving">Tell Emacs to make script files executable upon saving</h4>
<pre><code>(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)</code></pre>
<p>This will add a hook that checks if a the text contained in a buffer looks like a script (it does this by testing if the text starts with a shebang). If yes and the corresponding file is not executable yet it will make it executable.</p>
<p>#emacs</p>
<hr />
<h4 id="how-to-make-the-font-larger-or-smaller-in-emacs">How to make the font larger or smaller in Emacs</h4>
<ul>
<li>To increase font size for the current buffer in Emacs, use <code>C-x C-+</code></li>
<li>To decrease font size for the current buffer in Emacs, use <code>C-x C--</code></li>
<li>To reset font size to the default, use <code>C-x C-0</code></li>
</ul>
<p>In practice, I hit <code>C-x</code>, hold the control key pressed, then just press <code>+</code> and <code>-</code> repeatedly (much like <code>Cmd-+</code> / <code>Cmd--</code> for Mac apps works).</p>
<p>#emacs</p>
</body>
</html>