Skip to content

Instantly share code, notes, and snippets.

View doitlikejustin's full-sized avatar

Justin Scarpetti doitlikejustin

View GitHub Profile
@lajlev
lajlev / bookmarklet-gmail-compose.md
Last active December 21, 2015 04:18
How to create a bookmarklet to compose funktion in gmail.
  • Create a bookmark to Gmail.
  • Edit & paste following snippet into the url field.
javascript:var w=window,u='https://mail.google.com/mail/u/0/?ui=2&view=cm&fs=1&tf=1',l=document.location;try{ throw(0); } catch(z) {a =function(){if(!w.open(u,'t','toolbar=0,resizable=0,status=1,width=600,height=500'))l.href=u;};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();}void(0)
  • Boom you got a bookmarklet which make you able to compose an email, without having to enter you bloated inbox :)
@doitlikejustin
doitlikejustin / browser_caching.htaccess
Created August 4, 2013 21:41
Browser caching using Expires headers in .htaccess
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
@doitlikejustin
doitlikejustin / gzip.htaccess
Created August 4, 2013 21:37
gzip compression in .htaccess
<IfModule mod_deflate.c>
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
@doitlikejustin
doitlikejustin / no_www.htaccess
Created August 1, 2013 23:58
To WWW or not to WWW in .htaccess
#Force the no-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
@doitlikejustin
doitlikejustin / disable_core_updates.php
Created August 1, 2013 23:51
Disable WordPress updates (functions.php)
//Diasable Core Updates # 3.0+
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
wp_clear_scheduled_hook( 'wp_version_check' );
@doitlikejustin
doitlikejustin / reset_dns_lion.sh
Created July 26, 2013 20:29
Reset DNS cache in OS X Lion
sudo killall -HUP mDNSResponder
@doitlikejustin
doitlikejustin / change_wp_url.sql
Created July 26, 2013 20:06
WordPress SQL replace old URL with new URL
SET @prefix = "wp_";
SET @old = "http://www.old.com";
SET @new = "http://www.new.com";
SET @sql1 = CONCAT('UPDATE ', @prefix, 'options SET option_value = REPLACE(option_value,?,?)');
SET @sql2 = CONCAT('UPDATE ', @prefix, 'posts SET guid = REPLACE(guid,?,?)');
SET @sql3 = CONCAT('UPDATE ', @prefix, 'posts SET post_content = REPLACE(post_content,?,?)');
PREPARE update1 FROM @sql1;
PREPARE update2 FROM @sql2;
@doitlikejustin
doitlikejustin / wordpress.htaccess
Created July 26, 2013 18:27
Default WordPress .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
@doitlikejustin
doitlikejustin / unzip.php
Created July 26, 2013 18:16
Unzip ZIP file on server using PHP
<?php
$zip = new ZipArchive;
$res = $zip->open('./unzip.zip');
if($res === TRUE) {
$zip->extractTo('./');
$zip->close();
echo 'woot!';
} else {
echo 'doh!';
@drewjoh
drewjoh / custom.js
Created January 27, 2012 13:55
Dynamic (AJAX) loaded Bootstrap Modal (Bootstrap 2.1)
$(document).ready(function() {
// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {