Site Tools


Hotfix release available: 2024-02-06a "Kaos". upgrade now! [55.1] (what's this?)
New release available: 2024-02-06 "Kaos". upgrade now! [55] (what's this?)
onny:notizen:programmierung

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
onny:notizen:programmierung [2022/03/08 11:22] – [wordpress] 46.223.163.98onny:notizen:programmierung [2023/11/07 15:40] (current) – [sql] 127.0.0.1
Line 56: Line 56:
 date = datetime.datetime.now().strftime("%d.%m.%Y") date = datetime.datetime.now().strftime("%d.%m.%Y")
 </code> </code>
 +
 requests requests
 +
 <code python> <code python>
 import requests import requests
Line 66: Line 68:
 if (upstream_head.headers['content-type'] == "text/html;charset=UTF-8" or upstream_head.headers['content-type'] == "text/html; charset=UTF-8"): if (upstream_head.headers['content-type'] == "text/html;charset=UTF-8" or upstream_head.headers['content-type'] == "text/html; charset=UTF-8"):
     upstream_response = upstream_response.replace("//thepiratebay.org","")     upstream_response = upstream_response.replace("//thepiratebay.org","")
 +</code>
 +
 +class example
 +
 +<code python>
 +class Planday:
 +  auth_url = 'https://id.planday.com/connect/token'
 +  client_id = '1234'
 +  access_token = ''
 +
 +  def authenticate(self):
 +    payload = {
 +      'client_id': self.client_id,
 +      'refresh_token': 'qyS6qt9yNEqygE1mMQtRzA',
 +      'grant_type': 'refresh_token'
 +    }
 +    headers = {
 +      'Content-Type': 'application/x-www-form-urlencoded'
 +    }
 +    session = requests.session()
 +    session.trust_env = False
 +    response = session.request("POST", self.auth_url, headers=headers, data=payload)
 +    response = json.loads(response.text)
 +    self.access_token = response['access_token']
 +
 +planday = Planday()
 +planday.authenticate()
 </code> </code>
 ==== ponyorm ==== ==== ponyorm ====
Line 176: Line 205:
 </code> </code>
 ===== 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 || {}));
 </code> </code>
-jquery select by attribute content+ 
 +on document ready 
 <code javascript> <code javascript>
-$( "tr[data-id='"+data[station]["stationid"]+"']" ).remove(); +document.addEventListener("DOMContentLoaded", function() { 
-</code> +  your_function(...);
-jquery select dynamicly loaded ajax elements +
-<code javascript> +
-$('body').on('click','.btn + :not([class=disabled])', function() { +
-  var link = $(this).attr('src'); +
-  load_page(link);+
 }); });
 +
 </code> </code>
-jquery set background color + 
-<code javascript> +change content text 
-$(this).parent().css("background-color", "yellow"); +
-</code> +
-print mixed objects +
-<code javascript> +
-console.log('%d: %s', i, value); +
-</code> +
-javascript document ready +
-<code javascript> +
-$(document).ready(function(){ +
-  console.log('ready'); +
-}); +
-</code> +
-vanilla js change content text+
 <code javascript> <code javascript>
     var webgl_field = document.getElementById('webgl');     var webgl_field = document.getElementById('webgl');
Line 226: Line 243:
     }     }
 </code> </code>
-vanilla js ajax post form+ 
 +ajax post form 
 <code javascript> <code javascript>
     document.getElementById('form').onsubmit = function (evt) {     document.getElementById('form').onsubmit = function (evt) {
Line 244: Line 263:
     }     }
 </code> </code>
-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,100); var string = string.substring(0,100);
 </code> </code>
  
-vanilla js onclick class element+onclick class element 
 <code javascript> <code javascript>
 document.getElementsByClassName('navbar-burger')[0].onclick = function(){ document.getElementsByClassName('navbar-burger')[0].onclick = function(){
   console.log('ready');   console.log('ready');
 }; };
 +</code>
 +
 +onclick on all class elements
 +
 +<code javascript>
 +# old: var anchors = document.getElementsByClassName('wp-block-navigation-item__content');
 +let allCheckBox = document.querySelectorAll('.shapes')
 +
 +  allCheckBox.forEach((checkbox) => { 
 +  checkbox.addEventListener('change', (event) => {
 +    if (event.target.checked) {
 +      console.log(event.target.value)
 +    }
 +  })
 +})
 +</code>
 +
 +remove class from element
 +
 +<code javascript>
 +var element = document.getElementsByClassName('wp-block-navigation__responsive-container')[0];
 +element.classList.remove("is-menu-open");
 +</code>
 +
 +get url and pathname
 +
 +<code javascript>
 +console.log(window.location.url)
 +console.log(window.location.pathname)
 +</code>
 +
 +querySelector, get child element
 +
 +<code javascript>
 +var h3 = document.querySelector('div.multicolumn ul li:nth-child(1) h3')
 +console.log(h3.textContent);
 +h3.querySelector('span');
 +</code>
 +
 +querySelectorAll
 +
 +<code javascript>
 +var productAccordion = document.querySelectorAll('div.product__accordion');
 +productAccordion[1].style.display = "none";
 +</code>
 +
 +get next or previous element
 +
 +<code javascript>
 +document.getElementById('foo2').nextSibling; // #foo3
 +document.getElementById('foo2').previousSibling; // #foo1
 </code> </code>
 ==== vuejs ==== ==== vuejs ====
Line 440: Line 514:
       }       }
 </code> </code>
-===== css ===== 
-sweet font styling 
-<code css> 
-font-family: consolas,Menlo-Regular,Menlo,Monaco,monospace; 
-    font-size: 125%; 
-    line-height: 135%; 
-</code> 
-media queries, page greater than 600px 
-<code css> 
-      @media (min-width: 600px) { 
-        article { 
-          min-width: 600px; 
-        } 
-      } 
-</code> 
-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:opacity 250ms ease-out; 
- padding: 20px; 
- z-index: 2; 
- left: 17px; 
- background: white; 
-} 
  
-.main-navigation ul li:hover ul.sub-menu { 
- opacity: 1; 
- transition:opacity 250ms ease-out; 
-} 
-</code> 
- 
-responsive grid layout 
-<code> 
-ul { 
- display: grid; 
- grid-gap: 50px 40px; 
- grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); 
-} 
-</code> 
 ===== php ===== ===== php =====
 enable debugging / error log enable debugging / error log
Line 701: Line 734:
  
 add_action( 'customize_register', 'theme_customize_register' ); add_action( 'customize_register', 'theme_customize_register' );
 +</code>
 +
 +add custom javascript js
 +
 +<code php>
 +function twentytwentytwo_enqueue_custom_js() {
 +    wp_enqueue_script('custom', get_stylesheet_directory_uri().'/inc/js/main.js');
 +}
 +
 +add_action( 'wp_enqueue_scripts', 'twentytwentytwo_enqueue_custom_js' );
 </code> </code>
 ===== sql ===== ===== sql =====
-Update field: 
-<code sql> 
-update forwardings set destination='alex.bloss@online.de' where 'destination=bloss@bigwood.de'; 
-</code> 
-Insert field: 
-<code sql> 
-insert into forwardings (source, destination) VALUES ('markus.heim@wew-heim.de', 'heimmarkus@yahoo.de'); 
-insert into forwardings VALUES ('markus.heim@wew-heim.de', 'heimmarkus@yahoo.de'); 
-</code> 
-Delete row: 
-<code sql> 
-delete from domains where domain='alex-vt.de'; 
-</code> 
 <code sql> <code sql>
 mysql> \P /usr/bin/less mysql> \P /usr/bin/less
Line 736: Line 766:
  
 ==== mysql ==== ==== mysql ====
- 
-Dump database 
-<code bash> 
-mysqldump -u root -p Tutorials > tut_backup.sql 
-</code> 
- 
-Backup everything 
-<code bash> 
-mysqldump -u root -p --all-databases > alldb.sql 
-</code> 
- 
-Import database 
-<code> 
-mysql> CREATE DATABASE wordpress; 
-sudo mysql -u root wordpress < wordpress.sql 
-</code> 
- 
-Setup 
-<code bash> 
-systemctl stop mysqld 
-mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql 
-systemctl start mysqld 
-mysql_secure_installation 
-</code> 
  
 delete specific row delete specific row
Line 771: Line 777:
 </code> </code>
  
-==== postgresql ==== +adjust permissions to table 
- +<code sql
-drop database +CREATE USER 'ninja'@'http.pi' IDENTIFIED BY '****'; 
-<code bash+GRANT ALL PRIVILEGES ON ninja.* TO 'ninja'@'http.pi' identified by '123'; 
-sudo -u postgres -i +GRANT ALL PRIVILEGES ON ninja.* TO 'ninja'@'http.pi'; 
-dropdb onlyoffice+FLUSH PRIVILEGES;
 </code> </code>
  
-list databases +update statement
-<code> +
-psql# \l +
-</code>+
  
-dump database +<code sql
-<code> +UPDATE wp_options SET option_value = 'info@example.org' WHERE option_name = 'admin_email';
-pg_dump -U gitlab gitlabhq_production > /tmp/gitlab.pgsql+
 </code> </code>
  
-dump all 
-<code> 
-pg_dumpall > /tmp/dump_file_name.tar 
-</code> 
- 
-import database 
-<code> 
-psql# CREATE DATABASE gitlabhq_production; 
-psql -U gitlab gitlabhq_production < gitlab.pgsql 
-</code> 
- 
-create and delete user 
-<code> 
-DROP ROLE gitlab; 
-CREATE USER gitlab WITH PASSWORD '5V0hD0KWX81g5dhKGHsbqU4a'; 
-</code> 
- 
-grant permissions 
-<code> 
-ALTER USER gitlab SUPERUSER; 
-CREATE DATABASE gitlabhq_production OWNER gitlab; 
-ALTER DATABASE gitlabhq_production OWNER TO gitlab; 
-</code> 
onny/notizen/programmierung.1646738541.txt.gz · Last modified: 2022/03/08 11:22 by 46.223.163.98