Skip to content

Instantly share code, notes, and snippets.

@atafs
atafs / index.html
Last active February 24, 2018 02:04
OCaml script
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<!--<link rel="stylesheet" href="styles.css">-->
</head>
<body>
<h1>Hello world!</h1>
<!--<script src="script.js"></script>-->
@atafs
atafs / git-advanced-beyond-the-basics
Last active March 8, 2018 20:41
Git Basic and Advanced commands and Setup
# show the history -------------------------------------------------------------------
git hist
# check differences between 2 commits
git difftool <id> HEAD
# modify a file
mate README.md
git diff
@atafs
atafs / git-start-proj-demo.sh
Last active March 8, 2018 14:16
Demo of how to start a git repository/project
#!/bin/bash
# create a new project
cd ~; mkdir Repo; cd Repo
# create a new git repository
## git init .
git init DemoProj
mate README.md
@atafs
atafs / Botton.js
Last active February 24, 2018 01:06
react-native-albums-reusableComponents
const Button = ({ onPress, children }) => {
const { buttonStyle, textStyle } = styles;
return (
<TouchableOpacity onPress={onPress} style={buttonStyle}>
<Text style={textStyle}>
{children}
</Text>
</TouchableOpacity>
);
@atafs
atafs / AlbumDetail.js
Created February 24, 2018 01:09
react-native-albums-classComponent
const AlbumDetail = ({ album }) => {
const { title, artist, thumbnail_image, image, url } = album;
const {
thumbnailStyle,
headerContentStyle,
thumbnailContainerStyle,
headerTextStyle,
imageStyle
} = styles;
#!/bin/bash
# add remote connection called origin (default name)
git remote add origin git@github.com:atafs/fed-bed-git-version-control.git
# check
git remote
git remote -v
# change existing remote connection (eg from https to ssh)
@atafs
atafs / vagrant-provisioning-on-premise-demo01-create-vm.sh
Last active March 8, 2018 14:16
DevOps provisioning with vagrant to build virtual machines for testing code
#!/bin/bash
# install wget, virtualbox and vagrant
brew install wget
# enable in mac preferences to run oracle vm: https://developer.apple.com/library/content/technotes/tn2459/_index.html
brew cask install --force virtualbox
brew cask install vagrant
brew cask install vagrant-manager
# get a fresh Ubuntu 14.04 machine running and create a Vagrantfile
@atafs
atafs / js-redux-playground.js
Last active March 23, 2018 16:27
Redux way of managing state of the app (store)
// open the dev environment
// https://stephengrider.github.io/JSPlaygrounds/
// create reducer (function)
const reducer = (state = [], action) => {
if (action.type === 'SPLIT_STRING') {
return action.payload.split('');
} else if (action.type === 'ADD_CARACTER') {
// DO NOT MUTATE DATA IN A REDUCER
//state.push(action.payload);
@atafs
atafs / jestdescr.js
Last active March 27, 2018 19:31
JS WebStorm IDE snippets: code to use as alias for more productivity
// jestdescr
// Inserts describe() block
describe('$NAME$', function() {
$END$
});
@atafs
atafs / generator-start.js
Last active May 20, 2018 07:07
Redux Saga
// create a generator function
let generator = function*() {
return 5
}
let obj = generator()
obj.generator().next()
// iterate throught it
generator = function*() {
yield 1;