Skip to content

Instantly share code, notes, and snippets.

View manfromanotherland's full-sized avatar
🤏

Edmundo Santos manfromanotherland

🤏
View GitHub Profile
@paulodiovani
paulodiovani / viewport.coffee
Last active August 29, 2015 14:02 — forked from manfromanotherland/viewport-size.js
Script para exibir tamanho do viewport. Fontes em CoffeeScript, Javascript gerado e Javascript minificado (para usar num botão de atalho)
id = "viewport-size-by-edmundojr-paulodiovani"
# Cria o elemento do viewport, se ainda não existir
create = ->
div = document.getElementById(id) || document.createElement "div"
div.id = id
div.style.cssText = """
position:fixed; \
top:0; \
right:0; \
@Guilh
Guilh / SassMeister-input.scss
Last active August 29, 2015 14:17
Generated by SassMeister.com.
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
$icon-names: (
user : '\e972',
camera : '\e603',
heart : '\e601',
bubble : '\e96d',
@electerious
electerious / closest.js
Last active November 6, 2015 22:14
Select the closest matching parent of an element
const closest = (elem, className) => {
if (elem==null || elem.classList==null) return null
return (elem.classList.contains(className) ? elem : closest(elem.parentNode, className))
}
@billerickson
billerickson / gist:1243250
Created September 26, 2011 20:02
Photo Credit Fields in Media Gallery
<?php
/**
* Add Photographer Name and URL fields to media uploader
*
* @param $form_fields array, fields to include in attachment form
* @param $post object, attachment record in database
* @return $form_fields, modified form fields
*/
@electerious
electerious / toClassString.js
Created January 21, 2017 15:48
Conditionally convert the keys of an object to a string of class names
const toClassString = (obj) => Object.keys(obj).filter((key) => obj[key]===true).join(' ').trim()
const hasTouchscreen = () => {
const mobileDevice = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera)
const onTouchEnd = ('ontouchend' in document.documentElement)
return (mobileDevice && onTouchEnd)
}
@electerious
electerious / toggler.js
Last active January 24, 2017 09:04
Toggle between true and false
const toggler = (initState) => {
initState = initState!==false
let state = initState
return {
get : () => state,
reset : () => state = initState,
toggle : () => state = !state,
@electerious
electerious / select.js
Last active January 24, 2017 09:04
Select multiple elements and receive an array
const select = (query, elem = null) => {
elem = (elem==null ? document : elem)
let elems = elem.querySelectorAll(query)
if (elems==null) return []
else return Array.prototype.slice.call(elems, 0)
}
@electerious
electerious / counter.js
Last active January 24, 2017 09:04
Count up and down between two numbers
const counter = (min, max, initial) => {
let index = initial - min
let length = max - min + 1
return (modifier = 0) => {
index = (index + modifier) % length
if (index>=0) index = 0 + index