Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View madr's full-sized avatar
🤘
Elixir, React, Phoenix Liveview, Rust.

Anders Englöf Ytterström madr

🤘
Elixir, React, Phoenix Liveview, Rust.
View GitHub Profile
var titles = [], urls = [], rows = document.querySelectorAll("#section0_column0 > div"), i = rows.length, lastI = i; while (i--) { titles.push(rows[i].getAttribute("data-title")); urls.push(rows[i].getAttribute("data-alternate-link")); } titles = titles.map(function (t, i) { return "[" + t + "][" + (i + 1) + "] \nskriv nåt bra här\n"; } ); console.log(titles.join("\n")); urls = urls.map(function (u, i) { return "[" + (i + 1) + "]: " + u; }); console.log(urls.join("\n"));
@madr
madr / random.js
Last active August 29, 2015 14:07
Comparison of getting random values in different languages
(function () {
"use strict";
var v, bandMembers = ["Hansi", "Andre", "Marcus", "Thomen"];
// 1. one random number between 1 and 10
v = Math.ceil(Math.random() * 10);
// 2: one random member of Blind Guardian
v = bandMembers[Math.ceil(Math.random() * (bandMembers.length - 1))];
@mixin gradient-stopped ($fromcolor, $tocolor, $stop) {
background-color: $tocolor;
background-image: -moz-linear-gradient(180deg, $fromcolor, $tocolor $stop, $tocolor);
background-image: -ms-linear-gradient(top, bottom, $fromcolor, $tocolor $stop, $tocolor);
background-image: -webkit-linear-gradient(top, bottom, $fromcolor, $tocolor $stop, $tocolor);
background-image: linear-gradient(180deg, $fromcolor, $tocolor $stop, $tocolor);
}
@madr
madr / Makefile
Created September 1, 2014 14:42
Automated Wordpress FTP deployment using composer
install:
composer install
composer update
deploy:
php vendor/bin/deployment deployment.ini
test-deploy:
php vendor/bin/deployment deployment.ini --test
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body { margin: 0; }
div { position: absolute; width: 20px; height: 20px; border-radius: 50%; background: red; }
</style>
<img src="mupp2.png" alt="" width="2500" height="2500">
<div hidden></div>
<script>
/*jslint browser: true */
@madr
madr / gist:aab7ef174eec894d5c34
Created May 7, 2014 11:17
example github webhook post
{
"ref": "refs/heads/master",
"after": "7d97f223924e0c7440680892cefdb2d97ff662a3",
"before": "ae249ec5c919d54f76c700178061652ed65286de",
"created": false,
"deleted": false,
"forced": false,
"compare": "https://github.com/madr/bearded-sansa/compare/ae249ec5c919...7d97f223924e",
"commits": [
{
@madr
madr / bookmarket.js
Last active August 29, 2015 14:00
Dota stats
/*jslint indent: 2, devel: true, browser: true */
(function () {
"use strict";
function scrape(stopAt, startAt) {
var iframe = document.createElement("iframe"),
games = [],
heroes = {},
wins = 0,
page = 1,
heroesPlayed,
@madr
madr / example-infinitescroll.js
Last active December 31, 2015 12:38
Primitive scroll guard utility
/*jslint browser: true, indent: 4 */
/*
Example use of ScrollGuard: a simple, unobtrusive lazy loader.
Each time the user scrolled to the bottom of the page:
1. Look if there is content to load (lookForNextPage)
2. If new content, get content using Ajax (getNextPage)
3. Append the new content and do some polish (appencContent)
@madr
madr / gist:7802137
Created December 5, 2013 08:49
keep alive
<a href="javascript:(function(){(function(){var%20doc,reload,keepAlive,saveButton,title;title=window.bajsa;doc=document.querySelectorAll("frame")[1].contentWindow;reload=function(){if(window.bajsa!==undefined){console.log("who%20is%20gabriel");doc.location.reload();keepAlive=setTimeout(reload,5*1000);}};if(title!==undefined){clearTimeout(keepAlive);delete%20window.bajsa;console.log("CANCELLED")}else{window.bajsa="who%20is%20gabriel";reload();}}());})();">Keep Agresso Alive</a>
@madr
madr / Gruntfile.js
Last active December 27, 2015 16:39
Frontend QA and deploy using Grunt, including: HTML validation (validator.nu), KSS styleguide generation, JSLint, CSSLint, Jasmine and deployment (concatination, minification and compression of CSS and JavaScript). Use setup.sh to create folder structures and get all dependencies installed (the script will download the oher files).
/*
The Following folder structure is required:
./
./dist
app.js
app.min.js
app.min.zipped.js
design.css
design.min.css