Skip to content

Instantly share code, notes, and snippets.

View tlylt's full-sized avatar
🐱
On vacation

Liu Yongliang tlylt

🐱
On vacation
View GitHub Profile
@tlylt
tlylt / site.json.test.js
Created March 1, 2022 06:08
e2e test case for MarkBind
const fs = require('fs');
const _ = {};
_.cloneDeep = require('lodash/cloneDeep');
describe('Live Preview reload triggered by changes to site.json', () => {
const SITE_JSON_PATH = 'test/e2e/test_site/site.json';
const originalJson = JSON.parse(fs.readFileSync(SITE_JSON_PATH, 'utf8'));
beforeAll(async () => {
await page.goto('http://localhost:8888/');
@tlylt
tlylt / add-all-contributors.py
Created January 10, 2022 15:57
Automatically add all existing GitHub repo contributors with all-contributors-cli
import subprocess
import shlex
import sys
def init():
print("Initialize all-contributors")
subprocess.run(shlex.split("npx all-contributors-cli init"), shell=True)

Responsive Ferris Wheel - CSS Only animation

CSS keyframe Ferris-wheel animation. Easy to adjust speed and responsive.

A Pen by Jimba Tamang on CodePen.

License.

@tlylt
tlylt / gist:8c55589cec793bb4104f990ec5328f07
Created May 21, 2021 05:45
Cypress upload excel file
it('uploads a file', () => {
cy.fixture('sample.xlsx','binary').as('sample')
cy.get('input[type="file"]').then(function (el) {
const blob = Cypress.Blob.binaryStringToBlob(this.sample)
const file = new File([blob], 'sample.xlsx', { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' })
const list = new DataTransfer()
list.items.add(file)
const myFileList = list.files
el[0].files = myFileList
el[0].dispatchEvent(new Event('change', { bubbles: true }))
@tlylt
tlylt / .manifest
Created March 16, 2021 10:58 — forked from devjin0617/.manifest
chrome extension using a content script to access the `window` object
{
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["inject.js"],
"all_frames": true
}
],
"web_accessible_resources": [
"content.js"
@tlylt
tlylt / compareDouble.java
Created September 25, 2020 08:45
Compare two double in Java
boolean closeEnough(double a, double b) {
double tolerance = 1E-4;
return Math.abs(a-b) < tolerance;
}
@tlylt
tlylt / test6.jsh
Last active September 7, 2020 03:44
Lab 2 Level 6 test file
/open Cruise.java
/open SmallCruise.java
/open BigCruise.java
/open Loader.java
/open RecycledLoader.java
/open level6.jsh
Cruise[] cruises = {
new BigCruise("B1111", 0, 60, 1500),
new SmallCruise("S1112", 0),
new BigCruise("B1113",30, 100,1500),
https://docs.djangoproject.com/en/3.0/intro/reusable-apps/
def combinations(lst,n):
if n == 1: # every item is a combination
return list(map(lambda x: [x], lst))
elif len(lst) == n: # there is only one combination
return [list(lst)]
else:
first = lst[0]
rest = lst[1:]
# similar to coin change, either include or not include the first item
# if include the first item, add first to the combinations of the rest items that form n-1 combi
# How to solve install issue of WSL in Windows 10
Rename Ubuntu.1604.2017.711.0_v1.appx to Ubuntu.1604.2017.711.0_v1.zip and extract all in to a folder.
Run Ubuntu.exe inside the extracted folder.