Skip to content

Instantly share code, notes, and snippets.

View axellbrendow's full-sized avatar

Axell Brendow axellbrendow

View GitHub Profile
@Areahints
Areahints / algoGoogle.md
Last active March 24, 2024 12:37
[Algorithm question by Google] solve for O(nlogn) #python3 #big-o

QUESTION

We can determine how "out of order" an array A is by counting the number of inversions it has.

Two elements A[i] and A[j] form an inversion if A[i] > A[j] but i < j. That is, a smaller element appears after a larger element.

CHALLENGE

Given an array, count the number of inversions it has. Do this faster than O(N2) time.

@sibelius
sibelius / route.ts
Created January 28, 2019 00:41
routeTo helper to handle params and query string
import { generatePath } from 'react-router-dom';
import { stringify } from 'query-string';
const routeTo = (path: string, params: object, qs: object) => {
const url = generatePath(path, params);
return qs ? `${url}?${stringify(qs}` : url;
}
history.push(routeTo('admin/view/:id', { id: 'ok'}, { anotherParam: 'value' }));
@adrianmcli
adrianmcli / Spinner.js
Created December 3, 2017 01:26
Dead simple loading spinner with just CSS in styled-components.
import styled, { keyframes } from "styled-components";
const rotate360 = keyframes`
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
@troyharvey
troyharvey / deployment.yml
Last active June 16, 2024 12:12
Using Kubernetes envFrom for environment variables
# Use envFrom to load Secrets and ConfigMaps into environment variables
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: mans-not-hot
labels:
app: mans-not-hot
spec:
replicas: 1
@zkat
zkat / index.js
Last active March 10, 2024 14:32
npx is cool
#!/usr/bin/env node
console.log('yay gist')
@subfuzion
subfuzion / curl.md
Last active June 29, 2024 16:04
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@JamesMGreene
JamesMGreene / gitflow-breakdown.md
Last active June 22, 2024 03:44
`git flow` vs. `git`: A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@branneman
branneman / better-nodejs-require-paths.md
Last active June 29, 2024 16:00
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@tedmiston
tedmiston / nodejs-tcp-example.js
Last active May 20, 2024 11:27
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');