Skip to content

Instantly share code, notes, and snippets.

@modyari
modyari / VectorExtensions.cs
Created September 13, 2021 16:14
(Unity) Modifies a Vector's component and returns it
using UnityEngine;
public static class VectorExtensions
{
/// <summary>
/// Returns a modified version of the vector with one or more components modified
/// </summary>
/// <param name="x">X component to modify</param>
/// <param name="y">Y component to modify</param>
/// <returns>A modified version of the vector with the passed component configurations</returns>
@championswimmer
championswimmer / C++ Templates vs Java Generics.md
Created July 28, 2018 01:20
C++ Templates vs Java Generics

Templates in C++ vs Generics in Java

Templates and generics allow us to achieve very similar results using very similar code syntax in C++ and Java respectively. But despite that, the implementation of these two features and their semantics are vastly different under the hood.

Syntax and Usage

Templates

Let us consider first the case of a template called Pair in C++.

@jboner
jboner / latency.txt
Last active May 15, 2024 03:29
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
@alirezamika
alirezamika / autoscraper-examples.md
Last active May 15, 2024 03:29
AutoScraper Examples

Grouping results and removing unwanted ones

Here we want to scrape product name, price and rating from ebay product pages:

url = 'https://www.ebay.com/itm/Sony-PlayStation-4-PS4-Pro-1TB-4K-Console-Black/203084236670' 

wanted_list = ['Sony PlayStation 4 PS4 Pro 1TB 4K Console - Black', 'US $349.99', '4.8'] 

scraper.build(url, wanted_list)
@parmentf
parmentf / GitCommitEmoji.md
Last active May 15, 2024 03:28
Git Commit message Emoji
@bogaotory
bogaotory / install_bionic_on_x1c6.md
Last active May 15, 2024 03:25
Install Ubuntu 18.04 on Thinkpad X1 Carbon 6th Generation

Install Ubuntu 18.04 on Thinkpad X1 Carbon 6th Gen/2018

X1C6 Type: 20KG*

Bionic works out of the box on the new 2018 X1 Carbon. The X1C6 is a beautiful laptop, and Bionic is the best Ubuntu yet. Users of all levels of experties/experiences are recommended to try this combination. The purpose of this documentation is to improve the user's experience.

BIOS/UEFI Changes

Following changes are required by the DSDT patch:

  1. Turn off Secure Boot
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mock File System</title>
<style>
body {
font-family: 'Courier New', Courier, monospace;
background-color: #f4f4f4;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mock File System</title>
<style>
body {
font-family: 'Courier New', Courier, monospace;
background-color: #f4f4f4;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mock File System</title>
<style>
body {
font-family: 'Courier New', Courier, monospace;
background-color: #f4f4f4;
@chranderson
chranderson / nvmCommands.js
Last active May 15, 2024 03:16
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node