Skip to content

Instantly share code, notes, and snippets.

View evitolins's full-sized avatar
🏠
Working from home

Eriks Vitolins evitolins

🏠
Working from home
View GitHub Profile
@evitolins
evitolins / simple_flex_grid.css
Created June 18, 2017 18:47
A simple responsive grid using flexbox
.grid .cell {
position: relative;
margin: 1rem 1rem 2rem;
}
@media screen and (min-width: 600px) {
.grid {
display: flex;
flex-wrap: wrap;
flex-direction: row;
@evitolins
evitolins / html5_video_events.js
Created April 6, 2017 16:47
Attach alerts for every video event available.
var video_events = {
'abort' : 'abort : The loading of an audio/video is aborted',
'canplay' : 'canplay : The browser can start playing the audio/video',
'canplaythrough' : 'canplaythrough : The browser can play through the audio/video without stopping for buffering',
'durationchange' : 'durationchange : The duration of the audio/video is changed',
'emptied' : 'emptied : The current playlist is empty',
'ended' : 'ended : The current playlist is ended',
'error' : 'error : An error occurred during the loading of an audio/video',
'loadeddata' : 'loadeddata : The browser has loaded the current frame of the audio/video',
'loadedmetadata' : 'loadedmetadata : The browser has loaded meta data for the audio/video',
@evitolins
evitolins / find_stuff.sh
Last active April 10, 2017 18:32
Helpful Find Commands
# Find all files with uppercase extensions
find . -type f -regex '.*\.[A-Z]\{1,\}'
# Count all files with uppercase extensions
find . -type f -regex '.*\.[A-Z]\{1,\}' | wc -l
# Find all file extensions that exceed 2MB
find . -type f -name "*.*" -size +2M | sed 's|.*\.||' | sort -u
@evitolins
evitolins / getFilteredList.py
Last active March 8, 2017 06:29
Python: Filter list by prefix and/or suffix
def getFilteredList(list=[], pfx='', sfx=''):
filteredList = []
for item in list:
isMatch = False
if pfx and not sfx: isMatch = item.startswith(pfx)
if not pfx and sfx: isMatch = item.endswith(sfx)
if pfx and sfx: isMatch = item.startswith(pfx) and item.endswith(sfx)
if isMatch: filteredList.append(item)
return filteredList
// https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent
[
{
name : "target",
type: "EventTarget",
description: "The event target (the topmost target in the DOM tree)."
},
{
name : "type",
type: "DOMString",
@evitolins
evitolins / httpErrorMessage.js
Created December 5, 2013 19:46
A quick way to display human-readable HTTP errors.
// Quick and easy HTTP Error Messages
// @ https://gist.github.com/aidilfbk/1363383
var get_http_error_message = function (code) {
var http_errors = {
100: "Continue",
101: "Switching Protocols",
102: "Processing",
103: "Checkpoint",
122: "Request-URI too long",
@evitolins
evitolins / dir2iso.sh
Created November 29, 2013 07:12
OSX Folder to hybrid .iso file. Personally using this to easily gain access to files stored on OSX filesystem from within a VirtualBox session.
function dir2iso() {
echo "Generating ISO: ${1} -> ${1}.iso"
hdiutil makehybrid -iso -joliet -o ${1}.iso ${1}
}
alias dir2iso=dir2iso
@evitolins
evitolins / getElementsByIds.js
Last active December 29, 2015 07:39
A simple function to simplify the act of gathering DOM elements for manipulation.
/**
* Returns an object of elements, from a given list of ids (ev)
* @return {object} Object containing any matching element ids, assigning
* the id as the key
*/
var getElementsByIds = function() { "use strict";
var r = {},
a = [].slice.call(arguments),
e,id,i;
for (i=0; i<a.length; i++) {
@evitolins
evitolins / SingleEvent.js
Last active December 28, 2015 11:39
A simple, single-use Javascript eventListener class. (http://jsbin.com/ADeZAHe/2/edit)
/**
* This class allows you to assign an eventListener to be utilzed only once, before
* it removes itself.
*
* # Usage Example:
* var elem = document.createElement('div');
* var onetimer = new SingleEvent(elem, "click", function(){alert("Well, I'll never do THAT again...");});
* document.body.appendChild(elem);
*/
@evitolins
evitolins / curlPost_resultToHtml.sh
Last active December 24, 2015 08:19
Upload a file via Curl, and retrieve returned HTML.
curl -F "upload_filename=@/full/path/to/local/file.txt" -F "myotherqueryvar=queryvalue" -L http://198.101.215.168/upload.php > html_out.htm