Hello powerful space mango!

: Clippy, bash / zsh commands, CSS Color

CSS Color

/* alpha syntax */
color: rgba(255, 0, 255 / 75%); /* vs. rgba(…) */
color: rgba(255, 0, 255 / .75);

/* (HDR) color modes */
color: color(display-p3 1 0 1); /* vs. #F0F */

/* new color functions */
color: oklch(71.5% 0.35 330); /* vs. #F0F */

/* utilities */
color: color-mix(in lch, #F0F, white 20%);

/*
 * keep a tab on …  
 */

/* relative color syntax */
color: lch(from #F0F l calc(c + 75) h); /* increaces chroma by 75 */

/* color contrast */ 
color: color-contrast(var(--bg) vs #F0F, hotpink); /* pick the color that contrasts the most with --bg, choose between #F0F and hotpink)

Clippy

CSS

  • color-mix(in srgb, red 25%, blue)

CSS x JS

  • change custom property on :root/html: document.documentElement.style.setProperty(--var-name, val)

VIM basics

  • Exiting: :q,
    • modified/force: :q!
    • write changes + quit :wq
  • Modes:
    • Insert (i)
      • esc back to normal mode
      • +p paste from clipboard
    • Command (:)
    • Visual (v)
  • Deleting
    • character: x
    • line dd
  • Undo: u
  • Saving: :w
  • Commnads
    • Go to line 2 :2
    • running shell command :!<command>
  • Settings
    • show linenumbers :set number

Source

resources clipboard 📋

PHP Clipboard

Random selected notes regarding PHP

  • use str_contains to check if a string contains a string (instad of strpos) (8.x)
  • named parameters allows parameter supply in any order
    • function someFunc(string $value, array $options) -> someFunc(options: $opt, value: $val)

Vue Basics (Worksheet)

Resources & Infos

Terminology

  • State Management => All data in one place = Store = Single-Source-of-Truth
  • SPA / MPA – Single Page Application / Multi Page Application

Vue root instance

new Vue({
   el: '#app',
   data: {
     // supplied data
     entries: datahere
   },
   computed: {
     // computed data, will be updated if data changes
   },
   methods: {
     // custom functions
   }
})
<!-- SCOPE: -->
<div id="app">
   <!-- accessible by vue -->
</div>
<div id="something">
   <!-- NOT accessible by vue -->
</div>
(mehr …)

Link mixing bowl

Data

Testig & Security

More

Scala on macOS / OSX

Install (w. homebrew)

  1. First, check if the reqired Java version is instaled java --version . Scala requires at least Version 1.8.
    If not, install AdoptOpenJDK with Homebrew Cask: brew cask install adoptopenjdk
  2. Install scala: brew install scala
  3. Verify with scala -version or running directly scala and outputting something like println("Moshi moshi").

Run script files

First compile with scalac providing filename/-path (including extension). This generates a file with the class name in the folder defined in the package entry (or, if omitted, in the same as the scala file) then run it by calling scala followed by the method name (without extension)

scalac script.scala
scala script

Scriptfile anatomy

// package name
package ch.lrnz.example // binary will be generated in ch/lrnz/example

// imports
import import ch.lrnz.example.Functions // all, as 'package'
import import ch.lrnz.example.Utils._   // all, as single classes/methods
import java.util.Date


object myObject {

  def main(args:Array[String]): Unit = {
      // Void. 
      // Needed somehow? Otherwise: Compiling Error.
  }

  def myMethod(param1:Double,param2:Double):Double = {
    // do sth and be sure to return a Double.
  }

}

ImageMagick (command line)

To get started

Compressing

magick source.jpg -strip -interlace Plane -gaussian-blur 0.05 -quality 60% result.jpg

source

Batch processing (=> mogrify)

mogrify -quality 60 -density 72 -strip -resize 2500x1500\> -path ../foto-compressed *.jpg

In prose: This example sets the image quality to 60% and the dpi to 72, strips exif infos et al (only for png?) resizes the image if dimensions are bigger than 2500px w or 1500px heigh (keeping the aspect ratio [default]) and saving the news files at the specified (here: relative) path

Note the difference between the -densinty and the -resample option.

Combining

blend modes

-compose <blendmode>

convert img1.png imgN.png -compose multiply -composite imgOut.png

Note: whithout -composite, every layer would be outputet separately

List all blend modes with identify -list compose

Source

opacity

convert img1.png \( img2.png -alpha set -channel A -evaluate set 60% \) -composite imgOut.png

or:

convert img1.png \( img2.png -normalize +level 0,60% \) -composite imgOut.png

(not tested). Source

Notes on greener Websites

Notes from Tom Greenwood: Zero Carbon Emission talk (WordCamp Europe 2017)

  • Internet carbon emission is approx. the same as Germany or Turkey (the worlds 6. in electicity use [behind CN, US, India, Japan, Russia]) with a total emisson of 300 milion tonns of CO2 [2016/17]
  • WordPress makes up for about 27% of the Internet [2017]
  • The main electricity culprits are probably streaming services linke YouTube, Amazon Prime …
  • Reduce Filesize, cache, remove unused files (media library)
    • Because data = energy = carbon
    • cache: plugin (wp super cache / w3total) and server-side (varnish)
  • «Carbon offset» = (financially) compensate for energy usage / co2 emission by supporting renewable energy (companies) or the reduction of co2

Literature

  • Designing for sustainability

Links

CodeKit extensions

Uglify for ES6+

Reason: The built in uglify lib does not support ES6+ and throws an error if it stumbles upon something like const.

Solution: Use the uglify harmony branch (uglify-es) instead via a CodeKit hook

  1. Check if uglify-es ist already installed: npm list -g uglify-es . If not install it globaly: npm install uglify-es -g (see the harmony repository )
  2. Add a new hook in the CodeKit project peferences to run a shell script on any file which inputFileName ends with .js
  3. Use the following script to compress and mangle this file  uglifyjs $CK_INPUT_PATH --compress --mangle -o $CK_OUTPUT_PATH

See the Comandline Usage section of the uglify-es repo for more options and the CodeKit hook help for constants for the CodeKit part of the deal.


SSH

generate (macOS)

  • Terminal: run ssh-keygen
  • use default location
  • list keys: ls ~/.ssh
  • copy key with: cat ~/.ssh/id_rsa.pub | pbcopy
  • Add key to ssh-agent (so the passphrase doesn’t have to be typed in every single time)
    • Start Agent: eval ssh-agent
    • ssh-add -K ~/.ssh/<private key>
    • write to config file code ~/.ssh/config :
Host *
  seKeychain yes
   AddKeysToAgent yes
   IdentityFile ~/.ssh/id_rsa

see: Atlassian

add to server

ssh-copy-id user@server

=> Client public key will be copied to server’s location ~/.ssh/authorized_keys

connect to server

ssh user@server

Spotify API

Quick notes to start using the spotify web API

Checkout

updated: 08.04.2018

Front-End Checklist

thedaviddias/Front-End-Checklist

iOS 8 supports video Autoplay …

when

  • video is muted – either through the 'muted' attribute or has no soundtrack at all
  • video is visible – in viewport or by css/js

see: New <video> Policies for iOS on webkit.org (25.7.16)

According to Paul Irish, autoplay is now supported across mobile browsers:

https://twitter.com/paul_irish/status/920738485551509505

Strukturierte Daten (schema.org)

  • Container: itemscope itemtype="http://schema.org/Restaurant"
  • Item: itemprop='xxyyzz' (content=’xxyyzz‘)
  • Nested Container itemprop='xxyyzz'itemscope itemtype="..."
  • Wenn es nicht möglich ist, das itemprop  auf ein item zu legen (da z.B. von WP generiert): meta-tag <meta itemprop="..." >  verwenden

Links

ob_start ( php Ausgabepuffer)

Während die Ausgabepufferung aktiv ist werden Scriptausgaben (mit Ausnahme von Headerinformationen) nicht direkt an den Client weitergegeben sondern in einem internen Puffer gesammelt. [php.net]

  • ob_start()  – Aktiviert/startet Ausgabepuffer (callback parameter möglich, siehe php.net Beispiel)
  • ob_get_contents()  – gibt puffer als String zurück
  • ob_flush() / ob_end_flush()  – gibt den Puffer an client aus (bei ersterem bleibt Ausgabepuffer erhalten)
  • ob_end_clean()  – löscht den Puffer

(mehr …)

Mobile menues

CSS only Hamburger Menues

  • Animating CSS-Only Hamburger Menu Icons – callmenick.com (Demo)

    Less: Hamburger -> X

    @menu-toggle_width: 48px;
    @menu-toggle_height: @menu-toggle_width;
    @menu-toggle_bar-height: 4px;
    @menu-toggle_padding-horz: 9px;
    @menu-toggle_spacing: 8px;
    @menu-toggle_color: #fff;
    @menu-toggle_transition-duration: 250ms;
    
    .menu-toggle {
        display: block;
        position: fixed;
        overflow: hidden;
        right: 0;
        top: 0;
        margin: 0;
        padding: 0;
        width: @menu-toggle_width;
        height: @menu-toggle_height;
        font-size: 0;
        text-indent: -9999px;
        appearance: none;
        box-shadow: none;
        border-radius: none;
        border: none;
        cursor: pointer;
        transition: background @menu-toggle_transition-duration;
        z-index: 99;
    
        &:focus {
            outline: none;
        }
    
        span {
            display: block;
            position: absolute;
            top: @menu-toggle_height/2 - @menu-toggle_bar-height/2;
            left: @menu-toggle_padding-horz;
            right: @menu-toggle_padding-horz;
            height: @menu-toggle_bar-height;
            background: @menu-toggle_color;
        
            &::before,
            &::after {
                position: absolute;
                display: block;
                left: 0;
                width: 100%;
                height: @menu-toggle_bar-height;
                background-color: @menu-toggle_color;
                content: "";
    
                transition-duration:@menu-toggle_transition-duration,@menu-toggle_transition-duration;
                transition-delay:@menu-toggle_transition-duration, 0s;
            }
    
            &::before {
                top: (@menu-toggle_spacing + @menu-toggle_bar-height/2)*-1;
                
                transition-property: top, transform;
            }
    
    
            &::after {
                bottom: (@menu-toggle_spacing + @menu-toggle_bar-height/2)*-1;
                
                transition-property: bottom, transform;
            }
    
    
        }
    
        .menu-open & {
            background-color: #cb0032;
    
            span {
                background: none;
    
                &::before {
                    top: 0;
                    transform: rotate(45deg);
                }
    
    
                &::after {
                    bottom: 0;
                    transform: rotate(-45deg);
                }
    
                &::before,
                &::after {
                    transition-delay: 0s, @menu-toggle_transition-duration;
                }
            }
    
        }
    
    }

     

xdebug

Install

[1]: xdebug.org/docs/install
[2]: packagecontrol.io/packages/Xdebug%20Client#xdebug