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 / 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 / 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 / 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 / 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 / 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 / jpegopti.sh
Last active February 19, 2016 16:51
Optimise all jpegs recursively
find -type f -name "*.jpg" -exec jpegoptim --strip-all {} \;
@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 / iframe.html
Last active August 29, 2015 14:21
Example of postMessage() functionality made available in HTML5 (very rough and basic proof of concept example)
<DOCTYPE html>
<html>
<head>
<title>The iFrame file included in the above parent page</title>
</head>
<body>
<script type="text/javascript">
/**
* This will send every second
*/
@OdinsHat
OdinsHat / iframe.php
Created May 20, 2015 11:25
iframe PHP example passing an id to iframe getting hashed value back via postrmessage
<html>
<head>
<title>The IFrame</title>
</head>
<body>
<h1>IMAGINE THIS IS PRODUCT DESIGNR</h1>
<form id="form-pdesignr">
<input type="button" value="Click Me to Post Data Up ^" />
</form>
<script>
@OdinsHat
OdinsHat / key_error_magento.sql
Created May 29, 2015 15:53
Used this to fix key error on Magento after transferring to new server
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
TRUNCATE log_visitor_online;