Skip to content

Instantly share code, notes, and snippets.

View jeromegamez's full-sized avatar
:octocat:

Jérôme Gamez jeromegamez

:octocat:
View GitHub Profile
@smottt
smottt / AcmeCommand.php
Created March 31, 2012 12:15
Quick tip for setting the correct host in your custom symfony2 command.
<?php
namespace Acme\DemoBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class AcmeCommand extends ContainerAwareCommand
{
anonymous
anonymous / duplicate_mf_meta
Created October 24, 2012 21:14
Magic Fields 2 - Post Duplications
//Duplicates Magic Field 2 meta data when using WPML to duplicate a post for translation
function duplicate_mf_meta($master_post_id, $target_post_id){
global $wpdb;
$table = $wpdb->prefix.'mf_post_meta';
$mf_metas = $wpdb->get_results("SELECT * FROM $table WHERE post_id = $master_post_id");
foreach($mf_metas as $mf_meta){
$master_meta_id = $mf_meta->meta_id;
$master_meta_value = $wpdb->get_var( $wpdb->prepare("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s LIMIT 1 OFFSET %d", $master_post_id, $mf_meta->field_name, $mf_meta->group_count - 1) ); //check since there may be multiple instances
@lolautruche
lolautruche / controller.php
Last active December 25, 2015 04:39
Pagination in eZ Publish 5
<?php
namespace Acme\TestBundle\Controller;
use eZ\Publish\Core\Pagination\Pagerfanta\ContentSearchAdapter;
use Pagerfanta\Pagerfanta;
use Symfony\Component\HttpFoundation\Response;
use eZ\Bundle\EzPublishCoreBundle\Controller;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier;
use eZ\Publish\API\Repository\Values\Content\Query;
@marclambrichs
marclambrichs / Vagrantfile
Created December 5, 2015 07:41
install plugins
################################################################################
# check plugins
################################################################################
required_plugins = %w(vagrant-hostmanager vagrant-hosts vagrant-vbguest)
plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
if not plugins_to_install.empty?
puts "Installing plugins: #{plugins_to_install.join(' ')}"
if system "vagrant plugin install #{plugins_to_install.join(' ')}"
exec "vagrant #{ARGV.join(' ')}"
@jmaupetit
jmaupetit / watson_prompt.bash
Last active May 3, 2016 10:30
Watson Bash Prompt
# Add this to your ~/.provile or ~/.bashrc depending on your system
#
# watson directory (require watson >= 1.3)
# This value is the default on MacOSX
WATSON_DIR="$HOME/Library/Application Support/watson"
watson_status() {
# colors taken from git-aware-prompt
# https://github.com/jimeh/git-aware-prompt
local txtred="$(tput setaf 1 2>/dev/null || echo '\e[0;31m')" # Red
@ttscoff
ttscoff / whereami.sh
Created July 2, 2014 16:08
Uses get-location/CoreLocation on a Mac and Google's geocoding API to tell you the street address of your current location
#!/bin/bash
# So you know whoami, but whereami?
# Relies on this handy hack <https://github.com/lindes/get-location>
latlong=$(/usr/local/bin/get-location 2> /dev/null \
| sed -e 's/.*<\(.*\)>.*/\1/')
address=$(curl -Ss "http://maps.googleapis.com/maps/api/geocode/json?latlng=$latlong&sensor=false" \
| grep formatted_address \
| head -n 1 \
| sed -e 's/[ \t]*"formatted_address" : "\(.*\)",/\1/')
#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
sudo -E -H apt-get install -y software-properties-common rkhunter fail2ban
sudo -H apt-add-repository -y -u ppa:ansible/ansible
sudo -H apt-get install -y ansible
sudo -H ansible-galaxy install dev-sec.os-hardening dev-sec.ssh-hardening 2>/dev/null
cat << 'EOF' > hardening-playbook.yml
- hosts: localhost
@vielhuber
vielhuber / script.js
Last active September 22, 2017 23:12
change hover to click in Advanced Menu #shopware
$(document).ready(function() {
$('.navigation-main .navigation--entry').off();
$('.navigation-main .navigation--entry').click(function() {
if( $(this).hasClass('is--hovered') ) {
$(this).removeClass('is--hovered');
$('.advanced-menu .menu--is-active').removeClass('menu--is-active');
return false;
}
else {
$(this).siblings('.is--hovered').removeClass('is--hovered');
@lolautruche
lolautruche / AdminController.php
Created June 2, 2013 19:58
eZ Publish 5 - Legacy module with a Symfony controller
<?php
/**
* AcmeTestBundle/Controller/AdminController.php
*/
namespace Acme\TestBundle\Controller;
use eZ\Bundle\EzPublishCoreBundle\Controller;
/**
* Here is your Symfony controller, defined as a service (see service definition below)
@bitjockey42
bitjockey42 / 00_OSX_Docker_Machine_Setup.md
Last active November 9, 2020 13:49 — forked from andystanton/Start up local Docker Machine on OSX automatically.md
Use native virtualization on OS X docker with xhyve

What this?

So one of the painful points of using docker on OS X is that you need to run a virtualbox VM, which often suffers from performance issues. With xhyve, a OS X virtualization system, and docker-machine-xhyve you can now have docker use the native OS X hypervisor to run containers.

No more dealing with virtualbox shenanigans!

In this script, I've also set up a way to autoconfigure terminal sessions to load docker's environment vars (dependent on docker-machine) so you do not have to run eval $(docker-machine env whatever) every time you open a new terminal window.

Requirements