Skip to content

Instantly share code, notes, and snippets.

View tedhagos's full-sized avatar

Ted Hagos tedhagos

View GitHub Profile
@tedhagos
tedhagos / VSimpleCamera.java
Created April 26, 2016 00:19
Simple Camera Code for Android
package com.thelogbox;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.content.Context;
import android.widget.LinearLayout;
import android.hardware.Camera;
import android.hardware.Camera.ShutterCallback;
@tedhagos
tedhagos / virtualbox-vagrant-nuclear-option.sh
Created March 23, 2021 08:31 — forked from tjbenton/virtualbox-vagrant-nuclear-option.sh
Completely uninstall VirtualBox and Vagrant and reinstall through brew
# update brew because `brew update` is broken after updating to El Capitan
cd `brew --prefix`
git fetch origin
git reset --hard origin/master
sudo shutdown -r now # restart the computer
# open terminal and run the following
brew update
brew cleanup
@tedhagos
tedhagos / README.md
Created December 6, 2019 09:36
Sample node server app for Angular training

Installation

On the same folder where you will download 'app.js', do these things

npm init -y
npm install --save express cors
npm install -g nodemon
@tedhagos
tedhagos / README.md
Created December 19, 2018 01:13
Angular Routing
  1. Create an angular project, when asked for Angular routing support, say "YES"
  2. Create routes in app.module.ts
  3. Write the [routerLinks] in app.component.html
  4. Writer the in app.component.html
  5. Make sure there is a line in the head section of app.component.html
@tedhagos
tedhagos / README.md
Created December 18, 2018 03:37
http observable sample
  1. On the root module (app.module.ts)

    • import the HttpClientModule
    • put it in the imports section
  2. On the app.service.ts

    • import the HttpClient from @angular/common/http
    • Inject it in the constructor of the service
  3. In angular.json

  • Under architect > build > options > assets, add "src/api"
@tedhagos
tedhagos / app.component.html
Created December 18, 2018 03:32
observable sample
<h1>{{ title }}</h1>
<button (click)="subscribe()">
Subscribe
</button>
@tedhagos
tedhagos / README
Last active December 18, 2018 01:50
book sample with parent and child component
To create the project
ng new parentchild
ng g c childone
cd parentchild
npm install --save bootstrap
@tedhagos
tedhagos / app.component.html
Last active December 17, 2018 02:07
Guessing game exercise in Angular
<h1>{{ title }}</h1>
<strong>Can you guess a number betwee 1 to 100?</strong>
<p>
<input placeholder="type an integer" [(ngModel)]="guess">
</p>
<button (click)="guessTheNumber()">
Guess the number
</button>
<p></p>
@tedhagos
tedhagos / UseOfWhenInAndroid.kt
Created September 28, 2018 14:58
Using when in an Android app
class MainActivity : AppCompatActivity() {
val Log = Logger.getLogger(MainActivity::class.java.name)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
Log.info("onCreateOptionsMenu")
@tedhagos
tedhagos / TypeErasure.kt
Created September 28, 2018 08:28
TypeErasure.Kt
// Warning, this code won't compile in Kotlin
// it has problemss. Can you spot which line won't compile?
fun main(args: Array<String>) {
val mlist = listOf(Programmer("Ted"), Tester("Steph")) // (1)
val mprogs = mlist.typeOf<Programmer>() // (2)
mprogs.forEach { // (3)
println("${it.toString()} : ${it.javaClass.simpleName}")
}