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 / word-count-by-file-extension.sh
Created May 24, 2017 11:54
Count number of lines in files with specific extension
find . -name "*.ts" -print | xargs wc -l
@metodribic
metodribic / aql.sublime-syntax
Last active January 3, 2018 07:51
AQL syntax definition for sublime text 3
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions:
- aql
scope: source.aql
contexts:
# The prototype context is prepended to all contexts but those setting
# meta_include_prototype: false.
@metodribic
metodribic / .htaccess
Created June 1, 2018 06:04
Apache2 .htaccess for angular2 app hosted in subdirectories
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirectory
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdirectory/index.html [L]
</IfModule>
@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);
@metodribic
metodribic / remove_uniquie_raw.sh
Created August 24, 2018 16:05
Remove all CR2 (raw image) files if they don't have corresponding JPG sibling
#!/bin/bash
# Remove all CR2 (raw image) files if they don't have corresponding JPG sibling
allJpgs="$(ls|grep .JPG)"
allRaws="$(ls|grep .CR2)"
allowedRaws=()
for file in $allJpgs
do
allowedRaws+=(${file/JPG/CR2})
<!-- 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>
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);
}
@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
@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 / 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