Skip to content

Instantly share code, notes, and snippets.

View theodesp's full-sized avatar
🦄
Jumping over Rainbows...

Theofanis Despoudis theodesp

🦄
Jumping over Rainbows...
View GitHub Profile
import React, {Component} from 'react';
import {FormattedMessage} from 'react-intl';
import logo from './logo.svg'
import './Home.css';
class Home extends Component {
render() {
return (
<div className="Home">
<div className="Home-header">
@theodesp
theodesp / index.js
Last active November 14, 2019 12:39
ReactDOM.render(
<IntlProvider
locale={i18nConfig.locale}
defaultLocale={i18nConfig.locale}
messages={i18nConfig.messages}
>
<App />
</IntlProvider>, document.getElementById('root'));
/* react-intl imports */
import { IntlProvider } from 'react-intl';
/* Define your translations */
let i18nConfig = {
locale: 'el',
messages: {
"home.welcome": "Καλώς 'Ηρθατε στο {name}!",
"home.declarative": "Δηλωτικό"
}
.Home {
text-align: center;
}
.Home-logo {
height: 40vmin;
}
.Home-header {
background-color: #282c34;
@theodesp
theodesp / Home.js
Last active November 14, 2019 12:06
import React, {Component} from 'react';
import logo from './logo.svg'
import './Home.css';
class Home extends Component {
render() {
return (
<div className="Home">
<div className="Home-header">
<img src={logo} className="Home-logo" alt="logo"/>
@theodesp
theodesp / app.js
Last active November 14, 2019 12:04
import React from 'react';
import {Switch, Route, HashRouter as Router} from 'react-router-dom';
import Home from "./Home";
import './App.css';
const App = () => (
<Router>
<Switch>
<Route exact path="/" component={Home} />
@theodesp
theodesp / binSearch.js
Last active September 24, 2019 19:25
binary search #javascript #search
/**
* Binary search element
* from a flat array of integers.
*
* @param {array} arr The array. Needs to be sorted.
* @param {int} n The element to search.
* @returns {int} Index of the element found in array
*/
function binSearch(arr, n) {
let i = 0;
@theodesp
theodesp / addBinary.go
Last active September 17, 2019 15:29
Add 2 Binary Strings #go
/*
Observation: We start from the last char for each string. As long as we have not reached the beginning we compare the chars. The math is
1 + 1 = 0 (curry = 1)
1 + 0 = 0 + 1 = 1 (curry = 0)
1 + 1 = 1 (curry = 1) if curry = 1
1 + 0 = 0 + 1 = 0 (curry = 1) if curry = 1
If we have a curry in the end we prepend the 1
@theodesp
theodesp / anagrams.go
Last active September 17, 2019 14:31
Check if 2 strings are anagrams #go
/*
To find if 2 strings are anagrams we simply put each letter of first into a frequency table. Then for each other letter of b we subtract that count.
At the end we have a frequency table that all the values are 0.
*/
func Anagrams(a string, b string) bool {
count := int32(0)
frequencies := make(map[rune]int32)
for _, val := range a {
frequencies[val] = frequencies[val] + 1