Skip to content

Instantly share code, notes, and snippets.

View Ephigenia's full-sized avatar
🕊️
I may be slow to respond.

Marcel Eichner Ephigenia

🕊️
I may be slow to respond.
View GitHub Profile
@Ephigenia
Ephigenia / .bashrc
Created May 9, 2014 17:13
.bashrc-auto-theme-ssh
# ~/.bashrc
# changes the current theme of Terminal application to desired one
function tabc {
NAME=$1;
osascript -e "tell application \"Terminal\" to set current settings of front window to settings set \"$NAME\""
}
function ssh {
# insert desired SSH-Theme here
tabc "Red Sands"
CREATE FUNCTION fixUtf8Chars(str TEXT) RETURNS TEXT
BEGIN
SET str = REPLACE(str, CHAR(0xC383C2A9), CHAR(0xC3A9)); -- é
SET str = REPLACE(str, CHAR(0xC383C289), CHAR(0xC389)); -- É
SET str = REPLACE(str, CHAR(0xC383C2A8), CHAR(0xC3A8)); -- è
SET str = REPLACE(str, CHAR(0xC383C288), CHAR(0xC388)); -- È
SET str = REPLACE(str, CHAR(0xC383C2AA), CHAR(0xC3AA)); -- ê
SET str = REPLACE(str, CHAR(0xC383C28A), CHAR(0xC38A)); -- Ê
SET str = REPLACE(str, CHAR(0xC384C296), CHAR(0xC496)); -- Ė
SET str = REPLACE(str, CHAR(0xC384C297), CHAR(0xC497)); -- ė
@Ephigenia
Ephigenia / gist:1295272
Created October 18, 2011 12:03
php-convolution-filter-sharpen
<?php
// angenommen $h ist das image-handle
$m = array(
array(-1, -1, -1),
array(-1, 16, -1),
array(-1, -1, -1)
);
imageconvolution($h, $m, 8, 0);
?>
@Ephigenia
Ephigenia / gist:1295266
Created October 18, 2011 11:59
PHP-upload-file-errors
// test if a file was uploaded
$formFieldName = 'myFile';
if (isset($_FILES[$formFieldName])) {
switch(@$_FILES[$formFieldName]['error']) {
case UPLOAD_ERR_OK: // 0
// everything is ok with the upload for php
break;
case UPLOAD_ERR_INI_SIZE:
// file is larger than the size set in php.ini
// upload_max_filesize
@Ephigenia
Ephigenia / gist:1295253
Created October 18, 2011 11:52
splite-firstname-lastname-sql
- namen sind als [nachname] [vorname] gespeichert
SELECT
name,
-- lastname
SUBSTRING(name, 1, NULLIF(LOCATE(' ', name) - 1, -1))
-- firstname
SUBSTRING(name, LOCATE(' ', name) + 1, LENGTH(name)),
FROM users
-- namen sind als [vorname] [nachname] gespeichert
SELECT
@Ephigenia
Ephigenia / config-2.php
Created October 18, 2011 11:35
wordpress-env-config-username-example
define('WP_HOME','http://'.$_SERVER['HTTP_HOST'].'/wordpress/path/');
define('WP_SITEURL', WP_HOME);
@Ephigenia
Ephigenia / grep-example.sh
Created October 18, 2011 11:33
random-email-from-file
grep -Z -P '^From:s(.+)' mail_export.txt | uniq
Fr 4 Jun 2010 12:15:54 CEST
Batch Apache-Benchmarking on
http://www.horrorblog.org
uri: /
Finished 349 requests
Requests per second: 5.57 [#/sec] (mean)
Time per request: 1794.754 [ms] (mean)
Time per request: 179.475 [ms] (mean, across all concurrent requests)
uri: /blog/reca-drei-clips-und-red-band-trailer/
Finished 588 requests
@Ephigenia
Ephigenia / gist:1295180
Created October 18, 2011 11:10
vimrc-example
" only use with buftabs plugin
set showtabline=0
" custom colorsheme
colorscheme darkness
" set textmate as editr
set editor="mate -w"
" show hover links in status bar
set showstatuslinks=2
js document.getElementById("status-bar").setAttribute("moz-collapsed", false);
" no error sound, just flash display
@Ephigenia
Ephigenia / gist:1295164
Created October 18, 2011 10:59
nginx-fb-hotlinking-hb-2
# apply this rule on any location that’s an image using Regexp
location ~* \.(png|gif|jpg|jpeg|swf|ico)(\?[0-9]+)?$ {
# block empty blocked or whiteliste referers
valid_referers none blocked horrorblog.org www.horrorblog.org ~\.google\. ~\.yahoo\. ~\.bing\. ~\.facebook\. ~\.fbcdn\.;
if ($invalid_referer) {
return 403;
}
}