Skip to content

Instantly share code, notes, and snippets.

View stekhn's full-sized avatar

Steffen Kühne stekhn

View GitHub Profile
@stekhn
stekhn / mongodb.conf
Created October 16, 2015 13:17
Example YAML configuration for a MongoDB 3.0 database on CentOS
processManagement:
fork: true
pidFilePath: /var/run/mongodb/mongod.pid
net:
bindIp: 127.0.0.1
port: 27017
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
@stekhn
stekhn / takeScreenshot.js
Last active August 29, 2015 14:14
Take a screenshot from a website using PhantomJS
var page = require('webpage').create(),
system = require('system'),
args = system.args,
siteName;
function takeScreenshot() {
if (args.length === 1) {
console.log('Please specify a URL to screenshot.');
@stekhn
stekhn / playButton.css
Created May 30, 2014 11:48
CSS play button for videos
.playButton {
background-color: #888;
border-radius: 30px;
display: inline-block;
height: 60px;
left: 50%;
position: absolute;
margin-left: -30px;
top: 120px;
width: 60px;
@stekhn
stekhn / hideErrors.js
Last active December 29, 2015 01:59
Suppresses alle JavaScript errors. Don't try this at home.
function hideErrors() {
window.onerror = function () {
return true;
}
}
@stekhn
stekhn / getUrlParam.js
Last active December 28, 2015 09:49
Returns the value for a certain URL parameter. If your URL is http://example.com/index.html?year=2013 the function getUrlParam(year) will return the string "2013".
function getUrlParam(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null) {
return "";
} else {
@stekhn
stekhn / getScrollY.js
Last active December 28, 2015 09:49
Function that returns the current scroll position. Useful for "snowfallesk" and parallax scrolling projects.
function getScrollY() {
var currentY = 0;
if (typeof( window.pageYOffset ) == 'number') {
currentY = window.pageYOffset;
} else if (document.body && ( document.body.scrollLeft || document.body.scrollTop )) {
currentY = document.body.scrollTop;
} else if (document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop )) {
currentY = document.documentElement.scrollTop;
}