Skip to content

Instantly share code, notes, and snippets.

View maxgfr's full-sized avatar
🎯
Focusing

Maxime Golfier maxgfr

🎯
Focusing
View GitHub Profile
@maxgfr
maxgfr / erase_usb_stick.md
Last active December 2, 2022 22:16
Erase a USB stick format on mac os

Erase a USB stick format on mac os

sudo diskutil eraseDisk FAT32 MAX_USB disk2
@maxgfr
maxgfr / copy_html.js
Last active December 2, 2022 22:18
Copy HTML page in local with nodejs
const URL = ""
const rp = require('request-promise');
const fs = require('fs');
rp(URL).then(function(html){
fs.writeFile("./res.html", html, function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
@maxgfr
maxgfr / socket_express_react.js
Last active April 8, 2020 16:02
Socket.io + Express JS + React JS
var socket = require('socket.io');
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.join(__dirname, 'build')));
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
@maxgfr
maxgfr / node_websocket_kraken.js
Created May 20, 2020 17:02
Example of node application using kraken websocket
const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.kraken.com');
ws.on('open', function open() {
ws.send(JSON.stringify({
"event": "subscribe",
"pair": [
"BTC/USD",
"ETH/USD",
@maxgfr
maxgfr / ffmpeg.md
Last active February 14, 2023 12:51
Tricks using ffmpeg

FFMPEG

How to generate an empty video of 12 minutes ?

$ ffmpeg -t 720 -s 640x480 -f rawvideo -pix_fmt rgb24 -r 25 -i /dev/zero empty.mpeg

Concat videos using ffmepg

@maxgfr
maxgfr / nodemail_tester.js
Last active December 4, 2022 10:42
Testing nodemailer
const nodemailer = require('nodemailer');
sendMail('gmail', '[email protected]', 'Maxime', '[email protected]', 'Informations V2.0', 'Bonjour Maxime\nPasse une belle journée :p')
.then((res) => {
console.log('Email sent: ' + res.response)
})
.catch((err) => {
console.log(err);
});
@maxgfr
maxgfr / rename_js_to_jsx.md
Last active December 2, 2022 22:20
Rename JS file to JSX file

Rename JS file to JSX file

find . -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.jsx"' {} \;

# or
find ./ -depth -name "*.js" -exec sh -c 'mv "$1" "${1%.js}.jsx"' _ {} \;
@maxgfr
maxgfr / overlay_container.js
Created July 17, 2020 19:27
Make our own convenient OverlayContainer. The trick is to use absolute with 100% size (cf : https://github.com/onmyway133/blog/issues/254)
// @flow
import React from 'react'
import { View, StyleSheet } from 'react-native'
type Props = {
behind: React.Component,
front: React.Component,
under: React.Component
}
@maxgfr
maxgfr / axios_interceptor.js
Created August 22, 2020 18:32
Axios interceptor
import axios from 'axios'
import store from './redux/store'
const AxiosInstance = axios.create()
AxiosInstance.interceptors.response.use(
(response) => {
return response
},
async function (error) {