Skip to content

Instantly share code, notes, and snippets.

View tedhagos's full-sized avatar

Ted Hagos tedhagos

View GitHub Profile
@tedhagos
tedhagos / exer2.py
Created May 23, 2018 05:41
Solutions for Exer 2 and Exer 3 - Python TOP Training
# ask the user for input
# find the divisors of that number
def imperative_solution(end):
numrange = range(1, num + 1)
divisors = []
for i in numrange:
if num % i == 0:
divisors.append(i)
@tedhagos
tedhagos / pythontop-exer1-solution-1.py
Created May 17, 2018 06:13
Solution(s) to Python TOP Exer1
#!/usr/bin/python
import sys
# Description of the problem is
# found at http://bit.ly/python-top-exer1
def sum_to(end):
num_list = range(1, int(end))
sum = 0
@tedhagos
tedhagos / MainActivity.java
Created May 5, 2018 14:04
MainActivity.java for Listing 5-19 of Learning Android Studio 3 (Ted Hagos)
package com.example.ted.eventhandling_innerclass_as_listener;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@tedhagos
tedhagos / 1.html
Created November 28, 2017 02:30
Angular Directives Controllers Modules
<html ng-app="app">
<body ng-controller="ctrl">
<my-directive></my-directive>
<author-card></author-card>
<input type="text" ng-model="myinput"><br/>
<button ng-click="clickMe(myinput)"> Click me</button>
{{ greeting }}
@tedhagos
tedhagos / gcf.html
Created November 27, 2017 04:38
GCF Solution
<html ng-app>
<body ng-controller="ctrl">
<div id="disp">
<input type="number" placeholder="type a number" ng-model="fno"/><br/>
<input type="number" placeholder="type a number" ng-model="sno"/><br/>
<button ng-click="calculate()">Calculate</button>
<div id = "out">
{{ gcf }}
</div>
@tedhagos
tedhagos / filter.js
Created November 24, 2017 00:53
Filter examples
let app = angular.module('app', []);
app.controller('ctrl', ($scope) => {
$scope.numbers = [0,1,2,3,4,5,6,7,8,9,10];
$scope.names = [
{name: 'James Gosling', likes: 2 },
{name: 'Misko Hevery', likes: 3 },
{name: 'Ryan Dahl', likes: 4 },
@tedhagos
tedhagos / README.txt
Created November 23, 2017 02:11
Various endpoints for ExpressJS server
place these snippets before the line "app.listen(. . .)"
@tedhagos
tedhagos / 8-service.js
Created November 23, 2017 01:48
ngService
const myservice = ($http) => {
let github = () => {
return $http.get('https://api.github.com/users/angular')
.then((data) => {
return data.data;
})
}
return {
xgithub: github
}
@tedhagos
tedhagos / 1-directives.html
Created November 23, 2017 01:45
Directives
<html ng-app="app">
<body ng-controller='ctrl'>
{{ count }}
{{ user.name }}
<button ng-click="increase()">+</button>
<div my-directive></div>
</body>
<script src="bower_components/angular/angular.js"></script>
<script src="1.js"></script>
@tedhagos
tedhagos / README.txt
Created November 23, 2017 00:07
express route for searching one author
Place this code in server.js. Right before "app.listen(port)"
///
app.get('/author/:lastname', (req,res) => {
let name = req.params.lastname;
Author.findOne({'lastname': {'$regex': name,$options: 'i' }}).lean().exec((err,data)=> {
if(err) {
res.send(err);
}