Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
/**
* author: andreas johan virkus
* snippet url: https://gist.github.com/andreasvirkus/917a47fd8276be57300e
*
* Return all classes found that match the given prefix
* Example: You have an element with classes "apple juiceSmall juiceBig banana"
* You run:
* $elem.returnClassPrefix('juiceS');
* The resulting class is "juiceSmall"
*
<!DOCTYPE html>
<!-- Remove link outlines only for mouse interactions, keeping the tab-friendly outline for disabled users and keyboard lovers -->
<html>
<head>
<style id="_outline-styles"></style>
</head>
<body onmousedown="document.getElementById('_outline-styles').innerHTML='a{outline:none}';"
onkeydown="document.getElementById('_outline-styles').innerHTML=''">
<a href="#">test link</a>
// The lighten/darken functionality of SASS and LESS preprocessors in JavaScript
// Courtesy of Chris Coyier (https://css-tricks.com/snippets/javascript/lighten-darken-color/)
function LightenDarkenColor(col, amt) {
var usePound = false;
if (col[0] == "#") {
col = col.slice(1);
usePound = true;
}
// Basic static server setup with Node.js
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
contentTypes = require('./content-types'),
sysInfo = require('./sys-info'),
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var express = require('express'),
server = express(),
path = require('path'),
port = process.argv[2] || 80;
server.use(express.static(path.join(__dirname, 'assets')));
server.use(express.static(path.join(__dirname, 'build/content')));
server.listen(port);
console.log('Listening on port ' + port);
/**
* Some helper functions to transform/handle values
* between known colour formats
* atm: RGB, hex, HSL
*/
// RGB > Hex
function rgbToHex(r, g, b) {
function componentToHex(c) {
var hex = c.toString(16);
*
* This function does not attempt to implement all of sprintf, just %s,
* which is the only one that I ever use.
*/
function sprintf(text){
var i = 1,
args = arguments;
return text.replace(/%s/g, function(pattern) {
return (i < args.length) ? args[i++] : "";
function addGoogleFont(FontName) {
$("head").append("<link href='https://fonts.googleapis.com/css?family=" + FontName + "' rel='stylesheet' type='text/css'>");
}
function addCustomFont(url) {
$("head").append("<link href='" + link + "' rel='stylesheet' type='text/css'>");
}
// Usage
addGoogleFont("Junge");
#!/bin/bash
# Delay before starting
DELAY=10
# Sound notification to let one know when recording is about to start (and ends)
beep() {
paplay /usr/share/sounds/KDE-Im-Irc-Event.ogg &
}
#!/bin/bash
# Delay before starting
DELAY=10
# Sound notification to let one know when recording is about to start (and ends)
beep() {
paplay /usr/share/sounds/KDE-Im-Irc-Event.ogg &
}