Skip to content

Instantly share code, notes, and snippets.

arnorhs arnorhs

Block or report user

Report or block arnorhs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@arnorhs
arnorhs / snippet.js
Created Mar 19, 2018
see all forms on a website
View snippet.js
Array.prototype.forEach.call(document.forms, f => { console.log('[' + f.method + '] ' + f.action); console.table(Array.prototype.map.call(f.elements, el => { return {name: el.name, nodeName: el.nodeName } }))})
@arnorhs
arnorhs / recursive-obj-vars-for-private-props.php
Created Sep 28, 2017
horrible hack to recursively change custom objects into plain arrays
View recursive-obj-vars-for-private-props.php
Class Yoyo
{
public static function objectToArray($obj) {
if (is_object($obj)) {
$reflect = new \ReflectionClass($obj);
$props = $reflect->getProperties();
$d = array();
foreach ($props as $prop) {
View increase-reading-focus.js
var els = document.querySelectorAll('h1, h2, h3, h4, h5, h6, a, p, div');
function transform() {
Array.prototype.forEach.call(els, function(p) {
p.style.transform = 'translateY(' + (Math.random() - 0.5) + 'px)';
});
requestAnimationFrame(function() {
transform();
});
View maybe the easiest copy paste version.js
function islCompare() {
var order = '0123456789aAáÁbBcCdDeEéÉfFgGhHiIíÍjJkKlLmMnNoOóÓpPqQrRsStTuUúÚvVwWxXyYýÝzZþÞæÆöÖ';
function charOrder(a) {
var ix = order.indexOf(a);
return ix === -1 ? a.codePointAt() + order.length : ix;
}
return function(a, b) {
for (var i = 0; i < Math.min(a.length, b.length); i++) {
@arnorhs
arnorhs / dom-utils.js
Created Mar 2, 2016
random DOM utility functions
View dom-utils.js
/**
* Given a Node. Find the first parent node that matches a selector
*
* @param node {Node} the base node who's parents will be traversed
* @param selector {string} asdfasdf
* @returns {Node|null} the node, or null if nothing was found
*/
function findFirstParentNodeMatchingSelector(node, selector) {
var parent = node.parentNode;
@arnorhs
arnorhs / reset.styl
Created Dec 7, 2013
"Industry standard" Mayer reset.css ported to stylus. Original: http://www.cssreset.com/scripts/eric-meyer-reset-css/
View reset.styl
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video
margin: 0
padding: 0
border: 0
outline: 0
font-size: 100%
font: inherit
vertical-align: baseline
body
@arnorhs
arnorhs / gist:5407868
Created Apr 17, 2013
Rename a bunch of pngs to <number>.png
View gist:5407868
i=0; for filename in *; do mv $filename $i.png; ((i++)); done;
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Arnor Sigurdsson <arnorhs@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@arnorhs
arnorhs / scroll.js
Created May 17, 2012 — forked from acrookston/scroll.js
Small scrolling script for fun. Not sure how well it works. Please contribute if you have ideas.
View scroll.js
// muhaha.. changed all the code
// maybe this version handles scrolling to the bottom edge of a document a little better
// still not satisfied with the speed variable.. should that be higher == more speed, perhaps? or pixels per second?
// sorry about the opinionated style changes
Scrolling = {
smoothScrollTo: function(target_top) {
// ensure that we never scroll further than viewport size from bottom of the doc
target_top = Math.min(target_top, Math.max($(document).height(), $(window).height()) - $(window).height());
var speed = 30,
You can’t perform that action at this time.