Skip to content

Instantly share code, notes, and snippets.

View dukuo's full-sized avatar
🎯
Focusing

Dilip dukuo

🎯
Focusing
View GitHub Profile
@zentralwerkstatt
zentralwerkstatt / instructions.md
Last active July 5, 2021 18:58
SSH into Linux Subsystem for Windows
  • In /etc/ssh/sshd_conf, set UsePrivilegeSeparation to no
  • In /etc/ssh/sshd_conf, temporarily enable plaintext passwords
  • In /etc/ssh/sshd_conf, change port (e.g. to 23) to avoid confusion with Windows SSH server
  • sudo service ssh restart
  • Add alternative port as a new rule to Windows firewall
  • On the client: ssh-copy-id user@server
  • In /etc/ssh/sshd_conf, re-disable plaintext passwords

To fix Could not load host key ... error:

  • sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
function InsertionSort(arr) {
let len = arr.length, // number of items in the array
value, // the value currently being compared
i, // index into unsorted section
j; // index into sorted section
for(i = 1; i < len; i++) {
// store the current value because it may shift later
// Find a "pivot" element in the array to compare all other
// elements against and then shift elements before or after
// pivot depending on their values
function QuickSort(arr, left = 0, right = arr.length - 1) {
let len = arr.length,
index
if(len > 1) {
index = partition(arr, left, right)
function MergeSort(arr) {
let len = arr.length, // number of items in the array
middle, // middle of the array
left, // left side of the array
right, // right side of the array
// Arrays with 0 or 1 elements don't need sorting
if (len < 2) {
return arr
@ljharb
ljharb / array_iteration_thoughts.md
Last active April 15, 2025 03:33
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

Unit testing react with Jest


What is a unit test?

  • When given some input, does the output look like x?
  • Runs quickly
@MaruscaGabriel
MaruscaGabriel / functions.php
Last active November 5, 2021 01:40
WordPress (DIVI) code snippets
<?php
// Limit the number of revisions to 3
add_filter( 'wp_revisions_to_keep', 'divi_limit_revisions', 10, 2 );
function divi_limit_revisions( $num ) {
$num = 3;
return $num;
}
//Disable Emoji
@enghqii
enghqii / Program.cs
Created August 29, 2016 18:15
C# Coroutine example
using System;
using System.Collections;
using System.Collections.Generic;
namespace Generator3
{
class Program
{
// classic Generator
static IEnumerable<string> Script()
@juhaelee
juhaelee / react-typescript.md
Last active May 28, 2024 17:41
React + Typescript Cheatsheet

React + Typescript Cheatsheet

Setup

If you use atom... download & install the following packages:

What are Typescript type definition files? (*.d.ts)

@bsergean
bsergean / README.md
Last active January 23, 2024 17:50
Anti-aliasing (FXAA) with headless-gl and three.js

Aliased

Anti-aliased

Getting the code