Skip to content

Instantly share code, notes, and snippets.

View beunwa's full-sized avatar

Benoit Chevillot beunwa

View GitHub Profile
@beunwa
beunwa / gist:a49233f7588441aa77da49e00f2d3d5a
Last active May 27, 2024 15:05
midjourney php generator
function generateMidjourneyImage($prompt){
$jobIdFile = md5($prompt);
if (file_exists('./jobs/' . $jobIdFile)) {
$jobId = file_get_contents('./jobs/' . $jobIdFile);
die('https://cdn.midjourney.com/' . $jobId . '/0_1.png');//ou 0_2.png ou 0_3.png ou 0_4.png
}
$client = new GuzzleHttp\Client();
//créez un fichier mylock avec les droit de l'utilisateur qui execute le cron
//lancez la fonction mycron via votre systeme de cron
//voila, plus jamais d'overlap de cron
function mycron() {
$error = false;
//on ouvre le fichier du verrou
$fp = fopen("./mylock", "w+");
if (flock($fp, LOCK_EX | LOCK_NB)) { // acquière un verrou exclusif
//toute la logique metier du cron qui peut durer
@beunwa
beunwa / apacheloggoogle2csv
Last active August 29, 2015 14:06
extract des visites google depuis les logs apache et le transforme en csv
awk '{if($14 ~ /Googlebot/) {print $7}}' apache.log | sort | uniq -c | sort -n | tail -40 | sed 's/^[ \t]*//;s/[ \t]*$//' > top40google.csv
more apache.log | grep Googlebot | awk {'split($4, a, ":"); split(a[1], a, "["); print a[2]'} | sort | uniq -c | sed 's/^[ \t]*//;s/[ \t]*$//' > google-visits-per_day.csv
more apache.log | grep Googlebot | awk {'print $7'} | sort | uniq -c | wc -l
@beunwa
beunwa / 0_reuse_code.js
Created January 18, 2014 13:05
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
@beunwa
beunwa / bookmarklet-remove-twitter-pub
Last active December 23, 2015 06:19
bookmarklet pour supprimer automatiquement les pubs twitter à chaque fois qu'elles apparraissent (sur la version web)
$('.stream-container').bind("DOMNodeInserted",function(){$('.js-promoted-badge').closest('.js-stream-item').each(function(index) { $(this).hide() });});
javascript:(function(){$('.stream-container').bind("DOMNodeInserted",function(){$('.js-promoted-badge').closest('.js-stream-item').each(function(index) { $(this).hide() });}); })();
@beunwa
beunwa / bookmarklet-extract-twitter-followers
Last active December 16, 2015 13:38
extract twitters followers
$('.stream-item-header').each(function(index) { console.log($(this).find('.fullname')[0].innerHTML+';'+$(this).find('.username')[0].innerHTML) });
@beunwa
beunwa / Utf8 emergency
Created April 11, 2013 17:00
En cas d'urgence utf8 :)
sed -e 's/î/î/g' -i monfichier
sed -e 's/î/î/g' -i monfichier
sed -e 's/û/û/g' -i monfichier
sed -e 's/é/é/g' -i monfichier
sed -e 's/û/û/g' -i monfichier
sed -e 's/é/é/g' -i monfichier
sed -e 's/ç/ç/g' -i monfichier
sed -e 's/ç/ç/g' -i monfichier
sed -e 's/à/à/g' -i monfichier
sed -e 's/è/è/g' -i monfichier