This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import matplotlib.pyplot as plt | |
import random | |
def costJoint(normal: tuple[float, float], S3: tuple[float, float]): | |
return 1 - abs(normal[0]*S3[0] + normal[1]*S3[1]) | |
def costStylolite(normal: tuple[float, float], S3: tuple[float, float]): | |
return 1 - costJoint(normal, S3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import matplotlib.pyplot as plt | |
Stress = list[list[float], list[float]] | |
Vector = list[float] | |
Angle = float | |
def normalAndShear(S: Stress, theta: Angle) -> Vector: | |
a = math.radians(theta) | |
sxx = S[0][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Vector3 } from 'three' | |
import * as TWEEN from 'tween' | |
export type Callback = () => void | |
export function setView(position: Vector3, target: Vector3, duration = 0, callback: Callback = null) { | |
let endPosition = position.clone() | |
let endTarget = target.clone() | |
const startPosition = this.position.clone() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates | |
// See https://tc39wiki.calculist.org/es6/template-strings/ | |
// | |
function ttl(strings, ...rest) { | |
console.log(rest); | |
} | |
ttl `a${1}b${2}c${3}`; | |
ttl `a${1}b${2}c${3}d${4}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example function | |
export const fetchPackageInfo = async (pkgName: string, signal: AbortSignal): Promise<NpmPackage> => { | |
const response = await fetch(`https://registry.npmjs.org/${pkgName}`, { signal }) | |
if (response.status === 200) { | |
return response.json(); | |
} else { | |
throw response.text(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> | |
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> | |
<script src='https://kit.fontawesome.com/daa834e337.js' crossorigin="anonymous"></script> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<style> | |
html, | |
body { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simulate a 1 second computation | |
*/ | |
function computeFast() { | |
console.log("Init fast") | |
return new Promise(resolve => { | |
setTimeout(function() { | |
resolve(" Fast") | |
console.log(" End of fast") | |
}, 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type myFunction = (params: any) => void | |
/* eslint @typescript-eslint/no-explicit-any: off -- need to have any here for the factory */ | |
namespace Factory { | |
const map_: Map<string, myFunction> = new Map() | |
export const bind = (obj: myFunction, name: string = '') => { | |
name.length === 0 ? map_.set(obj.name, obj) : map_.set(name, obj) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint @typescript-eslint/no-explicit-any: off -- need to have any here for the factory */ | |
namespace Factory { | |
const map_: Map<string, any> = new Map() | |
export const bind = (obj: any, name: string = '') => { | |
name.length === 0 ? map_.set(obj.name, obj) : map_.set(name, obj) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -------------------------------------------------------- | |
const create = (Type: any, params: any) => new Type(params) | |
// -------------------------------------------------------- | |
// Example | |
class A { | |
private a = 0 | |
private b = 0 |
NewerOlder