put a key in dictionary into another key and remove it from dictionary:
Idiots way:
Tech C**P way:
#pop #python #dictionary #code_improvement
Idiots way:
data = {
'username': 'alireza@gmail.com'
}
data['email'] = data['username']
del data['username']
Tech C**P way:
data = {
'username': 'alireza@gmail.com'
}
data['email'] = data.pop('username')
pop
access the data and remove it from data payload. In case username
is not in data, an error will be raised. To prevent such an error give it default value:data['email'] = data.pop('username', 'NO_USERNAME')
#pop #python #dictionary #code_improvement
Did you know you can syntax highlight your codes in google docs using an add on?
This is
After installation
Happy syntax highlighting! :D
#google #code #syntax_highlight #code_block #addon #google_doc
This is
code block
! An addon that adds syntax highlighting to your documents. In order to download it, go to Add-ons
menu in google docs and click on Get add-ons
. Search for code block and install it.After installation
Code Block
option will be added to Add-ons
menu. Click it and hit Start
. Now you will have a great syntax highlighting right in your toolbox. :)Happy syntax highlighting! :D
#google #code #syntax_highlight #code_block #addon #google_doc
Have you ever wanted to syntax highlight text area with specific content in it? Let's say it contains json data. We also need to have
code folding (+/- in front of objects to collapse them). The tool that can be used for this purpose is
- https://codemirror.net/index.html
One of the things that I want to note here is that textarea wont get updated when you enter data in codeMirror field. For that you need to call save() method of codeMirror like below:
Download all the demos from github:
- https://github.com/codemirror/codemirror
Instead of myEditor change you can update textarea on form submit.
#syntax_highlighting #syntax #codeMirror #code_folding
code folding (+/- in front of objects to collapse them). The tool that can be used for this purpose is
codeMirror
:- https://codemirror.net/index.html
One of the things that I want to note here is that textarea wont get updated when you enter data in codeMirror field. For that you need to call save() method of codeMirror like below:
var myEditor = CodeMirror.fromTextArea(page_content, {
lineNumbers: true,
mode: "markdown",
lineWrapping: true,
lineNumbers:false,
indentWithTabs: true
});
function updateTextArea() {
myEditor.save();
}
myEditor.on('change', updateTextArea);
Download all the demos from github:
- https://github.com/codemirror/codemirror
Instead of myEditor change you can update textarea on form submit.
#syntax_highlighting #syntax #codeMirror #code_folding
codemirror.net
In-browser code editor