Skip to content

Instantly share code, notes, and snippets.

View gjedeer's full-sized avatar
💭
Fucking kittens

GDR! gjedeer

💭
Fucking kittens
View GitHub Profile
@gjedeer
gjedeer / gist:4514435
Created January 11, 2013 22:16
redmine supervisord script
[program:redmine]
command = /usr/bin/ruby /path/to/redmine/script/fastcgi
process_name = redmine
autostart = true
startsecs = 40
user = www-data
redirect_stderr = true
stdout_logfile = /var/log/redmine.log
environment = RAILS_ENV=production
@gjedeer
gjedeer / gist:5134047
Created March 11, 2013 12:56
C# 0.1024 -> colormap RGB implementation
int r;
int g;
int b;
if (point <= 128) // 1/8
{
r = 0;
g = 0;
b = 127 + point; // 0.5 ... 1
}
else if (point <= 384) // 3/8
@gjedeer
gjedeer / gist:5397996
Created April 16, 2013 17:50
How I generate an email with planned server restart time, in all time zones
import pytz
from datetime import datetime, timedelta
time_cet = datetime(2013,04,18, 6,0,0, tzinfo=pytz.utc)
for tz in pytz.all_timezones:
print tz.ljust(30), time_cet.astimezone(pytz.timezone(tz)).strftime('%Y %B %d, %H:%M')
@gjedeer
gjedeer / gist:5430144
Created April 21, 2013 16:22
mdadm resync RAID1 array
root@rescue:~# mkdir --parent /dev/md
root@rescue:~# mdadm --assemble --scan --auto=yes --symlink=no
mdadm: /dev/md/le02:1 has been started with 1 drive (out of 2).
mdadm: /dev/md/le02:0 has been started with 1 drive (out of 2).
root@rescue:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] [faulty]
md126 : active raid1 sdb1[1]
40957880 blocks super 1.2 [2/1]
@gjedeer
gjedeer / varnish-watchdog.sh
Created July 11, 2013 11:06
Simplest Varnish watchdog possible
#!/bin/bash
/usr/bin/varnishadm quit >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 2 ]
then
/etc/init.d/varnish restart
fi
@gjedeer
gjedeer / show_varnish_utilization
Created August 26, 2013 19:33
Show Varnish cache utilization in percents and megabytes
v_bytes=`varnishstat -1 | grep s0.g_bytes | awk '{print $2}'`
v_space=`varnishstat -1 | grep s0.g_space | awk '{print $2}'`
v_total=$(( v_bytes + v_space ))
v_percent=$(( 100 * v_bytes / v_total ))
v_total_mb=$(( v_total/1024/1024 ))
v_bytes_mb=$(( v_bytes/1024/1024 ))
echo $v_percent % \($v_bytes_mb / $v_total_mb MB\)
@gjedeer
gjedeer / detect_os_version.sh
Last active December 22, 2015 19:49
One-liner to detect Linux distro and version
# One-liner to detect Linux distro and version
cat /etc/issue;uname -a;if [ -f /etc/lsb-release ]; then echo "Ubuntu"; cat /etc/lsb-release; fi;if [ -f /etc/debian_version ]; then echo "Debian"; cat /etc/debian_version; fi;if [ -f /etc/redhat-release ]; then echo "RHEL"; cat /etc/redhat-release; fi;if [ -f /etc/SuSE-release ]; then echo "SuSE"; cat /etc/SuSE-release; fi;
# One-liner to detect Linux distro and version
@gjedeer
gjedeer / detect_joomla_version.sh
Last active December 22, 2015 19:49
One-liner to detect Joomla version
# cd /your/joomla/directory
if [ -f includes/version.php ]; then echo 1.0 DETECTED; grep var\ \$RELEASE includes/version.php; grep var\ \$DEV_LEVEL includes/version.php; fi; if [ -f libraries/joomla/version.php ]; then echo 1.5 DETECTED; grep var\ \$RELEASE libraries/joomla/version.php; grep var\ \$DEV_LEVEL libraries/joomla/version.php; fi; if [ -f joomla.xml ]; then echo 2.5+ DETECTED; grep \<version\> joomla.xml; fi; if [ -f libraries/cms/version/version.php ]; then echo 2.5+ DETECTED; grep public\ \$RELEASE libraries/cms/version/version.php; grep public\ \$DEV_LEVEL libraries/cms/version/version.php; fi;
# One-liner to detect Joomla version
@gjedeer
gjedeer / tt-rss-feedmod
Created October 7, 2013 15:34
Rules for some of the websites for the FeedMod plugin for TT-RSS
{
"bankier.pl": {
"type": "xpath",
"xpath": "div[@id='article_body']"
},
"makowskimarcin.pl": {
"type": "xpath",
"xpath": "div[@class='entry-content post_content']"
},
"niebezipecznik.pl": {
[master] gdr@gdr-desktop:~/Downloads/optipng-zopfli$ cat src/zopfli/makefile
make:
gcc *.c -O2 -W -Wall -Wextra -ansi -pedantic -lm -o zopfli
debug:
gcc *.c -g3 -lm -o zopfli
CFLAGS = -O2 -W -Wall -Wextra -ansi -pedantic -lm