Skip to content

Instantly share code, notes, and snippets.

@c-j-j
c-j-j / contentScript.js
Created February 24, 2021 16:57
Chrome extension: CLS Logger
console.log("MONITORING CLS")
let cls = 0;
new PerformanceObserver((entryList) => {
for (const entry of entryList.getEntries()) {
if (!entry.hadRecentInput) {
cls += entry.value;
console.log('Current CLS value:', cls, entry);
}
}
@c-j-j
c-j-j / counting-valleys.js
Created November 21, 2018 09:27
Counting Valleys - Javascript
// Complete the countingValleys function below.
function countingValleys(n, s) {
let level = 0;
let numberOfValleys = 0;
for (let i = 0; i < n; i++) {
const next = s[i]
if (next === 'U') {
if (level === -1) {
numberOfValleys = numberOfValleys + 1;
@c-j-j
c-j-j / counting-valleys.re
Last active November 21, 2018 09:31
Counting Valleys - ReasonML
let countingValleys = (~s) => {
let rec iter = (~numberOfValleys, ~level, ~s) =>
if (String.length(s) === 0) {
numberOfValleys;
} else {
let next = s.[0];
let rest = String.sub(s, 1, String.length(s) - 1);
switch (next, level) {
| ('U', (-1)) => iter(~numberOfValleys=numberOfValleys + 1, ~level=level + 1, ~s=rest)
| ('U', _) => iter(~numberOfValleys, ~level=level + 1, ~s=rest)

Sorting

  • Bubble Sort
  • Merge Sort

Searching

  • Linear Search
  • Binary Search

Keybase proof

I hereby claim:

  • I am c-j-j on github.
  • I am c_j_j (https://keybase.io/c_j_j) on keybase.
  • I have a public key whose fingerprint is 210B 26A1 E4BA FC11 D5EE 76DC 40CE A769 DC62 7148

To claim this, I am signing this object:

@c-j-j
c-j-j / cat_finder.ex
Created February 28, 2016 16:43
Concurrent file searcher in Elixir
defmodule CatFinder do
def find(scheduler) do
send scheduler, {:ready, self}
receive do
{ :find, file, scheduler_pid} ->
send scheduler_pid, { :answer, file, num_of_cats(file) }
find(scheduler)
{ :shutdown } ->
@c-j-j
c-j-j / gist:df314cf4691d390f0cc8
Last active March 8, 2017 15:04
Go mask network IP
package main
import (
"fmt"
"net"
)
//foo
func main() {
@c-j-j
c-j-j / ruby.vim
Created January 22, 2016 09:54
Find Ruby File Usages With Vim
function! RemoveLibPrefix(path)
let shortenedPath = split(a:path, "/")[1:]
return join(shortenedPath, "/")
endfunction
function! FindCurrentFileUsage()
let filePath = RemoveLibPrefix(@%)
let rubyPath = substitute(filePath, ".rb", "", "")
exec "silent grep! " . rubyPath . " **/*.rb"
exec "copen"
@c-j-j
c-j-j / json_marshalling_and_http_get.go
Created January 9, 2016 15:35
Json marshalling/unmarshalling with HTTP Get using Go
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type person struct {
UserId int `json:"userId"`
@c-j-j
c-j-j / about.md
Last active October 27, 2015 18:33 — forked from Maikon/about.md