Skip to content

Instantly share code, notes, and snippets.

View mitchellhislop's full-sized avatar

Mitchell Hislop mitchellhislop

View GitHub Profile
@mitchellhislop
mitchellhislop / phptojson.php
Created January 30, 2012 20:26
Get PHP into JS
var phpvar = $.parseJSON(<?php print json_encode(json_encode($json))?>);
@mitchellhislop
mitchellhislop / removechars.sql
Created November 29, 2011 22:24
Removing special characters in MySQL
# FIRST, REPLACE UTF-8 characters.
UPDATE `t` SET `c` = REPLACE(`c`, 0xE28098, "'");
UPDATE `t` SET `c` = REPLACE(`c`, 0xE28099, "'");
UPDATE `t` SET `c` = REPLACE(`c`, 0xE2809C, '"');
UPDATE `t` SET `c` = REPLACE(`c`, 0xE2809D, '"');
UPDATE `t` SET `c` = REPLACE(`c`, 0xE28093, '-');
UPDATE `t` SET `c` = REPLACE(`c`, 0xE28094, '--');
UPDATE `t` SET `c` = REPLACE(`c`, 0xE280A6, '...');
# NEXT, REPLACE their Windows-1252 equivalents.
UPDATE `t` SET `c` = REPLACE(`c`, CHAR(145), "'");
@mitchellhislop
mitchellhislop / klout.js
Created November 22, 2011 20:38
Klout's Algo
function klout(){
var klout_score=Math.floor(Math.random()*101);
return klout_score;
}
@mitchellhislop
mitchellhislop / memcache.php
Created November 21, 2011 16:35
Memcache is Magical
<?php
$key = "News_Articles";
$memcached_news_articles = $this->Controller->Memcache->get($key);
if(is_array($memcached_news_articles))
{
$news = $memcached_news_articles;
}
else
{
$news = $Article->getNewsArticles();
@mitchellhislop
mitchellhislop / browsers.css
Created September 19, 2011 20:20
Browser Specific CSS hacks
/***** Selector Hacks ******/
/* IE6 and below */
* html #uno { color: red }
/* IE7 */
*:first-child+html #dos { color: red }
/* IE7, FF, Saf, Opera */
html>body #tres { color: red }
@mitchellhislop
mitchellhislop / states.html
Created September 1, 2011 16:00
State Options
<div><label class="bold" for="state">State:</label></div>
<select id="state" name="state" class="selectall width50"><option value="">----</option><option value="AL">AL</option><option value="AK">AK</option><option value="AZ">AZ</option><option value="AR">AR</option><option value="CA">CA</option><option value="CO">CO</option><option value="CT">CT</option><option value="DE">DE</option><option value="DC">DC</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="IA">IA</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="ME">ME</option><option value="MD">MD</option><option value="MA">MA</option><option value="MI">MI</option><option value="MN">MN</option><option value="MS">MS</option><option value="MO">MO</option><option value="MT">MT</option><option value="NE">NE</option><option value="NV">NV</option>
@mitchellhislop
mitchellhislop / gist:1150240
Created August 16, 2011 21:37 — forked from niczak/gist:1150238
jQuery Form Validation
function fnValidate()
{
var aFields =
{"First Name":"sFirst",
"Last Name":"sLast",
"DRI Affiliation":"sAffil1",
"DRI Email":"sEmail_DRI"};
var bValid = true;
@mitchellhislop
mitchellhislop / fbdetect.js
Created August 15, 2011 20:25
Detect if someone is logged into FB, and the different states
FB.getLoginStatus(function(response) {
if(response.session) {
fbCheckUserPerms(); //show the FB login
} else {
// no user session available, someone you dont know
if(response.status == "notConnected") {
// But user is logged into facebook
alert("But is logged In"); //show the FB login
} else {
// show the default login
@mitchellhislop
mitchellhislop / fbbutton.css
Created August 3, 2011 16:16
FB rounded button css
.styled-button-3 {
-webkit-box-shadow: rgba(0, 0, 0, 0.0.97) 0px 1px 0px 0px;
background-color: #00559F;
border: 1px solid #29447E;
font-family: Arial;
font-size: 12px;
font-weight: bold;
padding: 4px 6px;
height: 20px;
@mitchellhislop
mitchellhislop / fbbutton.css
Created August 3, 2011 16:16
FB rounded button css
.styled-button-3 {
-webkit-box-shadow: rgba(0, 0, 0, 0.0.97) 0px 1px 0px 0px;
background-color: #00559F;
border: 1px solid #29447E;
font-family: Arial;
font-size: 12px;
font-weight: bold;
padding: 4px 6px;
height: 20px;