Skip to content

Instantly share code, notes, and snippets.

View camphi's full-sized avatar

Philippe Mendes Campeau camphi

View GitHub Profile
<?php
function getPrivate($obj, $varName)
{
return (function($varName){return $this->{$varName};})->call($obj, $varName);
}
function setPrivate($obj, $varName, $varValue)
{
(function() use ($varName, $varValue){$this->{$varName} = $varValue;})->call($obj);
}
DELETE
catalog_category_entity_int.*
FROM
catalog_category_entity_int
JOIN
catalog_category_entity ON
catalog_category_entity_int.entity_id = catalog_category_entity.entity_id
LEFT JOIN
eav_entity_attribute ON
(
@camphi
camphi / tar_pv_awk_gzip_progress.sh
Created October 16, 2018 14:39
gzip with progress
tar cf - . | pv -p -s `du -sb . | awk '{print $1}'` | gzip -9 > ../out.tgz
@camphi
camphi / prevent_wpautop.php
Created September 29, 2018 05:04
to prevent wpautop from altering your code add comment around pre tags which surround your code
<?php
echo '<!-- to prevent wpautop --><!-- <pre> -->
... your code here ...
<!-- </pre> -->';
@camphi
camphi / .htaccess
Created September 6, 2018 15:48
route all requests `/style.12345.css` to `/style.css`
# If you're not using a build process to manage your filename version
# revving, you might want to consider enabling the following directives
# to route all requests such as `/style.12345.css` to `/style.css`.
#
# To understand why this is important and even a better solution than
# using something like `*.css?v231`, please see:
# http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|m?js|png|svgz?|webp|webmanifest)$ $1.$3 [L]
@camphi
camphi / gist:5a74a5f126daf6a73a2cfd168fcd2559
Created September 2, 2018 19:16
find and replace chars in file name
for f in *; do tmp_f=`echo $f | tr "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\370\371\372\373\374\375\376\377" "aaaaaaaceeeeiiiienoooooouuuuyty"`; if [ "$tmp_f" != "$f" ]; then mv $f $tmp_f; echo "$f is renamed to $tmp_f"; fi done
@camphi
camphi / customSorts.js
Created August 30, 2018 16:03
javascript sorts custom function
function sortByPriorityAsc(a, b) {
if (typeof b !== 'undefined') {
return (a.priority - b.priority)
}
var direction = a ? 1 : -1 ;
return function(a, b) {
return (a.priority - b.priority) * direction
}
}
@camphi
camphi / debug.md
Created February 2, 2018 16:01
reusable cli

Git

remove merged branches

  • git branch --merged dev | grep -v -E "(master|dev)" | xargs -n 1 git branch -d
@camphi
camphi / 0_reuse_code.js
Created April 4, 2017 04:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console