Skip to content

Instantly share code, notes, and snippets.

View raphaelchaib's full-sized avatar

Raphael Chaib raphaelchaib

View GitHub Profile
@raphaelchaib
raphaelchaib / helpful-docker-commands.sh
Created January 22, 2018 17:25 — forked from garystafford/helpful-docker-commands.sh
My list of helpful docker commands
###############################################################################
# Helpful Docker commands and code snippets
###############################################################################
### CONTAINERS ###
docker stop $(docker ps -a -q) #stop ALL containers
docker rm -f $(docker ps -a -q) # remove ALL containers
docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter
# helps with error: 'unexpected end of JSON input'
@raphaelchaib
raphaelchaib / Default (OSX).sublime-mousemap
Created August 24, 2016 21:08 — forked from adzenith/Default (OSX).sublime-mousemap
Sublime Text 2 better mouse handling
[
// Basic drag select
{
"button": "button1", "count": 1,
"press_command": "drag_select_callback"
},
{
// Select between selection and click location
"button": "button1", "modifiers": ["shift"],
"press_command": "drag_select_callback",
@raphaelchaib
raphaelchaib / clone.js
Created June 8, 2016 17:30 — forked from joshcarr/clone.js
Javascript Cloning
// FROM http://stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object
// When I had to implement general deep copying I ended up compromising by
// assuming that I would only need to copy a plain Object, Array, Date, String,
// Number, or Boolean. The last 3 types are immutable, so I could perform a
// shallow copy and not worry about it changing. I further assumed that any
// elements contained in Object or Array would also be one of the 6 simple
// types in that list. This can be accomplished with code like the following:
function clone(obj) {
@raphaelchaib
raphaelchaib / clone_anythings.js
Created June 7, 2016 22:19 — forked from chrisyip/clone_anythings.js
Clone Anything with JavaScript
// http://davidwalsh.name/javascript-clone
function clone(src) {
function mixin(dest, source, copyFunc) {
var name, s, i, empty = {};
for(name in source){
// the (!(name in empty) || empty[name] !== s) condition avoids copying properties in "source"
// inherited from Object.prototype. For example, if dest has a custom toString() method,
// don't overwrite it with the toString() method that source inherited from Object.prototype
s = source[name];
if(!(name in dest) || (dest[name] !== s && (!(name in empty) || empty[name] !== s))){
@raphaelchaib
raphaelchaib / watchlist.php
Created December 21, 2015 05:35
Sync IMDb watchlist to trakt.tv watchlist. Usage: php -f watchlist.php trakt_apikey trakt_username trakt_passwordhash imdb_login imdb_password imdb_uid (IMDb login is email adress or nickname, it's NOT the ur12345678 bit, that's the imdb_uid)
<?php
define('TRAKT_APIKEY', $argv[1]);
define('TRAKT_USERNAME', $argv[2]);
define('TRAKT_PASSWORD', $argv[3]);
define('IMDB_EMAIL', $argv[4]);
define('IMDB_PASSWORD', $argv[5]);
define('IMDB_UID', $argv[6]);
function curl_post($urlpre, $data, $urlpost = '')
@raphaelchaib
raphaelchaib / open_scholar_setup.sh
Created November 22, 2015 02:10 — forked from rsmenon/open_scholar_setup.sh
Setup OpenScholar on EC2
#!/bin/sh
#Ravi Menon
#20/Aug/2014
MYSQL_ROOT_PASSWD=~/.mysql_root
install_dependencies() {
#Refresh Ubuntu package list
sudo apt-get update

###Init

  1. Spawn Ubuntu instance.
  2. Update aptitude with sudo apt-get update
  3. Install junk we want sudo apt-get install nginx spawn-fcgi php5 php5-cli php5-common php5-suhosin php5-cgi php-pear php5-mysql htop git
  4. Set root password sudo passwd root

###Setup PHP

  1. Change /etc/nginx/sites-available/default to:
server {
@raphaelchaib
raphaelchaib / Setup.md
Created November 22, 2015 02:02 — forked from suvozy/Setup.md
Setup AWS EC2 and RDS (php5.5, apache2.4, mysql5.5, phpmyadmin)
$.slugify = function(text) {
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 );
function woocommerce_category_image() {
if ( is_product_category() ){
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
if ( $image ) {
echo '<img src="' . $image . '" alt="" />';
}