Skip to content

Instantly share code, notes, and snippets.

View vicradon's full-sized avatar
🥑
creating technical content

Osinachi Chukwujama vicradon

🥑
creating technical content
View GitHub Profile
@vicradon
vicradon / paint.py
Created January 27, 2019 09:26
A simple event driven paint program which is part of the turtledemo in python
from turtle import *
def switchupdown(x = 0, y = 0):
'this defines how the pen responds to mouse input'
if pen()["pendown"]:
end_fill()
up()
else:
down()
begin_fill()
from turtle import *
speed(0), ht()
diff, a = 0.6, 45
def tree(d, n):
'this function uses recursion to draw'
if n > 1:
fd(d)
from turtle import *
def drawSquare(side):
for i in range(4):
fd(side)
lt(90)
tracer(0)
pu(), goto(-300, 0), pd()
ht(), width(5)
@vicradon
vicradon / The events in PWAs.md
Last active July 11, 2019 08:52
Events in PWAs. The install and fectch events

About

This app is an implementation of a PWA example from github. It will teach the basics of PWAs and the right ways to build, I guess.

Things to try out

  1. Put the css in a custom css folder
  2. Add a manu and some other pages

Caching Assets

This is done in the install event listener.

  • The code is put in a callback
@vicradon
vicradon / data.json
Last active September 9, 2019 03:01
{
"name":"Think Bits",
"size":6,
"developers":["python", "web", "c++"],
"people":["Godson", "Kingsley", "Ralph", "Samuel", "Samson", "Boniface"],
"sameLevel":true,
"structure":"https://i.ibb.co/bKQtjM3/object-structure.jpg"
}
@vicradon
vicradon / App.js
Last active October 21, 2019 15:41
A simple example of React Forms
// The main info to grab here is that the function which handles event.target can be placed
//on multiple elements. The props of that element get combined into an object which can
//be accessed form event.target. Remember how NetNinja accessed inputs of a form using '[]'?
//The same logic is applied here. The name is accessed using [] and the value, the normal way
//The name must reflect the property in state. because name is carried from the JSX element and
//sent to the state for investigation
import React from "react"
class App extends React.Component {
@vicradon
vicradon / App.js
Created October 22, 2019 16:13
A simple example of useEffect
import React, {useState, useEffect} from "react"
import randomcolor from "randomcolor"
function App() {
const [count, setCount] = useState(0)
const [color, changeColor] = useState(randomcolor)
useEffect(() => {
const intervalId = setInterval(() =>
setCount(prevCount => prevCount + 1), 1000
@vicradon
vicradon / stuff.json
Created December 14, 2019 10:45
A post
{
"title":"A post",
"content":"Some more post"
}
/**
* This code uses the principle of single return per function.
* I did not reassign any object.
* This enables a cleaner experience and a testable code.
*
* Also note that I did not use "let" or "var (which is forbidden)".
* I only used const, to prevent reassignment errors.
*/
const data = [
@vicradon
vicradon / a.dart
Last active April 17, 2020 07:12
The code snippets for the shopping cart app
import 'package:flutter/material.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: '/',
routes: {