Skip to content

Instantly share code, notes, and snippets.

View GeoDoo's full-sized avatar
🏠
Working from home

Georgios Karametas GeoDoo

🏠
Working from home
View GitHub Profile
@GeoDoo
GeoDoo / copy_ssh_key
Created September 17, 2020 14:18
Copy ssh key
#!/bin/bash
pbcopy < ~/.ssh/id_rsa.pub
@GeoDoo
GeoDoo / App.js
Last active December 13, 2018 16:31
Component with async componentDidMount
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 June 30, 2017 13:27
Flatten multidimensional arrays
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 {
function average(numbers) {
return sum(numbers) / numbers.length;
}
function sum(numbers) {
return numbers.reduce(function(a, b) {
const webpack = require('webpack');
const myEnv = require('dotenv').config();
...................................
},
plugins: [
new webpack.DefinePlugin({
API_KEY: JSON.stringify(myEnv.parsed.API_KEY),
}),
],
API_KEY=asdapsasdDAS#$234@#$ASLC()#(%OAIC)_VPOI)@POVIPDOIFOVA
@GeoDoo
GeoDoo / prototype_chains.js
Last active March 5, 2017 17:17
Prototype chains
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 January 6, 2017 21:30
React hello world native
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 January 6, 2017 21:29
React simpleness
import React, { Component } from 'react'
class HelloWorld extends Component {
render() {
return (
<div>
Hello World!
</div>
)
}