Skip to content

Instantly share code, notes, and snippets.

Metod Ribič metodribic

  • Working at Marand d.o.o.
  • Slovenia
Block or report user

Report or block metodribic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View download.ts
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 / starter.css
Created Sep 2, 2019
Basic css rules for start
View starter.css
body {
max-width: 1100px;
margin: 0 auto;
line-height: 1.5;
color: #2D3748;
}
h1,
h2,
strong {
View fonts.css
/* 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*/
View angular-in-view-directives.html
<!-- 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 Jan 9, 2019
Copy text to clipboard with pure JavaScript
View copy.js
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 / siblings.md
Last active Dec 18, 2018
CSS sibling selectors comparison
View siblings.md

Direct children selector >

Example:

.a > .b {
  border: 1px solid #eee;
}
@metodribic
metodribic / remove_uniquie_raw.sh
Created Aug 24, 2018
Remove all CR2 (raw image) files if they don't have corresponding JPG sibling
View remove_uniquie_raw.sh
#!/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})
@metodribic
metodribic / .htaccess
Created Jun 1, 2018
Apache2 .htaccess for angular2 app hosted in subdirectories
View .htaccess
<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 / aql.sublime-syntax
Last active Jan 3, 2018
AQL syntax definition for sublime text 3
View aql.sublime-syntax
%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 / word-count-by-file-extension.sh
Created May 24, 2017
Count number of lines in files with specific extension
View word-count-by-file-extension.sh
find . -name "*.ts" -print | xargs wc -l
You can’t perform that action at this time.