Skip to content

Instantly share code, notes, and snippets.

View balazsorban44's full-sized avatar
🌍
Coding from anywhere

Balázs Orbán balazsorban44

🌍
Coding from anywhere
View GitHub Profile
@bennadel
bennadel / spliced.htm
Created June 2, 2014 22:15
Spliced - A Version Of Splice() That Returns The Original Array In JavaScript
<!doctype html>
<html>
<head>
<title>
Spliced in Array Prototype To Return Original Array Reference
</title>
</head>
<body>
<h1>
@iDVB
iDVB / useScrollSpy.js
Created April 21, 2020 19:23
useScrollSpy similar to MUI docs https://bit.ly/3cArBBr
import { useState, useEffect, useRef, useCallback } from 'react';
import useThrottledOnScroll from './useThrottledOnScroll';
const useScrollSpy = ({ items = [], target = window } = {}) => {
const itemsWithNodeRef = useRef([]);
useEffect(() => {
itemsWithNodeRef.current = getItemsClient(items);
}, [items]);
const [activeState, setActiveState] = useState(null);
@arnobroekhof
arnobroekhof / pre-commit
Last active May 9, 2022 13:41
Maven pre commit hook
#!/bin/bash
# save the file as <git_directory>/.git/hooks/pre-commit
echo "Running Maven clean test for errors"
# retrieving current working directory
CWD=`pwd`
MAIN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# go to main project dir
cd $MAIN_DIR/../../
import { Machine, assign } from 'xstate';
import firebase from './firebase';
const chart = {
id: 'auth',
context: {
auth: null,
error: null,
loggedoutTime: null
},
@thebuilder
thebuilder / jest.config.js
Last active October 29, 2022 02:42
Use Jest Projects to run both JSDom and Node tests in the same project
module.exports = {
projects: [
{
displayName: 'dom',
testEnvironment: 'jsdom',
snapshotSerializers: ['enzyme-to-json/serializer'],
testMatch: ['**/__tests__/**/*.test.js?(x)']
},
{
displayName: 'node',
@femto113
femto113 / transpose.js
Last active September 6, 2023 00:28
one line transpose for 2-dimensional Javascript arrays
function transpose(a)
{
return a[0].map(function (_, c) { return a.map(function (r) { return r[c]; }); });
// or in more modern dialect
// return a[0].map((_, c) => a.map(r => r[c]));
}
@orta
orta / rfc.md
Last active February 20, 2024 02:23
A proposal for improving TS2322 error messages

This is a work in progress. Please don't take this as something that will definitely happen, we all know what happens to well laid plans and I need to present it to the rest of the TypeScript team in order to figure out a lot of feasibility questions.

Intro

The examples in this PR assumes [CLI DX] Improve positioning of compiler error messaging info #45717 is merged

In 4.4, all diagnostic messages from TypeScript are treated the same, we have a massive .JSON file of ±2000 diagnostic messages which are used everywhere from compiler messages to CLI help. Aside from some simple string manipulation, these are effectively what we output for all error messages. I'd like to propose that we break this pattern, just for error TS2322.

TS2322 is our 'type x is not assignable to y' error, you'd see it for const str: string = 123 and I expect it is the most seen

@stephenway
stephenway / git-change-author-commit.sh
Created December 19, 2015 04:02
Change last commit author
git commit --amend --author "Stephen Way <way.stephen@gmail.com>" --no-edit && \
git rebase --continue
...
git push origin master --force
@dcasati
dcasati / export-kubeconfig-from-aks
Created February 6, 2018 15:30
Export KUBECONFIG from AKS
az aks get-credentials --resource-group k8s-demo-ss --name k8s-demo-cluster-ss --file kubeconfig-ss