Skip to content

Instantly share code, notes, and snippets.

@dashr
dashr / shellshock-fix
Last active August 29, 2015 14:06
shellshock
#test on command line
$ env VAR='() { :;}; echo Bash is vulnerable!' bash -c "echo Bash Test"
#Fix on ubuntu (debian based)
$ sudo apt-get update && sudo apt-get install --only-upgrade bash
#Fix on CentOS/ Cpanel
$ sudo yum update bash
# from: https://www.petekeen.net/know-how-to-roll-your-ssl-certificates
# look into: https://github.com/tilsammans/playbook/tree/master/roles/rails/templates
desc "Generate a new key"
task :gen_key do
domain = get_env(:domain)
filename = "#{domain}.key"
`openssl genrsa -out #{filename} 2048`
end
@dashr
dashr / nginx80-443
Last active January 20, 2016 06:40
Nginx: Send all 80 to 443
# /etc/nginx/sites-available/production <-- in same VirtualHost container as the 443 one, above it
server {
listen 80;
server_name sample.com www.sample.com;
rewrite ^(.*) https://sample.com$1 permanent;
}
@dashr
dashr / quickie deny
Created February 20, 2014 07:05
send a simple 404 to users looking for a certain folder
<IfModule mod_rewrite.c>
ErrorDocument 404 "<H1>Page not found</H1>"
RewriteEngine On
RewriteBase /
RewriteRule ^(bigNoNo/*) - [R=404,L]
</IfModule>
@dashr
dashr / tumblr.caman.bfly.xing.js
Created September 2, 2012 00:34
CamanJS greyscale + trans png overlay on all post images
<script type="text/javascript">
$(document).ready(function(){
$('.photo img').each(function() {
Caman( this, function () {
this.greyscale();
this.newLayer(function () {
this.setBlendingMode('normal');
this.opacity(100);
@dashr
dashr / tags.tumblr.js
Created September 2, 2012 00:27
Hide the tumblr forced "submission" tag
<script type="text/javascript">
$(document).ready(function() {
//hide the tumblr forced "submission" tag, only City (1)
$(".tag_body:contains('submission')").parent().remove();
});
</script>
@dashr
dashr / simple drupal6_paywall.php
Created April 6, 2011 20:22
simple drupal6 paywall
/**
* Determine if this is a premium user with special access to content
*
* @param $user
* Bring in the user object to test its roles
* @return boolean
* True if this is a premium user
*/
function is_Premium($user) {
@dashr
dashr / d6_form_snippets.php
Created April 6, 2011 20:17
seldom used form snippets
$hooks['user_profile_form'] = array(
'arguments' => array('form' => NULL)
);
function theme_user_profile_form($form) {}
if ($vars['menu_item']['map'][0]=='user') {
if ($vars['menu_item']['map'][2]=='edit') {
drupal_goto('trainings') ; #var_dump($_GET);
}
@dashr
dashr / drupal6_memcached_single.php
Created March 7, 2011 22:13
only use memcached plugin if memcached responds
/**
* Use Memcached (if its on):
*
* Enable these configurations if a Memcached server is running on the
* server. This will move the database load from MySQL to Memcached,
* increasing the site speed and lowering the database lag.
*
* cache_inc = replaces the Drupal caching mechanism
* session_inc = replaces the Drupal mysqldb Sessions handler
* memcache_key_prefix should be set to a short unique string in multi Drupal environment