Skip to content

Instantly share code, notes, and snippets.

View soner8's full-sized avatar

Maco soner8

View GitHub Profile
@soner8
soner8 / determine-changed-props.js
Created June 13, 2019 07:13 — forked from sorenlouv/determine-changed-props.js
Determine which props causes React components to re-render
import React, { Component } from 'react';
export default function withPropsChecker(WrappedComponent) {
return class PropsChecker extends Component {
componentWillReceiveProps(nextProps) {
Object.keys(nextProps)
.filter(key => {
return nextProps[key] !== this.props[key];
})
.map(key => {
@soner8
soner8 / Chat.tsx
Created October 29, 2018 16:29
Phone Auth
import * as React from "react";
import { Image, Platform, Text, TouchableOpacity, View } from "react-native";
import firebase from "react-native-firebase";
import { NavigationParams } from "react-navigation";
import Bot from "./botMessage.json";
import { Input } from "./Input";
import { Messages } from "./Messages";
import { styles } from "./styles";
const bot = Bot;
@soner8
soner8 / getMiddle.js
Created June 7, 2018 11:42
CodeWars Maco
You are going to be given a word. Your job is to return the middle character of the word.
If the word's length is odd, return the middle character.
If the word's length is even, return the middle 2 characters.
String.prototype.toJadenCase = function () {
return this.split(' ').map(function (item) {
return item.replace(item.charAt(0), item.charAt(0).toUpperCase());
}).join(' ');
};
@soner8
soner8 / promise.js
Created June 3, 2018 16:20
Promise
class Monstre {
constructor (options = {}){
this.health = 100;
this.name = options.name;
}
heal() {
this.health= this.health + 10;
return this.health;
@soner8
soner8 / ES6.js
Last active May 22, 2018 15:15
ES6 Partie 3
const address = {
city: "Lyon",
state: "FR",
zip: 69001
};
const sportList = ['Football', 'BasketBall']
const otherSportList = ['Boxe', 'Judo']
sportList.push(...otherSportList)
@soner8
soner8 / MyTimer.js
Created April 23, 2018 14:27
timer
import React, {Component} from 'react';
class MyTimer extends React.Component {
constructor (props) {
super(props)
this.state = {count: 1}
}
componentDidMount () {
this.startTimer(this.timer)
}
@soner8
soner8 / app.js
Created April 21, 2018 14:25
Password.js
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import logo from './logo.svg';
import './App.css';
import Author from './test';
import Password from './password';
class App extends Component {
render() {
@soner8
soner8 / app.js
Created April 17, 2018 07:33
Author
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import logo from './logo.svg';
import './App.css';
import Author from './test';
class App extends Component {
render() {
return (
<div className="App">
@soner8
soner8 / upload.js
Created April 16, 2018 15:10
upload
var express = require('express');
var router = express.Router();
var multer = require('multer');
var upload = multer({
dest: 'tmp/'
});
var fs = require('fs');
/* GET home page. */
router.get('/', function (req, res, next) {
res.render('index', {
@soner8
soner8 / Delete.js
Created April 16, 2018 13:42
Delete.js
var express = require('express');
var router = express.Router();
//PUT
router.get('/:nom((\[a-z]+))', function (req, res, next) {
res.render('update-user', {
id: req.params.nom
});
});