Skip to content

Instantly share code, notes, and snippets.

@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;
}
<?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 / 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;
}
@joelremix
joelremix / JS: self_invoke_function
Last active December 17, 2015 22:19
JS: self invoke function
function hello() {
}()
@joelremix
joelremix / prevent_scrolling
Created June 15, 2013 17:52
JS: prevent scrolling
document.body.addEventListener('touchmove', function(event) {
event.preventDefault();
}, false);
// http://www.html5rocks.com/en/mobile/touch/
@joelremix
joelremix / backup_table
Created March 21, 2014 02:32
MySQL: backup_tables
CREATE TABLE wp_posts_BAK LIKE wp_posts ;
INSERT wp_posts_BAK SELECT * FROM wp_posts;
CREATE TABLE wp_postmeta_BAK LIKE wp_postmeta ;
INSERT wp_postmeta_BAK SELECT * FROM wp_postmeta;
@joelremix
joelremix / get_string_between.php
Last active November 29, 2021 17:23
PHP: get_string_between()
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
$fullstring = "this is my [tag]dog[/tag]";
@joelremix
joelremix / html5.html
Created April 1, 2014 11:48
HTML: html5 template
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes">
<link rel="stylesheet" type="text/css" href="normalize.css">
<link rel="stylesheet" type="text/css" href="main.css">
</head>
@joelremix
joelremix / responsive.css
Created April 1, 2014 11:50
CSS: responsive queries
/*iPhone < 4:*/
@media screen and (device-aspect-ratio: 2/3) {}
/*iPhone 4 retina */
@media screen and (device-aspect-ratio: 2/3) and (-webkit-min-device-pixel-ratio: 2) {}
/*iPhone 5:*/
@media screen and (device-aspect-ratio: 40/71) {}
/*iPad:*/
@joelremix
joelremix / momentum-scrolling-ios.css
Created April 29, 2014 03:22
CSS: momentum scroll ios
.module {
overflow-y: scroll; /* has to be scroll, not auto */
-webkit-overflow-scrolling: touch;
}