Skip to content

Instantly share code, notes, and snippets.

View OdinsHat's full-sized avatar
💭
Open to job offers

Doug OdinsHat

💭
Open to job offers
View GitHub Profile
@OdinsHat
OdinsHat / fix_server_perms.sh
Created May 14, 2015 09:24
Fix server permissions when someone accidentally chown/chmod from root recursively
# Fixes home dir and SSH key perms
chmod go-wrx ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
@OdinsHat
OdinsHat / jpegopti.sh
Last active February 19, 2016 16:51
Optimise all jpegs recursively
find -type f -name "*.jpg" -exec jpegoptim --strip-all {} \;
@OdinsHat
OdinsHat / create_user.sql
Created May 13, 2015 14:49
Create Magento admin user when it disappears
-- Creating a user in Magento when ity magically disappears
LOCK TABLES `admin_role` WRITE , `admin_user` WRITE;
SET @SALT = "rp";
SET @PASS = CONCAT(MD5(CONCAT( @SALT , "password") ), CONCAT(":", @SALT ));
SELECT @EXTRA := MAX(extra) FROM admin_user WHERE extra IS NOT NULL;
INSERT INTO `admin_user` (firstname,lastname,email,username,password,created,lognum,reload_acl_flag,is_active,extra,rp_token_created_at)
VALUES ('Firstname','Lastname','[email protected]','myuser',@PASS,NOW(),0,0,1,@EXTRA,NOW());
@OdinsHat
OdinsHat / pdfcon.sh
Last active August 29, 2015 14:19
PDF to Jpeg convertor script. Instructions in comments.
#!/bin/sh
# Need 2 directories:
# 1 ./toprocess
# 2 ./processed
#
# PHP dumps PDFs into "toprocess" dir.
# This script then converts and dump jpgs into "processed"
# Then deletes pdf contents of current directory.
#
# Run this script via crontab as so:
@OdinsHat
OdinsHat / imageresize.sh
Last active August 29, 2015 14:19
Batch convert image files size
#!/bin/sh
for i in *.jpg; do convert $i -resize 97x57 $i; done
@OdinsHat
OdinsHat / css3-mediaqueries_src.js
Created April 14, 2015 13:50
Copied from https://code.google.com/p/css3-mediaqueries-js/ before Google shut down GoogleCode (original author: Wouter van der Graaf)
/*
css3-mediaqueries.js - CSS Helper and CSS3 Media Queries Enabler
author: Wouter van der Graaf <wouter at dynora nl>
version: 1.0 (20110330)
license: MIT
website: http://code.google.com/p/css3-mediaqueries-js/
W3C spec: http://www.w3.org/TR/css3-mediaqueries/
@OdinsHat
OdinsHat / app.js
Created April 11, 2015 17:36
express 3.x cookie session middleware example - created as original visionmedia gist was deleted
var express = require('express')
, cookieSessions = require('./cookie-sessions');
var app = express();
app.use(express.cookieParser('manny is cool'));
app.use(cookieSessions('sid'));
app.get('/', function(req, res){
req.session.count = req.session.count || 0;
@OdinsHat
OdinsHat / MageDbExport.sh
Last active August 29, 2015 14:18 — forked from collymore/MageDbExport.sh
Run this one-liner in your Magento root to have the instaled DB dumped to the directory above with the filename the same as the dbname[.sql]
grep 'user\|dbname\|pass' app/etc/local.xml | tr -d '\n' | sed 's/<username><\!\[CDATA\[\(.*\)\]\]><\/username>.*<password><\!\[CDATA\[\(.*\)\]\]><\/password>.*<dbname><\!\[CDATA\[\(.*\)\]\]><\/dbname>/ mysqldump -u\1 -p\2 \3 > ..\/\3.sql/g' | sh
@OdinsHat
OdinsHat / countcsvheaders.sh
Last active August 29, 2015 14:17
Count number of headers in a CSV file using the shell/terminal/console
#/bin/sh
# Count number of headers in all CSV files in the current directory
for i in `ls`; do echo $i; head -1 $i | sed 's/,/ /g' | wc -w;done