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
@madr
madr / site.less
Last active February 14, 2016 14:54
LESS boilerplate
/*csslint box-model: false, box-sizing: false, universal-selector: false */
/*
All projects
should have nice
ASCII ART!
http://patorjk.com/software/taag/
@madr
madr / javascript.js
Last active January 21, 2016 11:54
String replacement using regular expressions
var results = 'hi bob123';
results = results.replace(/bob\d+/, 'cooper');
netstat -rn
@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
@madr
madr / characters.js
Last active December 25, 2015 14:19
var ಠ_ಠ = eval,
ლ_ಠ益ಠ_ლ = 42,
λ = function() {},
oneQuarter = "¼",
oneHalf = "½",
threeQuarters = "¾";
// ☺
// ¯\_(ツ)_/¯
// ಠ~ಠ
@madr
madr / validate_html.rb
Created October 15, 2013 10:05
Validate HTML using ruby
require "rubygems"
require 'living-validator'
require 'uri'
url = ARGV.first
files = ARGV.slice(1, 9999)
stop_at = files.length
i = 1
def colorize(text, color_code)
@madr
madr / ftp_upload.rb
Created October 15, 2013 09:13
Upload static files to a FTP server based on a git diff
require "rubygems"
require 'net/ftp'
require 'stringio'
ftp = ""
username = ""
passwd = ""
root_dir = "../../../../"
current_rev_file = root_dir + "__CURRENT_VERSION__"
@madr
madr / gist:5443213
Created April 23, 2013 12:36
Bash: quickly adding a vhost to MAMP basic
#!/bin/bash
#
# usage: ./adp-new-vhost <name>
#
mampdir=/Applications/MAMP
confdir=$mampdir/conf/apache/extra/vhosts
codedir=~/Code
mampport=80
cat <<end > $confdir/$1.conf