Skip to content

Instantly share code, notes, and snippets.

View AlexanderProd's full-sized avatar
⚛️
Looking at FLIR images.

Alexander Hörl AlexanderProd

⚛️
Looking at FLIR images.
View GitHub Profile
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active November 9, 2024 08:57
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@soheilhy
soheilhy / nginxproxy.md
Last active October 23, 2024 08:19
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@tonysneed
tonysneed / Mac OS X: Open in Visual Studio Code
Last active June 14, 2024 04:16
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
@idleberg
idleberg / atom-macos-context-menu.md
Last active April 27, 2022 00:37
“Open in Atom” in macOS context-menu

Open in Atom

  • Open Automator
  • Create a new Service
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /usr/local/bin/atom -n "$@"
  • Set “Pass input” to as arguments
  • Save as Open in Atom
@nmarley
nmarley / docker_cid.sh
Created December 8, 2016 13:58
Docker — get container ID from within Docker container
bash-4.3# cat /proc/1/cpuset
/docker/13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e
bash-4.3# DOCKER_CID=$(cat /proc/1/cpuset | cut -c9-)
bash-4.3# echo $DOCKER_CID
13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e
@Saifadin
Saifadin / useTypewriter.js
Last active January 25, 2019 18:31
Typewriter like "animation" for a string | Hooks
import { useState, useEffect } from 'react';
export const useTypeWriter = (text, startNow = true, speed = 100, skip) => {
const [toBeTyped] = useState(text);
const [displayedText, setDisplayedText] = useState('');
const [isDone, setIsDone] = useState(false);
const [intervalId, setIntervalId] = useState(null);
useEffect(
() => {
@FlorianRappl
FlorianRappl / useCarousel.ts
Last active August 16, 2024 06:30
The generic useCarousel hook.
import { useReducer, useEffect } from 'react';
import { useSwipeable, SwipeableHandlers, EventData } from 'react-swipeable';
function previous(length: number, current: number) {
return (current - 1 + length) % length;
}
function next(length: number, current: number) {
return (current + 1) % length;
}
@Retsam
Retsam / exampleState.ts
Last active January 31, 2021 18:11
Redux-like useReducer pattern
import { Dispatch, useReducer, useEffect } from "react";
import { produce } from "immer";
//=======
// State
//=======
export type ExampleState = {
name: string;
level: number;
saved: false;