Skip to content

Instantly share code, notes, and snippets.

View bitcodr's full-sized avatar
πŸ‘¨β€πŸ’»
Focusing...

Amir Roshanaei bitcodr

πŸ‘¨β€πŸ’»
Focusing...
View GitHub Profile
@bitcodr
bitcodr / untitled
Created September 5, 2017 07:21
laravel validation
public function rules()
{
$user = User::find($this->users);
switch($this->method())
{
case 'GET':
case 'DELETE':
{
return [];
db.item_01.find().snapshot().forEach(
... function (elem) {
... db.item_01.update(
... {
... _id: elem._id
... },
... {
... $set: {
... type: elem.attr_values[1]
... }
@bitcodr
bitcodr / latency.txt
Last active April 2, 2023 07:18 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@bitcodr
bitcodr / init.vim
Last active April 30, 2020 14:19
My NeoVim config
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd!
autocmd VimEnter * PlugInstall
endif
call plug#begin('~/.config/nvim/plugged')
"File Search:
Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files
@bitcodr
bitcodr / unfollow.js
Last active August 26, 2020 15:38
Bulk unfollow specific users according to thier jobs in Linkedin
// 1 - go to this page https://www.linkedin.com/feed/following/
// 2 - open browser console past the code as below and click Run
var buttons = $("button"),
interval = setInterval(function(){
var btn = $('.is-following');
var v = document.querySelectorAll("p.follows-recommendation-card__headline");
for(y in v)
{
@bitcodr
bitcodr / install-facetime-hd-webcam.sh
Created October 30, 2020 09:30 — forked from petrstepanov/install-facetime-hd-webcam.sh
Linux Install FaceTimeHD Camera
#!/bin/bash
set -e
export CONFIG_MODULE_SIG=n
export CONFIG_MODULE_SIG_ALL=n
# For current kernel
export KERNELRELEASE=$(cat /proc/version | awk '{print $3}')
temp_dir=$(mktemp -d)
echo "Installing FacetimeHD camera for $KERNELRELEASE"
@bitcodr
bitcodr / WSL2_VPN_Workaround_Instructions.md
Created September 12, 2021 14:44 — forked from machuu/WSL2_VPN_Workaround_Instructions.md
Workaround for WSL2 network broken on VPN

Overview

Internet connection and DNS routing are broken from WSL2 instances, when some VPNs are active. The workaround breaks down into two problems:

  1. Network connection to internet
  2. DNS in WSL2

This problem is tracked in multiple microsoft/WSL issues including, but not limited to:

@bitcodr
bitcodr / latency.md
Last active October 1, 2025 11:38
Latency Numbers For Software Engineers (2024-2025 Edition)

Core System Latencies

Operation                                    Latency        Human Scale*
═══════════════════════════════════════════════════════════════════════
L1 cache reference                           0.5 ns        1 second
Branch mispredict                            5   ns        10 seconds
L2 cache reference                           7   ns        14 seconds
Mutex lock/unlock                           25   ns        50 seconds
Main memory reference                      100   ns        3.3 minutes