Skip to content

Instantly share code, notes, and snippets.

View chindit's full-sized avatar
🦙
Lama, what else ?

David Lumaye chindit

🦙
Lama, what else ?
View GitHub Profile
@chindit
chindit / main.rs
Created November 24, 2022 19:16
Compress & upload a file
use flate2::write::{GzEncoder};
use flate2::Compression;
use std::fs::File;
use reqwest::blocking::Client;
use std::error;
use std::fs;
use reqwest::header::CONTENT_LENGTH;
use reqwest::header::AUTHORIZATION;
use reqwest::blocking::multipart::Form;
@chindit
chindit / login.php
Created June 23, 2018 07:55
php-opencloud login with Identity V3
<?php
/**
* Login with php-opencloud and Identity v3 is really badly explained.
*
* Here is a bit of code that allows you to easily connect to your OpenStack using Keystone (Identity) v3
*/
use OpenStack\ObjectStore\v1\Service;
use OpenStack\OpenStack;
use Psr\Log\LoggerInterface;
@chindit
chindit / cleanString.php
Created August 6, 2017 10:47
Clean a string to latin equivalent
<?php
/**
* Clean a string and return it with only letters, numbers, «.», «-» and «_»
* Spaces are replaced by «_»
*/
public function cleanName(string $filename) : string
{
return preg_replace("/[^.a-zA-Z0-9_-]+/", "",
transliterator_transliterate('Any-Latin;Latin-ASCII;',
str_replace(' ', '_', $filename)));
@chindit
chindit / ImageFactory.php
Last active February 14, 2021 18:05
FilePath to GD resource
<?php
declare(strict_types=1);
final class ImageFactory
{
public static function getResource(string $filePath): \GdImage
{
if (!is_file($filePath)) {
throw new IOException('File «' . $filePath . '» was not found');
<?php
declare(strict_types = 1);
/**
* Created by PhpStorm.
* User: david
* Date: 15/02/2017
* Time: 08:01
*/
namespace AppBundle\Services;
@chindit
chindit / style.css
Created June 22, 2016 21:18
Form style for FOSUserBundle
form:not('.special'){
display: block;
margin: auto;
width: 214px;
border: 1px solid gray;
padding: 7px;
border-radius: 15px;
}
form#formLogin input:not([type="checkbox"]), form#formRegister input:not([type="checkbox"]), form#formRequest input:not([type="checkbox"]){
width: 25vw;