Skip to content

Instantly share code, notes, and snippets.

View benfavre's full-sized avatar
💻
At the office

Webdesign29 benfavre

💻
At the office
View GitHub Profile
@benfavre
benfavre / import
Created January 10, 2014 20:37
Mysql Import csv files
LOAD DATA INFILE 'file.csv' INTO TABLE commandes
FIELDS TERMINATED BY ';' ENCLOSED BY ''
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(column1, column2);
@benfavre
benfavre / gist:10023351
Created April 7, 2014 16:14
Php display taxonomy terms
<?php // Get terms for post
$terms = get_the_terms( $post->ID , 'oil' );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print $term->slug ;
?>
<?php
// Add custom meta to user profile screen
add_action( 'show_user_profile', 'example_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'example_show_extra_profile_fields' );
function example_show_extra_profile_fields( $user ) { ?>
<h3>Payment information</h3>
@benfavre
benfavre / eps_to_png.sh
Created September 11, 2014 19:44
Batch EPS to PNG with colorspace conversion croping and centering
for f in *.eps; do echo "Converting $f"; convert -colorspace sRGB $f -density 300 -quality 100% -colorspace rgb -flatten -resize 1200x1000^ -gravity center -crop 1200x1000+0+0 /var/www/suivisalades/public/media/images-produits/png/"$(basename "$f" .eps).png"; done
@benfavre
benfavre / gravity
Created December 12, 2014 17:46
Gravity forms Less - BOOTSTRAP
.gform_wrapper ul {
.list-unstyled();
}
.gform_wrapper li {
.form-group();
}
.gform_wrapper form {
margin-bottom: 0;
}
.gform_wrapper .gfield_required {
@benfavre
benfavre / league-ubuntu-linux
Created December 29, 2014 22:03
Patch League with tuxlol, for linux ubuntu League of legends
#!/bin/sh
# --- README ---
# Run this patch after every update or the game will crash before loading
# adjust paths if needed
# get tuxlol https://bitbucket.org/Xargoth/tuxlol/downloads
# get mono: apt-get install mono-runtime libmono-system-core4.0-cil
cd ~/.PlayOnLinux/wineprefix/LeagueOfLegends/tuxlol/
mono tuxlol.exe patch --dir ../drive_c/Riot\ Games/League\ of\ Legends/ -- no-backup
@benfavre
benfavre / -README.md
Created February 19, 2016 17:44 — forked from jirutka/-README.md
How to use terminal on Windows and don’t go crazy…

How to use terminal on Windows without going crazy…

Windows is really horrible system for developers and especially for devops. It doesn’t even have a usable terminal and shell, so working with command line is really pain in the ass. If you really don’t want to switch to any usable system (OS X, Linux, BSD…), then this guide should help you to setup somewhat reasonable environment – usable terminal, proper shell, ssh client, git and Sublime Text as a default editor for shell.

Install stuff

  1. Download and install Git for Windows* with:
    • [✘] Use Git from the Windows Command Prompt
  • [✘] Checkout as-is, commit Unix-style line endings
@benfavre
benfavre / dos2unix_recursive
Created July 8, 2016 10:36
Recursively replace line ending in linux
find . -type f -print0 | xargs -0 dos2unix
// see : http://superuser.com/questions/757081/how-do-i-convert-all-files-in-a-folder-to-a-different-line-ending-on-windows
@benfavre
benfavre / .js
Created September 5, 2016 15:59
Serialize Form to JSON
(function ($) {
$.fn.serializeFormJSON = function (options) {
options = jQuery.extend({}, options);
var self = this,
json = {},
push_counters = {},
patterns = {
"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
@benfavre
benfavre / boot_app.sh
Created September 26, 2016 15:12
Boot file
#!/bin/sh
export DEBCONF_NONINTERACTIVE_SEEN=true DEBIAN_FRONTEND=noninteractive
echo "App boot script"
export APP_DATABASE_HOST="db"
echo "Setup env variables"
/sbin/setuser www-app cp /var/www/html/.env.example /var/www/html/.env && \
sed -i "s|%database_name%|${APP_DATABASE_NAME}|g" /var/www/html/.env && \
sed -i "s|%database_user%|${APP_DATABASE_USER}|g" /var/www/html/.env && \