Skip to content

Instantly share code, notes, and snippets.

View yann-yinn's full-sized avatar

Yann yann-yinn

  • Yann
  • France, Nantes
View GitHub Profile
@yann-yinn
yann-yinn / nginx-conf
Created May 17, 2018 07:40
Nginx conf with automatically renewed ssl certificate (cerbot) for NodeJS or React app (or any static files
# first install certbot and then run this command on your server
# certbot certonly --authenticator standalone --pre-hook "nginx -s stop" --post-hook "nginx"
# this will stop for a few seconds your nginx server and generate your Let's Encrypt ssl certificates, and configure
# cron so that certificates are renewed automatically \o/
# now create your nginx conf for your nodejs app :
# on port 80 (http), redirect to httpS (443)
server {
if ($host = www.your-domain.com) {
@yann-yinn
yann-yinn / contactForm.js
Created April 16, 2018 14:16
redux form with contact form
import React from "react";
import { Field, reduxForm } from "redux-form";
import { TextField, TextArea, SubmitButton } from "./bulma/Form";
let ContactForm = props => {
return (
<form onSubmit={props.handleSubmit}>
<Field
name="name"
component={TextField}
@yann-yinn
yann-yinn / contactForm.js
Created April 16, 2018 14:16
redux form with contact form
import React from "react";
import { Field, reduxForm } from "redux-form";
import { TextField, TextArea, SubmitButton } from "./bulma/Form";
let ContactForm = props => {
return (
<form onSubmit={props.handleSubmit}>
<Field
name="name"
component={TextField}
@yann-yinn
yann-yinn / arrow-function.js
Last active May 17, 2018 07:50
if, else, return & natural language
/**
* Can be read like a natural language from top to bottom :
* "the function withTodosNull returns a function. If todos is null,
* this function return null, else, it return Component
*/
function withTodosNull(Component) {
return function (props) {
if (!props.todos) {
return null
}
@yann-yinn
yann-yinn / index.jsx
Created April 1, 2018 18:51
Get content from graphCMS with Next.js
import React from "react";
import { request, GraphQLClient } from "graphql-request";
export default class HomePage extends React.Component {
static async getInitialProps() {
const query = `{
allPosts {
id
slug
coverImage {
@yann-yinn
yann-yinn / example.html
Created January 23, 2018 09:06
Flex : center element vertically and horizontally
<!--
On the parent div :
display:flex
align-items: center;
justify-content: center;
-->
<div style="background: silver; height: 100vh; display:flex; align-items: center;justify-content: center;" class="container">
<div style="background: yellow; height: 20vh">Center me please</div>
</div>
@yann-yinn
yann-yinn / file.sh
Last active December 3, 2017 11:46
# lister les interfaces écoutables
tcpdump --list-interfaces
# écouter une interface "en0"
tcpdump -i en0
# écouter le traffic entrant ou sortant d'une IP en particulier
tcpdump host 1.2.3.4
tcpdump src 2.3.4.5
tcpdump dst 3.4.5.6
tcpdump port 80
handleChange = event => {
const target = event.target;
const value = target.type === "checkbox" ? target.checked : target.value;
const name = target.name;
this.setState({
[name]: value
});
};
@yann-yinn
yann-yinn / index.js
Created November 3, 2017 16:48
get url GET params from nuxt.js asyncData method
// destructuring
async asyncData({ route }) {
console.log(route);
}
// without destructuring
async asyncData(allParams) {
console.log(allParams.route);
}
@yann-yinn
yann-yinn / preferences.json
Last active October 25, 2017 21:05
Enable Emmet in jsx files with VSCODE 1.7
// add this line to your preferences
"emmet.includeLanguages": { "javascript": "javascriptreact" }