Skip to content

Instantly share code, notes, and snippets.

View gorango's full-sized avatar
👋
🌍

Goran gorango

👋
🌍
View GitHub Profile
@gorango
gorango / gource-video-captions.sh
Last active April 1, 2021 18:18
Create gource video with commit messages as captions
#!/bin/bash
git log \
--pretty=format:"%at|%s" \
--reverse \
--no-merges \
> commitmsg.txt
gource \
-1920x1080 \
function highlightSentences (sentences) {
const highlights = []
const body = document.body
const contentNodes = gatherTextNodes(body)
sentences.forEach(sentence => {
const range = document.createRange()
let rangeSentence = sentence.toLowerCase()
let start = false
@gorango
gorango / clamp.js
Created February 5, 2019 21:03
ESNext version of @josephschmitt's Clamp.js
/*!
* Clamp.js 0.5.1
*
* Copyright 2011-2013, Joseph Schmitt http://joe.sh
* Released under the WTFPL license
* http://sam.zoy.org/wtfpl/
*/
/**
* Clamps a text node.
@gorango
gorango / get-google-fonts.sh
Last active May 25, 2018 00:12
Download any Google Font with its corresponding CSS rules.
#!/bin/bash
FONT_NAME="$1"
FILE_NAME=$(echo $FONT_NAME | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
URL_NAME=$(echo $FONT_NAME | tr ' ' '+')
FILE=$FILE_NAME"-font.css"
FONT_FOLDER="web-font"
AGENT_WOFF="Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"
AGENT_WOFF2="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like $
@gorango
gorango / sentence-tokenizer.js
Created November 18, 2017 10:42
Concise, efficient, and 99% reliable sentence tokenizer for all Latin languages.
function sentencesArray (text) {
return text
.replace(/([\s,]?[\d,-]?([A-Z][a-z]{3,}|[a-z]{2,}|[0-9])[.?!…\n]+([\s\n"]))/g, '$1|')
.split('|')
.map(s => s.trim())
.filter(s => s)
}
@gorango
gorango / screencast.md
Last active January 7, 2023 04:28
Uses CVLC (command-line VLC) to record a screen session in Linux.

Linux screen capture

Uses CVLC (command-line VLC) to record an ongoing screen session in Linux.

Requires VLC to be installed.

Usage

To save a new video file in the current folder:

import {AfterViewInit, Directive, ElementRef, Input, Renderer} from '@angular/core';
/**
* ng2 FitText directive.
*/
@Directive({
selector: '[fitText]'
})
export class FitText implements AfterViewInit {
private factor: number;
@gorango
gorango / infinite-scroll.ts
Last active September 21, 2016 02:47
ng2 infinite scroll directive
import {Directive, ElementRef, EventEmitter, Input, Output} from '@angular/core';
/**
* The infinite scroll directive.
* Providing a number on input offsets the distance from the bottom
*/
@Directive({
selector: '[infiniteScroll]',
host: {
'(scroll)': 'scroll($event)'
@gorango
gorango / Contract Killer 3.md
Last active August 29, 2015 14:28 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

#!/bin/bash
# Ubuntu kernel cleanup:
# Save the 2 latest kernels and remove the old
IMAGES=($(dpkg --get-selections | grep "linux-image-[[:digit:]].*" | tr "\t" ";" | cut -d ";" -f1))
HEADERS=($(dpkg --get-selections | grep "linux-headers-[[:digit:]].*" | tr "\t" ";" | cut -d ";" -f1))
I_LEN=${#IMAGES[@]}
H_LEN=${#HEADERS[@]}