Skip to content

Instantly share code, notes, and snippets.

Avatar

Theodore Keloglou sirodoht

View GitHub Profile
@sirodoht
sirodoht / django-csrf.js
Created Nov 7, 2017
Get CSRF token from Django HTML templates with vanilla JS
View django-csrf.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 / migrate-django.md
Last active Jul 24, 2020
How to migrate Django from SQLite to PostgreSQL
View migrate-django.md

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 / dokku-commands.sh
Last active May 31, 2020
Dokku config commands
View dokku-commands.sh
# config with restart
dokku config:set mataroa SECRET_KEY=''
# config no restart
dokku config:set --no-restart mataroa EMAIL_HOST_USER=''
dokku config:set --no-restart mataroa EMAIL_HOST_PASSWORD=''
# run command
dokku run mataroa python manage.py createsuperuser --email zf@sirodoht.com --username sirodoht
@sirodoht
sirodoht / vscode.json
Last active May 20, 2020
VSCode settings JSON configuration
View vscode.json
{
"window.zoomLevel": 0,
"window.newWindowDimensions": "maximized",
"window.restoreWindows": "none",
"editor.cursorStyle": "block",
"editor.dragAndDrop": false,
"editor.minimap.size": "fill",
"editor.minimap.showSlider": "always",
"editor.renderWhitespace": "selection",
"editor.renameOnType": false,
@sirodoht
sirodoht / lighter.css
Created May 18, 2020
new.css lite version without fonts and minification https://newcss.net/
View lighter.css
:root {
--text-color: #1a1a1a;
--light-grey-color: #f6f8fa;
--grey-color: #e5e7eb;
--link-color: #0070f3;
--link-accent-color: #0366d6;
--light-cyan-color: #79ffe1;
--dark-cyan-color: #0c4047;
}
@sirodoht
sirodoht / index.html
Last active May 13, 2020
Basic HTML/CSS boilerplate with Normalize.css
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
View keys.pub-link
View textmate-defaults.md

Textmate default settings

Exclude files matching

{*.{o,pyc},Icon\r,CVS,_darcs,_MTN,\{arch\},blib,*\~.nib}

Include files matching

View vscode-keybindings.json
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "cmd+k i",
"command": "workbench.files.action.collapseExplorerFolders"
},
{
"key": "ctrl+down",
"command": "scrollLineDown",
"when": "textInputFocus"
View maccy_preference.sh
defaults write org.p0deje.Maccy hotKey control+command+c
defaults write org.p0deje.Maccy historySize 50
defaults write org.p0deje.Maccy popupPosition center
You can’t perform that action at this time.