Skip to content

Instantly share code, notes, and snippets.

View weiland's full-sized avatar
🍫
🎓 && 💻 #GitHubDropICE

Pascal Weiland weiland

🍫
🎓 && 💻 #GitHubDropICE
View GitHub Profile
@weiland
weiland / Readme.md
Last active August 29, 2015 14:02
Page Size Visualization Bookmarklet

Visualise the size of each element on the page - Bookmarklet

Read more

Original Blog Post about this topic

What it does

On click it toggles the visualize-style

USE IT

just use the javascript code and add it as a bookmark:

@weiland
weiland / CalculateNewSizes.js
Created June 6, 2014 14:45
Calculate the new size of an element w*h with a new width or height.
(function CalculateNewSizes(){
var width, height, nWidth, nHeight, tmp;
tmp = prompt('Current dimensions 123x1234: ').split('x');
width = tmp[0];
height = tmp[1];
tmp = prompt('Set a new value for width. (prefix h for new Height)').replace(/ /g, '');
if(tmp.indexOf('h') !== -1) {
nHeight = tmp.replace(/h/, '');
nWidth = parseInt(width*nHeight/height);
} else {
@weiland
weiland / gulp-run-task-asynchronously.js
Created June 18, 2014 13:32
Gulp run tasks after each other.
// there were people suggesting using async or event-stream
// this is the way easier solution to run a taks after another taks is done
gulp.task('compileAssets', function() {
return gulp.src('assets/*').pipe(compile()); // the return is essential!
});
// compileAssets is a dependency
gulp.task('serve', ['compileAssets'], function() {
return gulp.src('app/**/*.js').pipe(startWebserver());
@weiland
weiland / bookmarklet-github-to-gitio.js
Created July 8, 2014 20:47
Switch between a GitHub Repository and their gh-pages.
javascript:(function() { var s,r,c; var l = window.location; if(l.origin.indexOf('github.io') !== -1) { r = /(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/i; s = window.location.origin.match(r)[1]; window.location.href='https://github.com/' + s + l.pathname; } else if(l.origin.indexOf('github.com') !== -1) { s = window.location.pathname.split('/')[1]; c = window.location.pathname.split('/')[2]; window.location.href='http://' + s + '.github.io/' + c; }})();
@weiland
weiland / github-visited-links-userscript.js
Created July 12, 2014 10:51
Mark visited links with a significant color, to see in your dashboard which repos you already visited.
@weiland
weiland / README.md
Created July 14, 2014 14:08
Reverse Proxy Setup

Reverse Proxy Setup

for Nginx and Apache

Local usage

(a normal reverse tunnel: ssh -R 61001:localhost:22 user@myhost.tld)

Asuming your local application runs on port 3000 (http://localhost:3000/ in the browser shows your nice webpage) we login with a user noroot and the ssh port 22 on the host myhost.tld to forward that to the server port 61001. Being logged in on the the server noroot@myhost.tld:22 the command curl -v http://localhost:61001/ should be equal to on the local machine http://localhost:300
just run: ssh -i ~/.ssh/server.key -l noroot -p 22 myhost.tld -R 61001:localhost:3000

@weiland
weiland / querySelectorAndForEach.js
Created July 24, 2014 08:50
QuerySelector and simple ForEach provided by Array
var forEach = Array.prototype.forEach,
_$ = document.querySelectorAll.bind(document);
forEach.call(_$('.className'), function(element) {
});
@weiland
weiland / chayns-dev-anti-cache-juniorAcademy.html
Created August 5, 2014 09:36
Solving JuniorAcademy Caching on iOS.
<a href="#" onclick="location.href='?d=' + (new Date()).getTime() + ''; return false;">reload</a>
@weiland
weiland / bug-report-bugmarklet.js
Last active August 29, 2015 14:04
Bug Report Bookmarklet
(function() {
var CurrentPage = window.location.href;
var CurrentUserAgent = window.navigator.userAgent;
var MailTo = 'MITARBEITER@EMAIL';
var MailFrom = 'Pascal';
var MailBody = ('Hi, <br><br>'
+ 'Fehler: <br>'
+'Seite: ' + CurrentPage + '<br>'
+'System: ' + CurrentUserAgent + '<br>'
+'Vorgehensweise:'
@weiland
weiland / RouteConfig.cs
Created August 7, 2014 13:34
Supports building a REST API with ASP.net MVC 5
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// add this block \o/
routes.MapRoute(
name: "single",
url: "{controller}/{id}",