Skip to content

Instantly share code, notes, and snippets.

View ultim8k's full-sized avatar
🛠️
Rock & roll!

Kostas Kapenekakis ultim8k

🛠️
Rock & roll!
View GitHub Profile
git reset --soft HEAD~1
@ultim8k
ultim8k / modules.js
Last active August 16, 2018 12:38
Modern JS kickstart
/**
* The module pattern
*/
const myObject = (function(){ // "const" is like "var" but cannot change
const myName = 'Kostas'; // This is private
const mySurname = 'Kapenekakis'; // This is private too
const sayFullName = function () {
alert(myName + ' ' + mySurname);
}

Bookmarklet: [🍪]("javascript:(function(){window.biscuit=(()=>({getCookie: cookieName => document.cookie.split(';').map(item=>item.split('=').map(name=>name.trim())).map(item=>({name: item[0], value: item[1]})).find(item => item.name === cookieName), setCookie: (cookieName, cookieValue) => document.cookie = ${cookieName}=${cookieValue} }))(); })();")

@ultim8k
ultim8k / README.md
Created July 31, 2018 10:36
Working with ssh keys

Working with ssh keys

Create an ssh key:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Start the ssh-agent in the background:

@ultim8k
ultim8k / README.md
Created July 31, 2018 10:22
Docker setup for node.js with nginx proxy

Docker setup for node.js with nginx proxy

File strcuture

_
|
|-- docker-compose.yml
|
|-- nginx
@ultim8k
ultim8k / get_pull_request_url.sh
Created July 30, 2018 14:04
Get url for pull request to current repo's remote origin
function get_pull_request_url () {
local GIT_BRANCH_NAME=$(git symbolic-ref --short HEAD);
local GIT_REMOTE_URL=$(git config --get remote.origin.url);
# [email protected]:USER_NAME/REPO_NAME.git
local GIT_FULL_REMOTE_NAME=$(echo $GIT_REMOTE_URL | sed -e 's/[email protected]://' -e 's/\.git//');
# https://github.com/ORG_NAME/REPO_NAME/compare/GIT_BRANCH_NAME?expand=1
echo "https://github.com/${GIT_FULL_REMOTE_NAME}/compare/${GIT_BRANCH_NAME}?expand=1"
}
@ultim8k
ultim8k / local-dev-setup.md
Last active June 28, 2018 10:53
Setting up local development environment for our app

Setting up local dev env for our app

Setting up the domain

Our domain is foobar.com so the one we want for local development is dev.foobar.com. We need to make sure that our browser will redirect all the requests to the local machine instead of asking a DNS.

sudo vim /etc/hosts
@ultim8k
ultim8k / dummy-router-post.md
Last active June 15, 2020 10:42
Dummy Router post

Hey, I made a dummy router with react and a couple Regular Expressions

Why?

Well, since the time I started playing with node.js and express I wondered how a router works under the hood. I even remember I once had a look on Backbone's router and didn't seem too hard to understand, but was wondering who is that crazy person who came up with this.

A couple days ago I wanted to build a simple markdown-notes list for fun using react. I started with a list of notes where you click one and navigate to the single note view. Ok, first I need to install React Router... Nah. That's boring. I'll just make a dummy router for now. How hard can it be? Let's see.

How?

@ultim8k
ultim8k / router.html
Created June 2, 2018 21:03 — forked from joakimbeng/router.html
A really simple Javascript router
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes: