Skip to content

Instantly share code, notes, and snippets.

@joelremix
joelremix / JS: self_invoke_function
Last active December 17, 2015 22:19
JS: self invoke function
function hello() {
}()
@joelremix
joelremix / prevent
Created May 17, 2013 11:51
PHP: prevent mysql injection
function prevent($this) {
$this = stripslashes($this);
$this = mysqli_real_escape_string($this);
return $this;
}
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
// just an example; please use something more secure/random than sha1(microtime) :)
$salt = substr(str_replace('+', '.', base64_encode(sha1(microtime(true), true))), 0, 22);
// 2a is the bcrypt algorithm selector, see http://php.net/crypt
@joelremix
joelremix / gist:4329176
Created December 18, 2012 15:52
CSS: Image Replacement
ir {
background-color: transparent;
border: 0;
color: transparent;
font: 0/0 a;
text-shadow: none;
}