Skip to content

Instantly share code, notes, and snippets.

<?php
$response = array();
$email = General::sanitize($postData['form']['email']);
$firstname = General::sanitize($postData['form']['firstname']);
$lastname = General::sanitize($postData['form']['lastname']);
if( isset($postData['form']['language']) && $postData['form']['language'] ){
$language = General::sanitize($postData['form']['language']);
} else {
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
environment_id="ruby-1.9.3-p0@inm"
#
# Uncomment the following lines if you want to verify rvm version per project
@danlefebvre
danlefebvre / gist:3865300
Created October 10, 2012 12:26
animated button in plain css
<div>
<a href="#" class="button"><span>Do Not Press This Button</span></a>
</div>
.button {
display: inline-block;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0 10px 0 #823a17, 0 15px 20px rgba(0, 0, 0, .5);
@danlefebvre
danlefebvre / gist:3009358
Created June 28, 2012 05:47
Findind locations with MySQL
Here's the SQL statement that will find the closest 20 locations that are within a radius of 25 miles to the 37, -122 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 25, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371.
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;
@danlefebvre
danlefebvre / gist:2978881
Created June 23, 2012 16:22
WP rewrites
<?php
//functions.php
/**
* En gros, ce que tu fais c'est définir un path avec une regex, ici "custom-post-type/([^/]+)/?$" , qui correspond à "custom-post-type/anything-you-want"
* En ensuite tu redéfini les variables de l'objet $wp_query. Les variables sont accessibles dans ton fichier de thème avec la fonction get_query_var()
* Un bon outil pour tester les rewrites : http://wordpress.org/extend/plugins/monkeyman-rewrite-analyzer/
*/
@danlefebvre
danlefebvre / gist:2331100
Created April 7, 2012 18:18
Reset post data WP
<?php
//top of page
$page_query = $wp_query;
//... do your stuff, call WP_Query, etc.
//reset $wp_query to current page
$wp_query = $page_query;
wp_reset_postdata();
@danlefebvre
danlefebvre / gist:2297647
Created April 4, 2012 04:11
Adding Virtual host Ubuntu
cd /etc/apache2/sites-available
sudo pico yourdomain.dev.conf
<VirtualHost *:80>
ServerName yourdomain.dev
DocumentRoot /home/dev/sites/yourdomain
</VirtualHost>
sudo pico /etc/hosts
@danlefebvre
danlefebvre / gist:2294057
Created April 3, 2012 17:45
Adding virtual host (Mac OSX)
#/etc/hosts
127.0.0.1 my-site.dev
#/Applications/MAMP/conf/apache/httpd.conf
<VirtualHost *>
DocumentRoot "/Users/dannybot/sites/my-site"
ServerName my-site.dev
</VirtualHost>
#restart server dans MAMP