Skip to content

Instantly share code, notes, and snippets.

@jacky810124
jacky810124 / sum.js
Created May 20, 2022 18:10
Currying function
const sum = (...args) => {
let result = 0;
if (!args.length) {
return result;
}
return (...a) => {
result = args.reduce((accumulator, item) => accumulator + item, result);
if (!a.length) {
return result;
}
@jacky810124
jacky810124 / tic-tac-toe-all-blocks.js
Created April 29, 2022 21:56
Tic-tac-toe scan all blocks solution
var getWinners = (blocks, amount) => {
for (let i = 0; i < amount; i++) {
const rowBlocks = [];
const columnBlocks = [];
const slashBlocks = [];
const backSlashBlocks = [];
for (let j = 0; j < amount; j++) {
rowBlocks.push(blocks[i * amount + j]);
columnBlocks.push(blocks[j * amount + i]);
backSlashBlocks.push(blocks[j * amount + j]);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>JS Bin</title>
<style>
.progress-bar-wrapper {
position: relative;
background-color: #c8c8c8;
const shuffle = list => {
const shuffledList = [...list];
for (
let currentIndex = shuffledList.length - 1;
currentIndex > 0;
currentIndex--
) {
const nextIndex = Math.floor(Math.random() * (currentIndex + 1));
const nextItem = shuffledList[nextIndex];
@jacky810124
jacky810124 / dark.md
Created October 29, 2018 10:11 — forked from a7madgamal/dark.md
Dark mode for Slack on MacOS
  1. Close slack
  2. Open this file /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
  3. Append this to it
document.addEventListener('DOMContentLoaded', function() {
 $.ajax({
   url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
   success: function(css) {
 $("").appendTo('head').html(css);
import styles from './styles.scss'
class SomeComponent extends React.Component {
render () {
return (
<div className={styles['some-component']}>
SomeComponent
</div>
)
}
import React from 'react'
import style from './styles.scss'
class NumericKeyboard extends React.Component {
constructor (props) {
super(props)
this.state = {
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Document</title>
</head>
<body>
</body>
const days = [
'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'
]
const data = {
'mon': [
{
start: '11:00',
end: '22:00'
}
],
@jacky810124
jacky810124 / app.js
Created March 29, 2018 07:55
PWA Day06 - cache matchAll
caches
.open('example-cache')
.then(function(cache) {
cache
.matchAll('/images/')
.then(function(response) {
response.forEach(function(element, index, array) {
cache.delete(element)
})
})