Skip to content

Instantly share code, notes, and snippets.

View metodribic's full-sized avatar

Metod Ribič metodribic

  • Working at Better
  • Slovenia
View GitHub Profile
@metodribic
metodribic / fullbleed.css
Last active June 20, 2022 07:00
Full bleed box-shadow + clip-path technique
.full-bleed-background {
--c: red;
background: var(--c);
/* Stretched box shadow */
box-shadow: 0 0 0 100vmax var(--c);
/* Clip only the top and the bottom */
clip-path: inset(0 -100vmax);
}
@metodribic
metodribic / docker-compose.yaml
Created October 30, 2020 06:52
Odoo 13 docker compose with mounted custom addon
version: '3'
services:
db:
image: postgres:11
environment:
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- POSTGRES_DB=postgres
restart: always
odoo:
@metodribic
metodribic / event.util.ts
Created October 13, 2020 06:32
Utils for dealing with keyboard events and figuring out what was pressed
export const enum KeyCodes {
BACKSPACE = 8,
TAB = 9,
ENTER = 13,
SPACE = 32,
DELETE = 46
}
export class EventUtil {
@metodribic
metodribic / docker-odoo.md
Created September 2, 2020 18:45
Docker Odoo commands

Advanced

Image is available on docker hub

Postgres

docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name db postgres:10

Odoo

@metodribic
metodribic / transparent.css
Created August 14, 2020 16:47
Transparent div style
background: linear-gradient(to top, #fff, rgba(255,255,255,0));
@metodribic
metodribic / atribute_selectors.css
Created February 3, 2020 06:17
CSS attribute selectors
// This attribute exist on the element
[value]
// This attribute has a specific value of cool
[value='cool]
// This vlaue attribute contains word cool
[value*='cool]
// This vlaue attribute contains word cool in a space-separated list
async download(image: string) {
const result = await fetch(`data:image/png;base64,${image}`);
const blob = await result.blob();
const a = document.createElement('a');
a.href = URL.createObjectURL(blob);
a.download = name;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
/* Suitable for wide range of webapps */
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
/* Serifs */
font-family: "MillerDisplay Light", Helvetica, Arial, sans-serif
/* https://pock.dev/ */
font-family: 'Open Sans', sans-serif;
/* https://www.airship.com*/
<!-- wInViewRoot directive is needed to specify the `root` for `IntersectionObserver` and some other it's options e.g. `margin` -->
<div class="container" wInViewRoot="viewport">
Any content can be here
<w-in-view-item>
<!-- Content will be replaced by a placeholder <div> with the same height as original content.
Also `InViewItemComponent`s change detector will be detached when it become invisible which means
all the content's change detectors won't be reachable and will be inactive as well. -->
</w-in-view-item>
...or any other content can be here
<w-in-view-item>
@metodribic
metodribic / copy.js
Created January 9, 2019 20:32
Copy text to clipboard with pure JavaScript
function copy(text) {
const textarea = document.createElement("textarea");
textarea.style.opacity = '0';
textarea.style.position = 'fixed';
textarea.textContent = text;
const body = document.getElementsByTagName('body')[0];
body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
body.removeChild(textarea);