Skip to content

Instantly share code, notes, and snippets.

@rabarbara
rabarbara / didItScrollIntoView.js
Created November 3, 2017 09:24
Did the element scroll into view?
//https://stackoverflow.com/a/22480938/5400353
function isScrolledIntoView(el) {
var elemTop = el.getBoundingClientRect().top;
var elemBottom = el.getBoundingClientRect().bottom;
// Only completely visible elements return true:
//var isVisible = (elemTop >= 0) && (elemBottom <= window.innerHeight);
// Partially visible elements return true:
isVisible = elemTop < window.innerHeight && elemBottom >= 0;
return isVisible;
@rabarbara
rabarbara / queue.py
Created July 21, 2017 15:29
Queue script for omxplayer for raspberry
#!/usr/bin/env python3
import os
import random
import subprocess
import argparse
parser = argparse.ArgumentParser(description='Število Pujs Pep, ki jih želiš zaigrat')
parser.add_argument('stevilo', metavar='N', type=int, nargs='+',
help='Število filmčkov za zaigrat')
@rabarbara
rabarbara / removeTextBoxes.vbs
Created July 12, 2017 13:13
Removing All Text Boxes In a Document
' Source: https://wordribbon.tips.net/T009169_Removing_All_Text_Boxes_In_a_Document.html
Sub RemoveTextBox2()
Dim shp As Shape
Dim oRngAnchor As Range
Dim sString As String
For Each shp In ActiveDocument.Shapes
If shp.Type = msoTextBox Then
' copy text to string, without last paragraph mark
@rabarbara
rabarbara / gist:7bde52a8cd6e11374dbccef8e1cfe321
Created July 12, 2017 07:44 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@rabarbara
rabarbara / beautiful_idiomatic_python.md
Created April 16, 2017 17:34 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@rabarbara
rabarbara / img-outline.js
Created April 6, 2017 09:46
Images that are too big for their actual use get an outline
let img = document.querySelectorAll('img')
// outline does not count in the size of the element, whereas border does. This is why outline is used
img.forEach(x => { if (x.naturalWidth>x.clientWidth) { x.style.outline = "2px solid red"}})
@rabarbara
rabarbara / regexes.txt
Created March 17, 2017 14:05
Regex expressions for pdf to markdown conversion
# Replaces the replacebelow statement in the text used as a placeholder for what used to be the document pagination
.*?[\*]*?replacebelow[\*]*?\n\n.*?\n
@rabarbara
rabarbara / custom-event.js
Last active April 11, 2017 12:04
Custom GA events on top of Google Tag Manager
// adapted from https://www.simoahava.com/analytics/macro-magic-google-tag-manager/#7
if ("ga"in window) {
var gaCustom = ga.getAll()[0]; //this retrieves all ga trackers, we get the first one, which is the one we want
if (gaCustom) {
gaCustom.send('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]) //send the event with the proper tracking info
}
}
@rabarbara
rabarbara / gist:aa9df2830a56449afffd
Created February 15, 2015 10:18
methods of overlaying text on images
methods of overlaying text on images
http://css-tricks.com/design-considerations-text-images/