Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Georgios Karametas GeoDoo

🏠
Working from home
View GitHub Profile
View copy_ssh_key
#!/bin/bash
pbcopy < ~/.ssh/id_rsa.pub
@GeoDoo
GeoDoo / App.js
Last active Dec 13, 2018
Component with async componentDidMount
View App.js
import React, { Component } from "react";
import axios from "axios";
import "./App.css";
class App extends Component {
constructor(props) {
super(props);
this.state = {
posts: [],
error: ""
@GeoDoo
GeoDoo / flatten.js
Last active Jun 30, 2017
Flatten multidimensional arrays
View flatten.js
function flatten(arr) {
return arr.reduce(function (flat, toFlatten) {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
function assertFlattenEquals(actual, expected, testName) {
if (JSON.stringify(actual) === JSON.stringify(expected)) {
console.log('\'' + testName + '\' test passed!');
} else {
View unit_testing.js
function average(numbers) {
return sum(numbers) / numbers.length;
}
function sum(numbers) {
return numbers.reduce(function(a, b) {
View webpack.config.js
const webpack = require('webpack');
const myEnv = require('dotenv').config();
...................................
},
plugins: [
new webpack.DefinePlugin({
API_KEY: JSON.stringify(myEnv.parsed.API_KEY),
}),
],
View .env
API_KEY=asdapsasdDAS#$234@#$ASLC()#(%OAIC)_VPOI)@POVIPDOIFOVA
@GeoDoo
GeoDoo / prototype_chains.js
Last active Mar 5, 2017
Prototype chains
View prototype_chains.js
var obj = {
prop: 1
};
console.log(obj.prop); // logs 1
console.log(obj.prop2); // logs undefined
// If you want to delegate failed lookups to the prototype
// you use this technique
var obj2 = Object.create(obj); // this way the newly created object has access to the obj properties!!!
@GeoDoo
GeoDoo / helloWorldNative.js
Last active Jan 6, 2017
React hello world native
View helloWorldNative.js
import React, { Component } from 'react'
import { Text, View } from 'react-native'
class HelloWorld extends Component {
render() {
return (
<View>
<Text>
Hello World!
</Text>
@GeoDoo
GeoDoo / helloWorld.js
Last active Jan 6, 2017
React simpleness
View helloWorld.js
import React, { Component } from 'react'
class HelloWorld extends Component {
render() {
return (
<div>
Hello World!
</div>
)
}