Skip to content

Instantly share code, notes, and snippets.

@sirodoht
sirodoht / bounce-up.css
Created December 19, 2017 17:38
Simple bounce up CSS animation
.bounce-up {
animation: bounce-up 3s infinite;
}
@keyframes bounce-up {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(-10px);
@sirodoht
sirodoht / tolltip.css
Last active January 4, 2018 15:42
CSS only simple tooltip from https://codepen.io/cbracco/pen/qzukg
/**
* Demo styles
* Not needed for tooltips to work
*/
/* `border-box`... ALL THE THINGS! */
html {
box-sizing: border-box;
}
@sirodoht
sirodoht / django-csrf.js
Created November 7, 2017 15:25
Get CSRF token from Django HTML templates with vanilla JS
function getCsrf() {
var inputElems = document.querySelectorAll('input');
var csrfToken = '';
for (i = 0; i < inputElems.length; ++i) {
if (inputElems[i].name === 'csrfmiddlewaretoken') {
csrfToken = inputElems[i].value;
break;
}
}
return csrfToken;
@sirodoht
sirodoht / django-gen-secret-key.py
Last active September 29, 2019 21:13
Generating a SECRET_KEY for Django.
#!/usr/local/bin/python3
import random
secret_key = ''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
print(secret_key)
@sirodoht
sirodoht / new-db-postgres.md
Last active July 30, 2021 09:15
How to create new database and new user with password on PostgreSQL (the easiest way)

How to create new database and new user with password on PostgreSQL

First, create db:

$ createdb avocado

Then, create user:

$ createuser avocado
@sirodoht
sirodoht / migrate-django.md
Last active April 20, 2024 09:52
How to migrate Django from SQLite to PostgreSQL

How to migrate Django from SQLite to PostgreSQL

Dump existing data:

python3 manage.py dumpdata > datadump.json

Change settings.py to Postgres backend.

Make sure you can connect on PostgreSQL. Then:

@sirodoht
sirodoht / max-call-stack.js
Created December 27, 2016 12:39
Compute call stack limit
function computeMaxCallStackSize() {
try {
return 1 + computeMaxCallStackSize();
} catch (e) {
// Call stack overflow
return 1;
}
}
computeMaxCallStackSize();
@sirodoht
sirodoht / embed-examples.html
Last active December 21, 2016 11:57
Web embed examples
<!-- Twitter single Tweet -->
<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">
<a href="https://twitter.com/hashtag/Overusing?src=hash">#Overusing</a> <a href="https://twitter.com/hashtag/hashtags?src=hash">#hashtags</a> can be <a href="https://twitter.com/hashtag/super?src=hash">#super</a> <a href="https://twitter.com/hashtag/annoying?src=hash">#annoying</a> 😩 Sticking to one or two per Tweet is a good call 😀</p>&mdash; Twitter Support (@Support) <a href="https://twitter.com/Support/status/613308058094039043">June 23, 2015</a>
</blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
<!-- Twitter Follow button -->
<a href="https://twitter.com/Support" class="twitter-follow-button" data-show-count="false">Follow @Support</a>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
Vim provides many ways to move the cursor. Becoming familiar with them leads to more effective text editing.
h move one character left
j move one row down
k move one row up
l move one character right
w move to beginning of next word
b move to previous beginning of word
e move to end of word
W move to beginning of next word after a whitespace

Keybase proof

I hereby claim:

  • I am sirodoht on github.
  • I am sirodoht (https://keybase.io/sirodoht) on keybase.
  • I have a public key ASDcpYHS9KAFzHS1HAOqlyqgLbuv6CXqQnxZtWDhAriFfQo

To claim this, I am signing this object: