Skip to content

Instantly share code, notes, and snippets.

View Dewep's full-sized avatar

Maigret Aurélien Dewep

View GitHub Profile
@Dewep
Dewep / fonts.js
Created April 1, 2019 14:42
pdf.js/src/core/fonts.js
/* Copyright 2012 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@Dewep
Dewep / example.js
Created January 10, 2017 14:30
MultiPart Uploader
function onChange(event) {
if (this.fileUploading) {
this.appEventsService.emit("error", "A file is already uploading.")
} else if (!event || !event.target || !event.target.files[0]) {
this.appEventsService.emit("error", "Input file error.")
} else if (!this.user || !this.user._id) {
this.appEventsService.emit("error", "User not found.")
} else {
var multiPartUploader = new MultiPartUploader({
url: this.apiService.baseApiPath + '/message/user/' + this.user._id + '/attachment',
@Dewep
Dewep / durationToString.js
Created October 26, 2016 14:05
Duration to string
/* Units: ms, s, m, h, d */
window.durationToString = function (duration, unit, minRate) {
var str = ''
unit = unit.toLowerCase()
if (minRate === undefined) {
minRate = 0.02
}
if (unit.startsWith('s')) {
duration *= 1000
@Dewep
Dewep / csv.html
Created October 25, 2016 16:03
JavaScript CSV Download
<!DOCTYPE>
<html>
<head>
<title>CSV</title>
</head>
<body>
<script type="text/javascript">
(function(){
function objectToCSV(content, separator) {
var str = ''
@Dewep
Dewep / auto-rescroll.html
Last active October 5, 2016 16:03
Timeout child scrollable
<!DOCTYPE>
<html>
<head>
<title>Test</title>
<style>
body { width: 200px; margin: 0 auto; }
.hide { display: none; }
#parent { height: 400px; overflow: auto; border: 1px solid #eee; margin-top: 30px; text-align: center; }
</style>
</head>
@Dewep
Dewep / logstash-nginx-error.conf
Created November 21, 2015 14:47
LogStash Grok - Match Nginx error - With multiline errors
input {
stdin {
}
}
filter {
mutate {
replace => {
"type" => "nginx-error"
}
@Dewep
Dewep / task.py
Last active October 29, 2015 18:12
Natural computation assessment #1
#!/usr/bin/env python3
__author__ = "Maigret Aurelien"
"""
$> python3 task.py
| pos x y | north | east | south | west | nomove | proba | stddev | probabilities
| --------- | ------- | ------ | ------- | ------ | -------- | ------- | -------- | ---------------
| 7 (0,0) | 0 | 1/4 | 1/6 | 0 | 7/12 | 0.090 | 0.003 | 0.090 0.087 0.094 0.085 0.088 0.090 0.091 0.093
| 8 (0,1) | 0 | 1/4 | 1/6 | 1/4 | 1/3 | 0.046 | 0.002 | 0.047 0.047 0.043 0.047 0.044 0.047 0.050 0.047
@Dewep
Dewep / pi.py
Last active October 9, 2015 18:47
ApproximationOfPI
from random import uniform
from math import fabs
from sys import argv
interface = len(argv) > 1
if interface:
import turtle
N = 100000000
ran = 1.5
@Dewep
Dewep / epitechDefense-to-Doodle.js
Last active August 25, 2015 22:31
Epitech defense to Doodle
(function(){
EpitechDoodle = EpitechDoodle || {};
$.ajax({
"url": window.location.origin + window.location.pathname + "?format=json",
dataType: "json"
}).success(function(data){
var fields = {
"type": "date",
"levels": 3,
"title": data.title,
@Dewep
Dewep / readme.md
Created July 28, 2015 13:06
Test preload image Google
#> python send_email.py
#> python server.py
Serving HTTP on 0.0.0.0 port 8000 ...
*************
Host: my-server.com:8000
Connection: Keep-alive