Skip to content

Instantly share code, notes, and snippets.

View JustinSDK's full-sized avatar
👨‍👩‍👧
Working from home

Justin Lin JustinSDK

👨‍👩‍👧
Working from home
View GitHub Profile
@JustinSDK
JustinSDK / sin_square_wave.py
Last active May 17, 2021 03:06
弦波疊加
import numpy as np
import matplotlib.pyplot as plt
freq = 10 # 頻率
stop = .25 # 取樣範圍為 0 ~ stop
sample_rate = 800 # 取樣率,單位 x 取樣幾次
n = 1000 # 疊加的波數
x = np.linspace(0, stop, int(stop * sample_rate), endpoint = False)
i = np.arange(1, 2 * n, 2).reshape((n, 1))
@JustinSDK
JustinSDK / one_sin.py
Created May 17, 2021 02:43
NumPy 與 Matplotlib 畫正弦波
import numpy as np
import matplotlib.pyplot as plt
freq = 10 # 頻率
stop = .25 # 取樣範圍為 0 ~ stop
sample_rate = 800 # 取樣率,單位 x 取樣幾次
x = np.linspace(0, stop, int(stop * sample_rate), endpoint = False)
y = np.sin(freq * 2 * np.pi * x)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function array(lt) {
let unit = _ => _;
let no_use = unit;
let no = _ => f => f(no_use);
let when = unit;
let left = p => p(l => _ => l);
let right = p => p(_ => r => r);
@JustinSDK
JustinSDK / quine.py
Last active September 21, 2020 03:28
t = 't=\'\\n\nprint(t[0:3]+t[0:2]+t[3]+t[2]+t[3]*2+t[4]+t[3:5]+t[6:]+t[2]+t[5]+t[6:])'
print(t[0:3]+t[0:2]+t[3]+t[2]+t[3]*2+t[4]+t[3:5]+t[6:]+t[2]+t[5]+t[6:])
# r='r=%r;print(r%%r)';print(r%r)
@JustinSDK
JustinSDK / render_object_widget.dart
Last active June 16, 2020 13:10
RenderObjectWidget Demo
import 'package:flutter/material.dart';
void main() {
runApp(
RedSquare(
center: Offset(210, 300),
width: 100,
height: 200,
)
);
@JustinSDK
JustinSDK / render_object_widget.dart
Created June 16, 2020 08:23
RenderObjectWidget Demo
import 'package:flutter/material.dart';
void main() => runApp(
RedSquare(
center: Offset(210, 300),
width: 100,
height: 200,
)
);
@JustinSDK
JustinSDK / recursive_lambda.cpp
Created January 8, 2020 06:02
return recursive lambda
#include <iostream>
#include <functional>
using namespace std;
function<int(int)> foo() {
return [](int n) -> int {
function<int(int)> fac = [&](int n) -> int {
return n == 0 ? 1 : n * fac(n-1);
};
return fac(n);
@JustinSDK
JustinSDK / _instanceof.js
Created July 24, 2019 03:22
Babel 的 _instanceof
function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return !!right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
}
@JustinSDK
JustinSDK / es8-for-await.js
Created May 7, 2019 06:21
es8-for-await.js
// 透過非同步產生器函式
const vertex2 = {
x: 1,
y: 2,
z: 3,
[Symbol.asyncIterator]: async function* () {
for (let key in this) {
yield this[key];
}
}