Skip to content

Instantly share code, notes, and snippets.

View artturijalli's full-sized avatar

Artturi Jalli artturijalli

View GitHub Profile
@artturijalli
artturijalli / example.js
Created March 10, 2021 07:09
An example javascript gist
while(1 < 2){
console.log("This is just an example.");
}
@artturijalli
artturijalli / dismissKeyboard.swift
Created March 19, 2021 16:12
Extensions for dismissing keyboard in SwiftUI by tapping outside the text field
extension UIApplication {
func handleKeyboard() {
guard let window = windows.first else { return }
let tapRecognizer = UITapGestureRecognizer(target: window, action: #selector(UIView.endEditing))
tapRecognizer.cancelsTouchesInView = false
tapRecognizer.delegate = self
window.addGestureRecognizer(tapRecognizer)
}
}
@artturijalli
artturijalli / functions.go
Last active March 20, 2021 09:52
A simple example of using functions in Go.
package main
import "fmt"
// FUNCTIONS
// specify the argument type(s) and the possible return value type
func sum(x int, y int) int {
return x + y
}
@artturijalli
artturijalli / example.go
Last active March 20, 2021 09:52
Basics of Go language.
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
// Creating variables
var x1 int = 5
@artturijalli
artturijalli / pointer.go
Created March 20, 2021 09:47
An example of using pointers in Go.
package main
import "fmt"
func main() {
// POINTERS
i := 7
package main
import "fmt"
// STRUCTURES - a collection of fields to construct a logical type
type Fruit struct {
name string
color string
}
{
"Name": "Charlie",
"Street address": "Student Street 32",
"Graduated": false,
"Allergies": ["Banana", "Apple", "Nuts"],
"Grades": {
"Physics": 4,
"Maths": 4,
"Chemistry": 5
}
[
{
"Name": "Charlie",
"Street address": "Student Street 32",
"Graduated": false,
"Allergies": ["Banana", "Apple", "Nuts"],
"Grades": {
"Physics": 4,
"Maths": 4,
"Chemistry": 5
const students_data = [
{
"Name": "Charlie",
"Street address": "Student Street 32",
"Graduated": false,
"Allergies": ["Banana", "Apple", "Nuts"],
"Grades": {
"Physics": 4,
"Maths": 4,
"Chemistry": 5
@artturijalli
artturijalli / generator_example.py
Created April 21, 2021 09:00
A simple generator in Python
def square_even(numbers):
for number in numbers:
if number % 2 == 0:
yield(number * number)
numbers = [1, 2, 3, 4, 5, 6]
squared_numbers = square_even(numbers)
for number in squared_numbers:
print(number)