Skip to content

Instantly share code, notes, and snippets.

View arguiot's full-sized avatar
🤑
Trading meme coins

Arthur Guiot arguiot

🤑
Trading meme coins
View GitHub Profile
@arguiot
arguiot / average_function.php
Last active September 2, 2016 12:10
image color average using PHP
//I made a function that calculates the average color of a given image resource and returns it in "#rrggbb" format (hex):
function average($img) {
$w = imagesx($img);
$h = imagesy($img);
$r = $g = $b = 0;
for($y = 0; $y < $h; $y++) {
for($x = 0; $x < $w; $x++) {
$rgb = imagecolorat($img, $x, $y);
$r += $rgb >> 16;
@arguiot
arguiot / nightmode.css
Created March 19, 2017 07:53
Night Mode CSS
//Create a Night version of any website
body { zoom: 100%; } * { background: #111111 !important; color: #ABABAB !important; } :link, :link * { color: #DBDBDC !important } :visited, :visited * { color: #5B5B5B !important }
@arguiot
arguiot / 2=1
Last active June 9, 2017 08:49
The proof that 2=1
2 =1+1
2 = 1 + (−1) * (−1)
2 = 1 + (e^πi)^2
2 = (e^πi)^2 +(e^πi)^2
2 = (eπi)^4
4 root (2)=e^πi
4 root (2) = −1
2 = −1^4
2 = 1
@arguiot
arguiot / cartesianPointDist.js
Last active May 1, 2017 08:57
This will give you the distance between 2 or 3 (depends how many axis you have) points on a cartesian plane
// This will give you the distance between 2 or 3 (depends how many axis you have) points on a cartesian plane
// © Arthur Guiot 2017
// Sqare Root algorithm based on babylonian method
// @param n - the number to compute the square root of
// @param g - the best guess so far (can omit from initial call)
const squareroot = (n, g) => {
if (!g) {
// Take an initial guess at the square root
// Add Display.js
<script src="https://unpkg.com/display.js"></script>
@arguiot
arguiot / primes_prob.py
Created June 26, 2017 04:12
Primes probability
import numpy as np
import matplotlib.pyplot as plt
import sympy as sp
import progressbar
def numOfPrimesBellow(n):
# primeArray = []
# for i in range(n):
# if i in sp.sieve:
# primeArray.append(i)
@arguiot
arguiot / display.es6.min.js
Created July 23, 2017 17:44
Compiled version of DisplayJS v0.3.2 for CDNJS
class DisplayJS{constructor(a){this.obj=a}var(a){const b=()=>{this.if(),this.else();const a=document.querySelectorAll("[var]");for(let b=0;b<a.length;b++){const c=a[b].getAttribute("var");a[b].innerHTML=this.obj[c]}};a?!0==a?(b(),this.live(this.obj,()=>{b()})):window.setInterval(()=>{b()},a):b()}xss(a){const b=/</g,c=/>/g,d=/'/g,e=/"/g;return a.toString().replace(b,"&lt;").replace(c,"&gt;").replace(d,"&#39;").replace(e,"&#34;")}xssURI(a){return encodeURI(a)}target(b=()=>{this.var()}){const c=(()=>{return document.addEventListener?(a,b,c)=>{a.addEventListener(b,c,!1)}:(a,b,c)=>{a.attachEvent(`on${b}`,c)}})(),d=this.obj;[].forEach.call(document.querySelectorAll("[target]"),(e,f,g)=>{c(g[f],"change",function(){const a=g[f].getAttribute("target");d[a]="checkbox"==this.type?this.checked:this.value,b()}),c(g[f],"keydown",function(){const a=g[f].getAttribute("target");d[a]="checkbox"==this.type?this.checked:this.value,b()}),c(g[f],"input",function(){const a=g[f].getAttribute("target");d[a]="checkbox"==this.type?this
@arguiot
arguiot / sha256.js
Created October 30, 2017 14:30
Easy to use sha256 implementation in JavaScript
function sha256(s) {
const chrsz = 8;
const hexcase = 0;
function safe_add(x, y) {
const lsw = (x & 0xFFFF) + (y & 0xFFFF);
const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
function S(X, n) {
@arguiot
arguiot / xorcipher.js
Created October 30, 2017 14:31
XOR Cipher encryption in JavaScript
const XORCipher = {
encode(key, data) {
data = xor_encrypt(key, new String(data).split(""));
return b64_encode(data);
},
decode(key, data) {
data = b64_decode(data);
return xor_decrypt(key, new String(data).split(""));
}
};
@arguiot
arguiot / model.js
Last active November 20, 2017 12:00
MNIST digits model - brain.js
This file has been truncated, but you can view the full file.
window["netData"] = {
"layers": [
{
"0": {},
"1": {},
"2": {},
"3": {},
"4": {},
"5": {},
"6": {},