Skip to content

Instantly share code, notes, and snippets.

View chluehr's full-sized avatar

Christoph Lühr chluehr

View GitHub Profile
@chluehr
chluehr / sample-table-print.html
Created December 16, 2016 13:40
HTML Example for a printable print CSS with repeating table column headers suitable for wkhtmltopdf
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
margin: 60px;
}
@chluehr
chluehr / test.sh
Created May 2, 2016 14:16
test desc
#!/bin/bash
test
@chluehr
chluehr / 0_reuse_code.js
Created May 2, 2016 13:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@chluehr
chluehr / varnishclear.sh
Created December 3, 2013 10:04
Bash script to clear all resources / files / path of a (sub-) domain in a varnish cache.
#/!bin/bash
cmd="sudo varnishadm -T 127.0.0.1:6082 -S /etc/varnish/secret"
site=$(echo $1 | sed -r 's|https?://||;s|/(.*)||;')
page=$(echo $1 | awk -F'/' -v OFS='/' '{sub(/https?:\/\//, ""); $1=""; print $0}')
if [ -z "$1" ]; then
echo "ERROR: please provide a URL to purge.."
echo "USAGE: "
@chluehr
chluehr / mysql-view-definer-change.sh
Last active January 15, 2016 09:34
A shell script to change all the security definers of a mysql view
#!/bin/bash
# Usage: mysql-view-definer-change.sh MYSQLDUMP.sql
sed -i 's/DEFINER=[^*]*\*/\*/g' $1
@chluehr
chluehr / ox_set_password.sql
Created October 10, 2013 07:50
Reset/Change OXID Password via SQL
update oxuser set oxpassword = MD5( CONCAT( 'pass', UNHEX( oxpasssalt ) ) ) where oxusername='myusername';
@chluehr
chluehr / git_set_default_remote.sh
Created October 8, 2013 12:10
(re-)set default git pull/push location
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
@chluehr
chluehr / test_ssl.sh
Created March 11, 2013 12:03
Test SSL connections in terminal (like telnetting into port 80)
# Test SSL connections in terminal (like telnetting into port 80)
openssl s_client -connect 192.168.0.1:443
/* /website/static/js/editmode/wysiwyg.js */
CKEDITOR.stylesSet.add( 'custom_styles', [
// Paragraph Styles
{ name: 'Regular Text', element: 'p', attributes: { 'class': '' }},
{ name: 'Large Text', element: 'p', attributes: { 'class': 'content__text-L' } }
]);
CKEDITOR.editorConfig = function( config ) {
// add our custom styles
@chluehr
chluehr / bayes_rank.sql
Last active October 12, 2015 18:08
Bayesian Ranking / Stars
SELECT
voteId,
this_num_votes,
this_stars,
( ( avg_num_votes * avg_stars ) + ( this_num_votes * this_stars ) ) / (
avg_num_votes + this_num_votes ) AS real_stars
FROM (
SELECT
voteId,
(SELECT COUNT(productId) FROM Vote) / (SELECT COUNT(DISTINCT voteId) FROM Vote) AS avg_num_votes,