Skip to content

Instantly share code, notes, and snippets.

View innermond's full-sized avatar

Gabriel Braila innermond

View GitHub Profile
@innermond
innermond / gist:3aa15512aedb78c4c9ffc588465da905
Last active July 9, 2016 12:49
Get a list of fontnames from google fonts. You need to paste it in console si run it, the run again and again till you exhaust the list
console.clear();
// https://fonts.google.com/?subset=latin-ext&category=Sans+Serif ; get list from here
// run it from the console; when run for first time uncomment the line below and comment the subsequent line; for the next runs just use the script as is here
// var latin = [];
var latin = latin || [];
var nodes = document.querySelectorAll('h1.fonts-module-title');
Array.prototype.forEach.call(nodes, function(nod){
var font = nod.textContent.trim("\n");
if (latin.indexOf(font) == -1) latin.push(font);
});
@innermond
innermond / gist:0fb526cc30cea81bbc10
Last active March 27, 2016 21:45
rotate a portrait jpg file to a landscape, resize it and cropp it
for f in *.jpg; do wh=$(convert "$f" -ping -format '%w %h' info:); w="${wh%\ *}"; h="${wh#*\ }";[[ h -gt w ]] && echo portrait && mogrify -rotate -90 "$f" || echo landscape; mogrify -resize 220x -gravity center -crop 220x122 done
@innermond
innermond / gist:9cfc6a69c8e4b9ab2034
Created March 26, 2016 23:13
export single page pdfs as pngs using inkscape
for f in *; do inkscape "$f" -z --export-dpi=300 --export-area-drawing --export-png="$f.png"; done
@innermond
innermond / HeartBeat
Created February 20, 2016 11:05
Give heart beat capacity to a function, execute it at regular interval
var Heart = function(pulse){
return {
id: null,
periodical: function(beat){
this.id = setInterval(pulse, beat);
console.log('interval ' + this.id);
return this;
},
stop: function(span){
@innermond
innermond / parallel wget from lists located in many folders
Last active February 11, 2016 15:31
Download with wget using a .list of urls. Every download happens in parallel and every .list has it's own process
#!/bin/bash
path=$(realpath ${1:-.})
parallel=${2:-8}
directory=
for list in $(find "$path" -wholename "*/.list")
do
# .ignore file exists?
directory="${list%/*}"
if [ -f "$directory"/.ignore ]; then
@innermond
innermond / parallel wget from a list
Last active February 10, 2016 14:57
download from a list with wget in parallel
cat .list | xargs -I % -P 10 wget -t 3 --header="Accept: text/html" --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" ‐‐referer="https://www.google.com" %
@innermond
innermond / gist:e0d3cf049ce0f2911ae7
Created February 10, 2016 14:00
Bookmark get images href
javascript:void(function() {
document.title = "List images";
var links = document.querySelectorAll('div[data-ved]>a');
var link = "";
var href = "";
var found = [];
for(var inx = 0, len = links.length; inx < len; inx++) {
link = links[inx];
if ( ! href in link) continue;
href = link.href;
@innermond
innermond / s3up
Created February 9, 2016 08:46
Minify, compress and put to an s3 bucket. It depends on awscli
#!/bin/bash
root=~/Projects/printuridigital.ro
src=$root/src
dist=$root/dist
what=$1
options_s3=$2
if [ -z $1 ]; then echo need file argument; exit; fi
type=${1##*.}
file_src=$src/$type/$what
file_min=$dist/$type/$what
@innermond
innermond / gist:104e1fe488accadb1568
Created February 6, 2016 13:49
rename files in current directory with prefixed name and a counter
# rename files
i=0; for f in * ; do ((i++)); mv ./"$f" ./"<prefix-name>"$i.jpg ; done
@innermond
innermond / gist:6797cc6a73ae2c21c5e7
Created September 27, 2015 21:37
interesting bits of javascript
// Returns first element that matches CSS selector {expr}.
// Querying can optionally be restricted to {container}’s descendants
function $(expr, container) {
return typeof expr === "string"? (container || document).querySelector(expr) : expr || null;
}
// Returns all elements that match CSS selector {expr} as an array.
// Querying can optionally be restricted to {container}’s descendants
function $$(expr, container) {
return [].slice.call((container || document).querySelectorAll(expr));