Skip to content

Instantly share code, notes, and snippets.

View thegreyfellow's full-sized avatar
🏠
Working Remotely

Youssef Idmoussi thegreyfellow

🏠
Working Remotely
  • Rabat, Morocco.
  • 20:26 (UTC -12:00)
View GitHub Profile
@ChrisTitusTech
ChrisTitusTech / fixlocale.sh
Created October 27, 2020 21:51
Fix Locales in any distro
#!/bin/bash
echo "LC_ALL=en_US.UTF-8" | sudo tee -a /etc/environment
echo "en_US.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen
echo "LANG=en_US.UTF-8" | sudo tee -a /etc/locale.conf
sudo locale-gen en_US.UTF-8
@akramsaouri
akramsaouri / react-lazy-img-io.ts
Last active January 31, 2023 23:24
⚛️ Lazy load images in React with IntersectionObserver.
import React, { useEffect, useRef, FunctionComponent, HTMLProps } from 'react';
import 'intersection-observer'; // if you want to include a polyfill
/**
* Returns an IntersectionObserver that loads the image
* when it is at least {threshold}*100 visible in the viewport.
*
* PS: Cached on the window for performance
*/
function getImageLoaderObserver(
@akramsaouri
akramsaouri / lazy-evaluation.js
Last active October 15, 2018 14:01
Lazy evaluation in JavaScript
function Let(f) {
let called = false
let v = null
return function () {
if(called) return v
console.log('evaluating.')
v = f()
called = true
return v
}
@akramsaouri
akramsaouri / gomodoro.go
Created September 18, 2017 21:18
Pomodoro implementation using go routines/channels.
package main
import (
"fmt"
"os"
"time"
)
type Pomodoro struct {
turnChan, shortBreakChan, longBreakChan, exit chan bool
#!/bin/bash
# Small utility to wait for port to open.
#
# usage:
# ./port-wait.sh hostname port [timeout=10]
#
# ex:
# ./port-wait.sh 127.0.0.1 3000
@tinogomes
tinogomes / pre-commit-complete
Last active March 24, 2021 13:59
Git Hook pre-commit to pass Rubocop and Brakeman on Rails application for validations
#!/bin/sh
#
# Check for ruby style errors
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
NC='\033[0m'
if git rev-parse --verify HEAD >/dev/null 2>&1

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by
@christiangenco
christiangenco / download_egghead_videos.md
Last active January 29, 2024 03:16 — forked from ldong/download_egghead_videos.md
download egghead videos
@iangreenleaf
iangreenleaf / gist:b206d09c587e8fc6399e
Last active June 20, 2024 02:39
Rails naming conventions

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@alecguintu
alecguintu / bm-string-contains-any-in-array.rb
Created April 29, 2014 03:33
Check if string contains any substring in an array in Ruby
require 'benchmark'
iterations = 1_000_000
words = 'foo, bar, test, boo'.split(',').map(&:strip)
string = 'this is going foo be awesome~!'
Benchmark.bmbm do |bm|
bm.report do
iterations.times do
words.any? { |s| string.include?(s) }
end