Skip to content

Instantly share code, notes, and snippets.

View elundmark's full-sized avatar
💭
I may be slow to respond.

elundmark

💭
I may be slow to respond.
View GitHub Profile
@elundmark
elundmark / UserStyles.css
Created August 26, 2011 16:25
Nicer Images - Google Chrome UserStyles.css
html > body[style^='margin'] > img[style^='-webkit-user-select']:first-of-type {
display:block;
margin:0 auto;
box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
@elundmark
elundmark / Count_the_lines.py
Created September 19, 2011 16:43
Count lines in text-file (works w/ Nautilus Script)
#!/usr/bin/python -tt
import sys
import os
import subprocess
def main(filenames):
for filename in filenames:
fcmd = "file -bi '"+filename+"'"
f = os.popen(fcmd,"r")
@elundmark
elundmark / fixedCategoryDropdown.php
Created September 23, 2011 13:31
Divide wp_dropdown_categories to include alphabetical optgroups
// put this in your functions.php file
function fixedCategoryDropdown() {
$categories = get_categories('depth=1');
$catcount = count($categories);
$categorymenu = wp_dropdown_categories(
array(
// See http://codex.wordpress.org/Function_Reference/wp_dropdown_categories
// for all the available options
// These are the ones that makes sence for this example
'orderby' => 'name',
@elundmark
elundmark / fixedCategoryDropdown.js
Created September 23, 2011 13:35
(jQuery) Divide wp_dropdown_categories to include alphabetical optgroups
var optgroupArr = [], newHTML = "", currentLetter, categoryForm = $("form#cat");
categoryForm.find("option").each(function(index){
if (index === 0) {
newHTML += this.outerHTML;
} else if ( index > 0 ) {
var elFirstLetter = this.innerText.charAt(0).toLowerCase();
if (index === 1) {
optgroupArr.push(elFirstLetter);
currentLetter = elFirstLetter;
} else if ( currentLetter === elFirstLetter ) {
@elundmark
elundmark / Copy_to.sh
Created December 24, 2011 17:46
Robust Copy to... script for Nautilus
#!/bin/bash
dropbox=$(zenity --file-selection --directory)
filelog=""
for arg
do
if [ ! -f "${dropbox}/${arg}" ] && [ ! -d "${dropbox}/${arg}" ]
then
if [ -d "~/.local/share/Trash/files" ]; then
cp "${PWD}/${arg}" "${dropbox}/${arg}" &&\
@elundmark
elundmark / Move_to.sh
Created December 24, 2011 17:47
Robust Move to... script for Nautilus
#!/bin/bash
dropbox=$(zenity --file-selection --directory)
filelog=""
for arg
do
if [ ! -f "${dropbox}/${arg}" ] && [ ! -d "${dropbox}/${arg}" ]
then
if [ -d "~/.local/share/Trash/files" ]; then
cp -f "${PWD}/${arg}" ~/.local/share/Trash/files &&\
@elundmark
elundmark / search_for_text_in_folder.sh
Created January 13, 2012 00:41
Search text files in current folder (Recursive, RegExp)
#!/bin/bash
KEYWORD=$(zenity --entry --title="Search folder for..." --text="RegExp:" --entry-text "");
case "$?" in
1 )
exit 1
;;
esac
if [[ "${KEYWORD}" = "" ]]; then
exit 1
@elundmark
elundmark / svtschedule.php
Created June 4, 2012 22:22
Old SVTSchedule PHP script
#!/usr/bin/php -dsafe_mode=Off
<?php
######### Bash Cron script -> crontab #########
##!/bin/bash
#{
# if [[ -z "$DBUS_SESSION_BUS_ADDRESS" ]]; then
# source "$HOME/.dbus/session-bus"/*-0 && export DBUS_SESSION_BUS_ADDRESS
# fi
# DISPLAY=:0.0 /home/elundmark/.bin/svtschedule.php "rapport" "320"
# sleep 2
@elundmark
elundmark / _px2em.scss
Created June 19, 2012 14:48
pixels to em's sass function
// Your default font-size
$fs = 16;
@function px2em($target, $context: $fs) {
@return ( ( 1 / $context ) * $target )+0em;
}
// ----------
@elundmark
elundmark / secure_bash_passwords.sh
Created July 18, 2012 12:15
Store and use secure passwords in bash
#!/bin/bash
# Mixing in python with bash we can easily retrieve our passwords securely in our shell scripts.
# Read this first: https://live.gnome.org/GnomeKeyring/SecurityPhilosophy
# Make sure your distro has gnome-keyring-daemon installed and running at login,
# as well as python-keyring installed (sudo apt-get install python-keyring)
##
# Follow these steps to see what it does. Verify by looking in Seahorse for your password.
##