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
#!/bin/bash -e
# Run with sudo!
echo -n "Please enter the PhpStorm download url (eg http://download.jetbrains.com/webide/PhpStorm-EAP-141.690.tar.gz): "
read url
# Download file from url
echo "Downloading PhpStorm to ~/Desktop"
cd ~/Desktop
wget ${url} --no-check-certificate
comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// vanilla
var el = document.getElementById("foo"), child = el.firstChild, nextChild;
while (child) {
nextChild = child.nextSibling;
if (child.nodeType == 3) {
el.removeChild(child);
}
child = nextChild;
}
// Condensed logical operators
var operators = new Function("return {"+ "==,===,!=,!==,<,>,<=,>=" .replace(/([^,]+)/g, "'$1': function (l, r) { return l $1 r; }\n")+ ",'typeof': function (l, r) { return typeof l == r; } }")();
// And beating 'round the bush
var operators = {
'==': function (l, r) { return l == r; },
'===': function (l, r) { return l === r; },
'!=': function (l, r) { return l != r; },
'!==': function (l, r) { return l !== r; },
'<': function (l, r) { return l < r; },
/**
* A simple user script to customise the layout
* of JIRA's Backlog (add some keyboard shortcuts + hide
* unnecessary stuff)
*
* // TODO:
* - Set shortcut for moving back to parent ticket + creating sub task
* (useful when the focus jumps to the newly created subtask)
* - Set shortcut for assigning story points
*/
/**
* Light breadcrumbs lookup using the native wp_nav_menu
*
* @param string $themeLocation
* @param string $separator
*
* @return string
*/
function getBreadcrumbs($themeLocation = 'primary', $separator = ' &rang; ') {
/**
* Load Enqueued Scripts in the Footer
*
* Automatically move JavaScript code to page footer, speeding up page loading time.
*/
function footer_enqueue_scripts()
{
remove_action('wp_head', 'wp_print_scripts');
remove_action('wp_head', 'wp_print_head_scripts', 9);
// Another poor man's vanilla throttle script
window.addEventListener('scroll', throttle(callback, 1000));
// v1
function throttle(fn, wait) {
var time = Date.now();
return function() {
if (time + wait - Date.now() < 0) {
/**
* Credit goes to the very useful gomakethings.com
*
* https://gomakethings.com/ditching-jquery/
*
* Determine if an element is in the viewport
* @param {Node} elem The element
* @return {Boolean} Returns true if element is in the viewport
*/
var isInViewport = function ( elem ) {