cat << EOF > /somefile
These contents will go into file.
EOF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.usmans.blog.vertx | |
import org.eclipse.jgit.api.Git | |
import org.eclipse.jgit.revwalk.RevCommit | |
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider | |
import java.io.File | |
internal const val GIST_REPO_URL = "https://gist.github.com/someid.git" | |
fun gitCredentialProvider(gistToken: String = System.getenv("GITHUB_GIST_TOKEN")) = UsernamePasswordCredentialsProvider(gistToken, "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blogApp.directive('gistDirective', function() { | |
return function(scope, element, attrs) { | |
scope.$watch('blogItem', function(){ | |
angular.element('[data-gist-id]').gist(); | |
}); | |
} | |
}); | |
//then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ { | |
"id" : 186, | |
"urlFriendlyId" : "tcp_client_using_vertx_kotlin_gradle", | |
"title" : "TCP Client using Vertx, Kotlin and Gradle build", | |
"description" : "Step by Step guide to create simple TCP client using Vertx, Kotlin and Gradle", | |
"body" : "<p>As part of my hobby project to control RaspberryPi using Google Home Mini and/or Alexa, I wanted to write a very simple TCP client that keeps a connection open to one of my custom written server in cloud (I will write another blog post to cover the server side on a later date). The requirement of the client is to send a shared secret upon connecting and then keep waiting for message from server. Vert.x, Kotlin and Gradle allow rapid development of such project. The generated jar can be executed on Raspberry Pi. These steps outline the project setup and related source code to showcase a Vert.x and Kotlin project with Gradle.</p>\n<h2>Project Directory Structure</h2>\n<p>From command line (or via Windows Explorer, whatever you prefer to use) create a directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
environment: | |
SERVER_NAME: "myserver.doma.in" | |
# Dummy key, cert | |
SSL_KEY: |- | |
-----BEGIN RSA PRIVATE KEY----- | |
MIICXQIBAAKBgQD272jYrLm8Ph5QpMWFcWUO9Ua1EviykalP+tkMIg12yZ3GvezF | |
y8aayxdztB5vu68jqMeg6mOJlscWqFUhmAxj4mDknYenVzVX2CKzCgHlGninTKxY | |
61rXDaDZVpSZ+XIESJkaB0z9HHYtrSLr0coKmq4cT5TRptOnkpDlJxIRaQIDAQAB | |
AoGATcTYoGTFmiN2KK+8BWrRCQT2X9C5woNdb3LxKIEQ/HhC2HS4PRMQWW/c0vPH | |
IilZ30EoneUztAFochpRtWLNg4lJoLy04X/eNjEiC/imp0KSwWXmnuLhDcWcb0+M |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
all = "!sh -c \"find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} $1 \\;\" -" |
Goal
In Progress
Use Raspberry PI 2 as a PP2P VPN gateway so that devices on the network can be configure to use PI as gateway which should direct the internet traffic through VPN.
Setup
- Modify main router to issue DHCP address so that PI can be assigned an IP address outside the range.
- Connect PI using ethernet cable. WIFI may also be used, however, following instructions assume eth.
- Setup PI with static IP address. Modify
/etc/dhcpcd.conf
with following contents (192.168.1.2 is PI ip address, 192.168.1.1 is the WAN router IP address):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from "@angular/core"; | |
import {Http, Headers, RequestOptionsArgs, Response, RequestMethod, RequestOptions, Request} from "@angular/http"; | |
import {LoginService} from "../login/login.service"; | |
import {Observable} from "rxjs"; | |
/** | |
* JwtHttpClient is a wrapper over Angular Http. It appends JWT header for authentication. | |
*/ | |
@Injectable() | |
export class JwtHttpClient { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from "@angular/core"; | |
import {Http, Headers, Response} from "@angular/http"; | |
import {Observable} from "rxjs"; | |
import "rxjs/add/operator/map"; | |
/** | |
* Login Service to obtain access_token and refresh_token. | |
*/ | |
@Injectable() | |
export class LoginService { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Router, CanActivate } from '@angular/router'; | |
import {LoginService} from "./login/login.service"; | |
@Injectable() | |
export class AuthGuard implements CanActivate { | |
constructor(private router: Router, | |
private loginService: LoginService) { } |