Hotfix release available: 2025-05-14b "Librarian".
upgrade now! [56.2] (what's this?)
Hotfix release available: 2025-05-14a "Librarian".
upgrade now! [56.1] (what's this?)
New release available: 2025-05-14 "Librarian".
upgrade now! [56] (what's this?)
onny:notizen:programmierung
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| onny:notizen:programmierung [2022/03/02 09:37] – [postgresql] 2a02:8071:3ecc:6e00:1a9:a89f:404c:a243 | onny:notizen:programmierung [2023/11/07 15:40] (current) – [sql] 127.0.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, | ||
| + | </ | ||
| + | |||
| + | onclick class element | ||
| + | |||
| + | <code javascript> | ||
| + | document.getElementsByClassName(' | ||
| + | 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 = " | ||
| + | </ | ||
| + | |||
| + | get next or previous element | ||
| + | |||
| + | <code javascript> | ||
| + | document.getElementById(' | ||
| + | document.getElementById(' | ||
| </ | </ | ||
| ==== vuejs ==== | ==== vuejs ==== | ||
| Line 433: | Line 514: | ||
| } | } | ||
| </ | </ | ||
| - | ===== css ===== | ||
| - | sweet font styling | ||
| - | <code css> | ||
| - | font-family: | ||
| - | font-size: 125%; | ||
| - | line-height: | ||
| - | </ | ||
| - | media queries, page greater than 600px | ||
| - | <code css> | ||
| - | @media (min-width: 600px) { | ||
| - | article { | ||
| - | min-width: 600px; | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | popover menu | ||
| - | <code css> | ||
| - | .main-navigation ul li ul.sub-menu { | ||
| - | opacity: 0; | ||
| - | position: absolute; | ||
| - | box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26); | ||
| - | transition: | ||
| - | padding: 20px; | ||
| - | z-index: 2; | ||
| - | left: 17px; | ||
| - | background: | ||
| - | } | ||
| - | .main-navigation ul li:hover ul.sub-menu { | ||
| - | opacity: 1; | ||
| - | transition: | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | responsive grid layout | ||
| - | < | ||
| - | ul { | ||
| - | display: grid; | ||
| - | grid-gap: 50px 40px; | ||
| - | grid-template-columns: | ||
| - | } | ||
| - | </ | ||
| ===== php ===== | ===== php ===== | ||
| enable debugging / error log | enable debugging / error log | ||
| Line 571: | Line 611: | ||
| [...] | [...] | ||
| + | | ||
| + | endif; | ||
| + | |||
| + | add_action( ' | ||
| </ | </ | ||
| Line 605: | Line 649: | ||
| } | } | ||
| </ | </ | ||
| - | ===== sql ===== | + | |
| - | Update field: | + | custom menu walker, only printing <a> tags without list items |
| - | <code sql> | + | <code php> |
| - | update forwardings set destination='alex.bloss@online.de' | + | class Nav_Footer_Walker extends Walker_Nav_Menu { |
| + | |||
| + | function start_lvl( & | ||
| + | $indent | ||
| + | $output .= " | ||
| + | } | ||
| + | |||
| + | function end_lvl( & | ||
| + | $indent | ||
| + | $output .= " | ||
| + | } | ||
| + | |||
| + | function start_el( & | ||
| + | | ||
| + | |||
| + | $class_names = $value = ''; | ||
| + | |||
| + | $classes = empty( $item-> | ||
| + | $classes[] = ' | ||
| + | |||
| + | $class_names = join( ' ', apply_filters( ' | ||
| + | $class_names = $class_names ? ' class="' | ||
| + | |||
| + | $id = apply_filters( ' | ||
| + | $id = $id ? ' id="' | ||
| + | |||
| + | $output .= $indent . ''; | ||
| + | |||
| + | $attributes | ||
| + | $attributes .= ! empty( $item-> | ||
| + | $attributes .= ! empty( $item-> | ||
| + | $attributes .= ! empty( $item-> | ||
| + | |||
| + | $item_output = $args-> | ||
| + | $item_output .= '<a class=" | ||
| + | | ||
| + | $item_output | ||
| + | $item_output .= $args-> | ||
| + | |||
| + | $output | ||
| + | } | ||
| + | |||
| + | |||
| + | function end_el( & | ||
| + | $output .= " | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | wp_nav_menu( array( | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ) ); | ||
| </ | </ | ||
| - | Insert field: | + | |
| - | < | + | customizer add option custom text |
| - | insert into forwardings | + | < |
| - | insert into forwardings VALUES | + | function theme_customize_register( $wp_customize |
| + | |||
| + | $wp_customize-> | ||
| + | | ||
| + | ' | ||
| + | ' | ||
| + | ),); | ||
| + | |||
| + | $wp_customize-> | ||
| + | $wp_customize, | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ) | ||
| + | ) ); | ||
| + | |||
| + | } | ||
| + | |||
| + | add_action( ' | ||
| </ | </ | ||
| - | Delete row: | + | |
| - | < | + | add custom javascript js |
| - | delete from domains where domain='alex-vt.de'; | + | |
| + | < | ||
| + | function twentytwentytwo_enqueue_custom_js() { | ||
| + | wp_enqueue_script('custom', | ||
| + | } | ||
| + | |||
| + | add_action( ' | ||
| </ | </ | ||
| + | ===== sql ===== | ||
| <code sql> | <code sql> | ||
| mysql> \P / | mysql> \P / | ||
| Line 639: | Line 766: | ||
| ==== 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 674: | Line 777: | ||
| </ | </ | ||
| - | ==== 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 > / | + | |
| - | </ | + | |
| - | + | ||
| - | 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; | ||
| - | </ | ||
onny/notizen/programmierung.1646213823.txt.gz · Last modified: 2022/03/02 09:37 by 2a02:8071:3ecc:6e00:1a9:a89f:404c:a243
