Skip to content

Instantly share code, notes, and snippets.

View charleslouis's full-sized avatar

okcharlo charleslouis

View GitHub Profile
@charleslouis
charleslouis / keybindings.sublime-keymap
Created April 18, 2013 14:10
Sublime-Text Keybindings
[
{ "keys": ["ctrl+alt+n"], "command": "new_window" },
{ "keys": ["ctrl+o"], "command": "show_overlay", "args": {"overlay": "goto"} },
{ "keys": ["ctrl+shift+o"], "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"} },
{ "keys": ["ctrl+t"], "command": "auto_complete" },
{ "keys": ["ctrl+shift+t"], "command": "console_start" },
// { "keys": ["ctrl+shift+d"], "command": "find_all_under" },
{ "keys": ["ctrl+shift+c"], "command": "toggle_comment" },
{ "keys": ["ctrl+alt+down"], "command": "duplicate_line" },
{ "keys": ["ctrl+alt+x"], "command": "prefixr" },
@charleslouis
charleslouis / RandomClassesDivs.js
Created April 18, 2013 23:31
Javascript - append div in a container with random classes and positions
(function RandomClassesDivs(){
// declare classes we want to apply
var bubbleColors = ['bubble_color_1', 'bubble_color_2', 'bubble_color_3', 'bubble_color_4', 'bubble_color_5', 'bubble_color_6'];
var bubbleSizes = ['bubble_1', 'bubble_2', 'bubble_3', 'bubble_4', 'bubble_5'];
//find the highest key of the classes arrays
var nbrSizes = (bubbleSizes.length) - 1,
nbrColors = (bubbleColors.length) - 1;
<!DOCTYPE HTML>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Mouse Parallax Effect</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="parallax">
<img class="parallax-item" src="http://bymarina.com.br/wp-content/uploads/2011/01/sol2.jpg" width="150">
@charleslouis
charleslouis / _mixins-custom.scss
Created April 23, 2013 06:58
SASS - Custom Mixins
@mixin opacity( $opacity ) {
// where 0 <= $opacity <= 1
zoom: 1;
filter: alpha(opacity= ( $opacity * 100 ));
opacity: $opacity;
}
@charleslouis
charleslouis / _video.scss
Last active December 16, 2015 14:40
Javascript - Jquery - Video player - append iframe ondemand
//
// Wells
// --------------------------------------------------
// Base class
.video-wrapper {
position: relative;
padding: 3em 0;
border-top: 1px solid $linkColor;
@charleslouis
charleslouis / add_custom_gravatar.php
Created May 9, 2013 13:31
php - wordpress - custom default Gravatar + localhost support hack
/* AVATAR */
// Add a default avatar to Settings > Discussion
add_filter( 'avatar_defaults', 'add_custom_gravatar' );
if ( !function_exists('add_custom_gravatar') ) {
function add_custom_gravatar( $avatar_defaults ) {
$myavatar = get_stylesheet_directory_uri() . '/_inc/img/avatar.png';
$avatar_defaults[$myavatar] = 'Avatar Santé Ensemble';
return $avatar_defaults;
@charleslouis
charleslouis / record-custom-post-type-in-buddyPress-activity.php
Created May 10, 2013 11:28
php - wordpress - buddy press - record custom post type in activity
/*============================================================
= record custom post types in activity =
============================================================*/
add_action( 'save_post', 'record_activity', 10, 2 );
function record_activity( $post_id, $post, $user_id = false ) {
global $bp, $wpdb;
$post_id = (int)$post_id;
@charleslouis
charleslouis / use-custom-post-type-dedicated-template.php
Created May 10, 2013 11:29
php - wordpress - customp post type - force usage of dedicated template for custom post type
/*=======================================================================
= force dedicated template usage for custom posts =
=======================================================================*/
add_filter( 'template_include', 'include_template_function', 1 );
function include_template_function( $template_path ) {
if ( get_post_type() == 'fiche-projet' ) {
if ( is_single() ) {
// checks if the file exists in the theme first,
@charleslouis
charleslouis / dropdown-custom-taxonomies.php
Created May 10, 2013 11:31
php - wordpress - dropdown - custom taxonomies - remove and add meta box
/*==================================================
= dropdown custom taxonomies =
==================================================*/
function custom_meta_box() {
remove_meta_box( 'annee-de-demarrage-du-projetdiv', 'fiche-projet', 'side' );
add_meta_box( 'annee-de-demarrage-du-projetdiv', 'annee-de-demarrage-du-projet', 'annee_demarrage_meta_box', 'fiche-projet', 'side');
// add_meta_box( 'tagsdiv-annee-de-demarrage-du-projet', 'annee-de-demarrage-du-projet', 'annee_demarrage_meta_box', 'fiche-projet', 'side');
@charleslouis
charleslouis / remove_tools_menu.php
Created May 15, 2013 14:03
Php - wordpress - Remove menu or submenus items in wordpress admin menu if user is not admin - or any other role
/**
* [remove_tools_menu
* Remove menu or submenus items in wordpress admin menu if user is not admin - or any other role ]
* @return [noting] [simply unset menus]
*/
function remove_tools_menu() {
if ( current_user_can('admin_itr') || current_user_can('administrator') ) {
return;
} else {