Skip to content

Instantly share code, notes, and snippets.

View ChristianOellers's full-sized avatar
🇨🇾

Christian Oellers ChristianOellers

🇨🇾
View GitHub Profile
@ali-sabry
ali-sabry / useSpeechRecognition.js
Created May 22, 2023 13:09
this hook allows users to control the application with voice commands.
import { useState, useEffect } from "react";
function useSpeechRecognition(commands, callback) {
const [recognition, setRecognition] = useState(null);
const [transcript, setTranscript] = useState("");
const [error, setError] = useState("");
const [status, setStatus] = useState("idle");
// define an effect that runs once when the component mounts
useEffect(() => {
@viclafouch
viclafouch / modal.jsx
Last active January 23, 2023 21:14
An implementation of a Modal Component with React Hooks ! See https://react-modal.viclafouch.vercel.app
import React, { useEffect, useImperativeHandle, useState, forwardRef, useCallback } from 'react'
import { createPortal } from 'react-dom'
import './styles.css'
const modalElement = document.getElementById('modal-root')
export function Modal({ children, fade = false, defaultOpened = false }, ref) {
const [isOpen, setIsOpen] = useState(defaultOpened)
const close = useCallback(() => setIsOpen(false), [])
@chillu
chillu / Gemfile
Last active November 12, 2022 23:24
Batch update labels in Github repos
gem "octokit", "~> 4.0"
@adamreisnz
adamreisnz / package.json
Last active January 19, 2024 13:01
Simple pure npm scripts build process
{
"name": "project-name",
"description": "Template for static sites",
"version": "1.0.0",
"homepage": "http://www.project-name.com",
"author": {
"name": "Adam Reis",
"url": "http://adam.reis.nz"
},
"license": "UNLICENSED",
@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@jay-johnson
jay-johnson / example .travis.yml
Created November 27, 2015 07:44
example .travis.yml
sudo: required
language: ruby
services:
- docker
before_install:
- echo "Testing Docker Hub credentials"
- docker login -e=$DOCKER_EMAIL -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
@blixt
blixt / prng.js
Last active January 14, 2024 07:01
A very simple, seedable JavaScript PRNG. NOTE: Please read comments on why this is not a good choice.
// NOTICE 2020-04-18
// Please see the comments below about why this is not a great PRNG.
// Read summary by @bryc here:
// https://github.com/bryc/code/blob/master/jshash/PRNGs.md
// Have a look at js-arbit which uses Alea:
// https://github.com/blixt/js-arbit
/**
@joyrexus
joyrexus / README.md
Last active February 1, 2023 08:51 — forked from joelambert/README
RAF replacements for setTimeout and setInterval

Drop in replace functions for setTimeout and setInterval that make use of requestAnimationFrame.

See overview article and Paul Irish's earlier post.

Courtesty of Joe Lambert

Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
@geraldyeo
geraldyeo / bitwise.as
Created March 28, 2011 06:53
Bitwise gems – fast integer math
/*
Left bit shifting to multiply by any power of two
Approximately 300% faster.
*/
x = x * 2;
x = x * 64;
//equals:
x = x << 1;