This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
onny:notizen:programmierung [2022/03/08 11:26] – [wordpress] 46.223.163.98 | onny:notizen:programmierung [2023/03/08 12:59] – [javascript] 10.100.0.1 | ||
---|---|---|---|
Line 56: | Line 56: | ||
date = datetime.datetime.now().strftime(" | date = datetime.datetime.now().strftime(" | ||
</ | </ | ||
+ | |||
requests | requests | ||
+ | |||
<code python> | <code python> | ||
import requests | import requests | ||
Line 66: | Line 68: | ||
if (upstream_head.headers[' | if (upstream_head.headers[' | ||
upstream_response = upstream_response.replace("// | upstream_response = upstream_response.replace("// | ||
+ | </ | ||
+ | |||
+ | class example | ||
+ | |||
+ | <code python> | ||
+ | class Planday: | ||
+ | auth_url = ' | ||
+ | client_id = ' | ||
+ | access_token = '' | ||
+ | |||
+ | def authenticate(self): | ||
+ | payload = { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | headers = { | ||
+ | ' | ||
+ | } | ||
+ | session = requests.session() | ||
+ | session.trust_env = False | ||
+ | response = session.request(" | ||
+ | response = json.loads(response.text) | ||
+ | self.access_token = response[' | ||
+ | |||
+ | planday = Planday() | ||
+ | planday.authenticate() | ||
</ | </ | ||
==== ponyorm ==== | ==== ponyorm ==== | ||
Line 176: | Line 205: | ||
</ | </ | ||
===== javascript ===== | ===== javascript ===== | ||
+ | |||
split up javascript files | split up javascript files | ||
+ | |||
<code javascript> | <code javascript> | ||
var MODULE = (function (my) { | var MODULE = (function (my) { | ||
Line 192: | Line 223: | ||
}(MODULE || {})); | }(MODULE || {})); | ||
</ | </ | ||
- | jquery select by attribute content | + | |
+ | on document ready | ||
<code javascript> | <code javascript> | ||
- | $( "tr[data-id=' | + | document.addEventListener("DOMContentLoaded", function() { |
- | </ | + | |
- | jquery select dynamicly loaded ajax elements | + | |
- | <code javascript> | + | |
- | $(' | + | |
- | | + | |
- | load_page(link); | + | |
}); | }); | ||
+ | |||
</ | </ | ||
- | jquery set background color | + | |
- | <code javascript> | + | change content text |
- | $(this).parent().css(" | + | |
- | </ | + | |
- | print mixed objects | + | |
- | <code javascript> | + | |
- | console.log(' | + | |
- | </ | + | |
- | javascript document ready | + | |
- | <code javascript> | + | |
- | $(document).ready(function(){ | + | |
- | console.log(' | + | |
- | }); | + | |
- | </ | + | |
- | vanilla js change content text | + | |
<code javascript> | <code javascript> | ||
var webgl_field = document.getElementById(' | var webgl_field = document.getElementById(' | ||
Line 226: | Line 243: | ||
} | } | ||
</ | </ | ||
- | vanilla js ajax post form | + | |
+ | ajax post form | ||
<code javascript> | <code javascript> | ||
document.getElementById(' | document.getElementById(' | ||
Line 244: | Line 263: | ||
} | } | ||
</ | </ | ||
- | vanilla js change style element | + | |
+ | change style element | ||
<code javascript> | <code javascript> | ||
function show_create_post() { | function show_create_post() { | ||
Line 257: | Line 278: | ||
trim string to max length | trim string to max length | ||
+ | |||
<code javascript> | <code javascript> | ||
var string = string.substring(0, | var string = string.substring(0, | ||
</ | </ | ||
- | vanilla js onclick class element | + | onclick class element |
<code javascript> | <code javascript> | ||
document.getElementsByClassName(' | document.getElementsByClassName(' | ||
console.log(' | console.log(' | ||
}; | }; | ||
+ | </ | ||
+ | |||
+ | onclick on all class elements | ||
+ | |||
+ | <code javascript> | ||
+ | # old: var anchors = document.getElementsByClassName(' | ||
+ | let allCheckBox = document.querySelectorAll(' | ||
+ | |||
+ | allCheckBox.forEach((checkbox) => { | ||
+ | checkbox.addEventListener(' | ||
+ | if (event.target.checked) { | ||
+ | console.log(event.target.value) | ||
+ | } | ||
+ | }) | ||
+ | }) | ||
+ | </ | ||
+ | |||
+ | remove class from element | ||
+ | |||
+ | <code javascript> | ||
+ | var element = document.getElementsByClassName(' | ||
+ | element.classList.remove(" | ||
+ | </ | ||
+ | |||
+ | get url and pathname | ||
+ | |||
+ | <code javascript> | ||
+ | console.log(window.location.url) | ||
+ | console.log(window.location.pathname) | ||
+ | </ | ||
+ | |||
+ | querySelector, | ||
+ | |||
+ | <code javascript> | ||
+ | var h3 = document.querySelector(' | ||
+ | console.log(h3.textContent); | ||
+ | h3.querySelector(' | ||
+ | </ | ||
+ | |||
+ | querySelectorAll | ||
+ | |||
+ | <code javascript> | ||
+ | var productAccordion = document.querySelectorAll(' | ||
+ | productAccordion[1].style.display = " | ||
</ | </ | ||
==== vuejs ==== | ==== vuejs ==== | ||
Line 703: | Line 770: | ||
</ | </ | ||
- | print setting text inside template | + | add custom javascript js |
<code php> | <code php> | ||
- | <?php echo get_option('fachwerksauna_footer-text' | + | function twentytwentytwo_enqueue_custom_js() { |
+ | wp_enqueue_script(' | ||
+ | } | ||
+ | |||
+ | add_action( ' | ||
</ | </ | ||
===== sql ===== | ===== sql ===== | ||
Line 741: | Line 813: | ||
==== mysql ==== | ==== mysql ==== | ||
- | |||
- | Dump database | ||
- | <code bash> | ||
- | mysqldump -u root -p Tutorials > tut_backup.sql | ||
- | </ | ||
- | |||
- | Backup everything | ||
- | <code bash> | ||
- | mysqldump -u root -p --all-databases > alldb.sql | ||
- | </ | ||
- | |||
- | Import database | ||
- | < | ||
- | mysql> CREATE DATABASE wordpress; | ||
- | sudo mysql -u root wordpress < wordpress.sql | ||
- | </ | ||
- | |||
- | Setup | ||
- | <code bash> | ||
- | systemctl stop mysqld | ||
- | mysql_install_db --user=mysql --basedir=/ | ||
- | systemctl start mysqld | ||
- | mysql_secure_installation | ||
- | </ | ||
delete specific row | delete specific row | ||
Line 776: | Line 824: | ||
</ | </ | ||
- | ==== postgresql ==== | + | adjust permissions to table |
- | + | < | |
- | drop database | + | CREATE USER ' |
- | < | + | GRANT ALL PRIVILEGES ON ninja.* TO ' |
- | sudo -u postgres -i | + | GRANT ALL PRIVILEGES ON ninja.* TO ' |
- | dropdb onlyoffice | + | FLUSH PRIVILEGES; |
</ | </ | ||
- | list databases | + | update statement |
- | < | + | |
- | psql# \l | + | |
- | </ | + | |
- | dump database | + | < |
- | < | + | UPDATE wp_options SET option_value = ' |
- | pg_dump -U gitlab gitlabhq_production > /tmp/gitlab.pgsql | + | |
</ | </ | ||
- | dump all | ||
- | < | ||
- | pg_dumpall > / | ||
- | </ | ||
- | |||
- | import database | ||
- | < | ||
- | psql# CREATE DATABASE gitlabhq_production; | ||
- | psql -U gitlab gitlabhq_production < gitlab.pgsql | ||
- | </ | ||
- | |||
- | create and delete user | ||
- | < | ||
- | DROP ROLE gitlab; | ||
- | CREATE USER gitlab WITH PASSWORD ' | ||
- | </ | ||
- | |||
- | grant permissions | ||
- | < | ||
- | ALTER USER gitlab SUPERUSER; | ||
- | CREATE DATABASE gitlabhq_production OWNER gitlab; | ||
- | ALTER DATABASE gitlabhq_production OWNER TO gitlab; | ||
- | </ |