Skip to content

Instantly share code, notes, and snippets.

View ahojukka5's full-sized avatar

Jukka Aho ahojukka5

View GitHub Profile
@ahojukka5
ahojukka5 / AHO_Elem1HT2T2.py
Created December 15, 2011 06:05
Ristikkorakenteen ratkaisu elementtimenenetelmällä
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 19 12:17:23 2011
@author: Jukka
Elementtimenetelmät 1, syksy 2011
Harjoitustehtävät 2, tehtävä 2
"""
@ahojukka5
ahojukka5 / AHO_Elem1HT2T3.py
Created December 15, 2011 06:09
Palkkirakenteen ratkaisu elementtimenetelmällä
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 19 13:09:12 2011
@author: Jukka
Elementtimenetelmät 1, syksy 2011
Harjoitustehtävät 2, tehtävä 3
"""
@ahojukka5
ahojukka5 / create_lagrange_element.jl
Last active January 2, 2020 21:40
JuliaFEM snippets
"""
Create new Lagrange element
"""
function create_lagrange_element(element_name, X, P, dP)
nnodes, dim = size(X)
A = zeros(nnodes, nnodes)
for i=1:nnodes
A[i,:] = P(X[i,:])
end
@ahojukka5
ahojukka5 / contact_element_seg2.jl
Last active January 2, 2020 22:25
Contact element Seg2
using ForwardDiff, BenchmarkTools, Tensors, DiffResults, LinearAlgebra
using ForwardDiff: value
const quadrature_points = ((0.23692688505618908, -0.906179845938664),
(0.47862867049936647, -0.538469310105683),
(0.56888888888888890, 0.000000000000000),
(0.47862867049936647, 0.538469310105683),
(0.23692688505618908, 0.906179845938664))
function project_from_slave_to_master(::Type{Val{:Seg2}}, x1, n1, xm1, xm2)
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/PDEAssembler.jl/blob/master/LICENSE
using FEMBase, Base.Threads
struct Poisson <: FieldProblem end
FEMBase.get_unknown_field_name(::Problem{Poisson}) = "u"
function FEMBase.assemble_elements!(problem::Problem{Poisson},
@ahojukka5
ahojukka5 / Login.js
Created November 17, 2019 06:12
react-stateful-login
function StatefulLogin({ login }) {
const [showError, setShowError] = useState(false)
async function onLogin(username, password) {
try {
await login(username, password)
setShowError(false)
} catch (error) {
setShowError(true)
}
}
@ahojukka5
ahojukka5 / index.html
Last active January 2, 2020 21:39
hy-fullstack-2019-part-1-anecdotes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
@ahojukka5
ahojukka5 / hello.py
Last active January 2, 2020 22:17
Hello world from Python in VSCode + GistPad
import numpy as np
import matplotlib.pylab as plt
print("Hello, world!")
x = np.linspace(0, np.pi)
y = np.sin(x)
plt.plot(x, y)
@ahojukka5
ahojukka5 / hello.jl
Last active January 2, 2020 22:21
Hello world from Julia in VSCode + GistPad
println("Hello, world!")
@ahojukka5
ahojukka5 / composition.jl
Created January 3, 2020 06:18
Functional programming using Julia
‎‎​