Skip to content

Instantly share code, notes, and snippets.

Avatar

Chung Yen Li mofas

View GitHub Profile
View main.css
.root___1Rh2d {
padding: .5rem 1rem .5625rem;
border: none;
color: #fff;
font-size: larger;
cursor: pointer;
border-radius: 1.25rem;
border: 2px solid #900
}
@mofas
mofas / a.js
Last active Mar 8, 2020
Search Google
View a.js
async function queryGoogle(target) {
const page = await browser.newPage();
await page.goto('https://google.com');
await page.keyboard.type(target + " MSA")
await page.keyboard.press("Enter")
await page.waitForNavigation();
await page.content()
const title = await page.evaluate(() => {
let elements = document.querySelectorAll('h3');
return elements[0].textContent;
@mofas
mofas / limitCoint.py
Last active Sep 2, 2019
Coin changes
View limitCoint.py
dfs (remainCoins, target):
if target === 0:
# calculate what coins you used here
usedCoin = ...
results.append(usedCoin)
return
if target < 0:
return
for coin in remainCoins:
@mofas
mofas / min-char-rnn.py
Created Mar 7, 2019 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
View min-char-rnn.py
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
View main.py
import sys
import numpy as np
from scipy.cluster.hierarchy import dendrogram, linkage
import matplotlib.pyplot as plt
def minidistance(S1, S2) :
N = len(S1)
M = len(S2)
matrix = np.zeros((N + 1, M + 1), dtype=int) #Build an alignment matrix
matrix[0][0] = 0
@mofas
mofas / main.py
Created Feb 4, 2019
sarbina cute cute
View main.py
from scipy import fftpack
import imageio
import numpy
# load in an image, convert to grayscale if needed
image = imageio.imread('ft/input.png', as_gray=True)
# take the fourier transform of the image
fft2 = fftpack.fftshift(fftpack.fft2(image))
View main.py
def get_next_status_set(status):
ret = []
status_len = len(status)
for i in range(status_len - 1):
if status[i] == '1' and status[i + 1] == '0':
new = status[:]
new[i] = '0'
new[i + 1] = '1'
ret.append(''.join(new))
# handl the last case
View 965.py
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def isUnivalTree(self, root):
"""
:type root: TreeNode
@mofas
mofas / iter_rec_diff.py
Created Nov 22, 2018
Explain the iteration and recursion for beginner
View iter_rec_diff.py
def fact1(n):
acc = 1
for i in range(n):
# print(acc, i + 1)
acc *= (i + 1)
return acc
View seq_per.py
seq = ['A', 'B', 'C']
current = []
next = []
for char in seq:
for c in current:
next.append(c + char)
next.append(char + c)
next.append(char)
current = current + next
You can’t perform that action at this time.