Skip to content

Instantly share code, notes, and snippets.

@grena
grena / format-size.php
Last active January 25, 2019 09:34
Snippet to convert bytes size to human readable size in PHP.
<?php
function filesize_formatted($path)
{
$size = filesize($path);
$units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$power = $size > 0 ? floor(log($size, 1024)) : 0;
return number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
}
@grena
grena / gist.sh
Last active August 29, 2015 14:24
# Size per directory
du -sh *
# More human
du -hsx * | sort -rh | head -10
# Size per directory, sorted by size, with total and hidden dirs
du -sch .[!.]* * |sort -h
# Free disk space
@grena
grena / scraper.py
Created October 15, 2015 08:04
Scraper for http://downloads.khinsider.com/, a game OST download website.
import json
import wget
import re
import urllib.request
from datetime import datetime
from bs4 import BeautifulSoup
# CONFIGURATION
MAIN_URL = 'http://downloads.khinsider.com/game-soundtracks/album/world-of-warcraft-direct-game-rip-'
# END CONFIGURATION
@grena
grena / 1-Explanations.md
Created December 4, 2015 20:24 — forked from danvbe/1-Explanations.md
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
@grena
grena / function.js
Created March 4, 2016 15:31
Automatic placement for bootstrap popover
// Source https://github.com/twbs/bootstrap/issues/1833#issuecomment-4102195
placement: function (tip, element) {
var offset = $(element).offset();
height = $(document).outerHeight();
width = $(document).outerWidth();
vert = 0.5 * height - offset.top;
vertPlacement = vert > 0 ? 'bottom' : 'top';
horiz = 0.5 * width - offset.left;
horizPlacement = horiz > 0 ? 'right' : 'left';
@grena
grena / .fonts.conf
Created March 17, 2016 11:15
Avoid shitty font on debian, to put in home folder.
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="hinting">
  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • chore: Other changes that don't modify src or test files
@grena
grena / association_type.md
Last active June 15, 2016 10:02
Structured formats for PIM entities

AssociationType

Standard

[
	'code'   => 'mycode',
	'labels' => [
	   'fr_FR' => 'XSELL',
	   'en_US' => 'Vente croisée',
	]

Keybase proof

I hereby claim:

  • I am grena on github.
  • I am grena (https://keybase.io/grena) on keybase.
  • I have a public key whose fingerprint is B051 D11C 8DDE 71E4 50E9 9FAF F8AA 53AC 4B68 ED90

To claim this, I am signing this object:

@grena
grena / test.md
Last active January 24, 2017 10:48

By default in the pre-filled cartouche:

Q A
Added Specs Todo
Added Behats Todo
Added integration tests Todo
Changelog updated Todo
Review and 2 GTM Todo
Micro Demo to the PO (Story only) Todo