Skip to content

Instantly share code, notes, and snippets.

@saqibameen
saqibameen / jax-m1-install.sh
Last active March 13, 2024 03:49
Installing Jax on Macbook — Apple Silicon (M1 Mac)
# jax officially support m1 mac.
pip install jax jaxlib
# if running into issues.
conda create --name jax python=3.9
conda activate jax
pip install jax jaxlib
body {
font-weight: 500;
font-style: normal;
text-align: left;
padding: 1rem 6rem 4rem 6rem;
max-width: min(100%, 1140px);
align-self: center;
margin: 0 auto;
@saqibameen
saqibameen / breast-cancer-dataset.csv
Last active October 7, 2021 07:53
Open ML Breast Cancer Dataset. Source: https://www.openml.org/d/13
age menopause tumor-size inv-nodes node-caps deg-malig breast breast-quad irradiat Class
40-49 premeno 15-19 0-2 yes 3 right left_up no recurrence-events
50-59 ge40 15-19 0-2 no 1 right central no no-recurrence-events
50-59 ge40 35-39 0-2 no 2 left left_low no recurrence-events
40-49 premeno 35-39 0-2 yes 3 right left_low yes no-recurrence-events
40-49 premeno 30-34 3-5 yes 2 left right_up no recurrence-events
50-59 premeno 25-29 3-5 no 2 right left_up yes no-recurrence-events
50-59 ge40 40-44 0-2 no 3 left left_up no no-recurrence-events
40-49 premeno 10-14 0-2 no 2 left left_up no no-recurrence-events
40-49 premeno 0-4 0-2 no 2 right right_low no no-recurrence-events
We can't make this file beautiful and searchable because it's too large.
"age","workclass","fnlwgt","education","education-num","marital-status","occupation","relationship","race","sex","capitalgain","capitalloss","hoursperweek","native-country","class"
2,State-gov,77516,Bachelors,13,Never-married,Adm-clerical,Not-in-family,White,Male,1,0,2,United-States,<=50K
3,Self-emp-not-inc,83311,Bachelors,13,Married-civ-spouse,Exec-managerial,Husband,White,Male,0,0,0,United-States,<=50K
2,Private,215646,HS-grad,9,Divorced,Handlers-cleaners,Not-in-family,White,Male,0,0,2,United-States,<=50K
3,Private,234721,11th,7,Married-civ-spouse,Handlers-cleaners,Husband,Black,Male,0,0,2,United-States,<=50K
1,Private,338409,Bachelors,13,Married-civ-spouse,Prof-specialty,Wife,Black,Female,0,0,2,Cuba,<=50K
2,Private,284582,Masters,14,Married-civ-spouse,Exec-managerial,Wife,White,Female,0,0,2,United-States,<=50K
3,Private,160187,9th,5,Married-spouse-absent,Other-service,Not-in-family,Black,Female,0,0,0,Jamaica,<=50K
3,Self-emp-not-inc,209642,HS-grad,9,Married-civ-spouse,Exec-managerial,Husband,White,Male,0,0
@saqibameen
saqibameen / notes.js
Created August 10, 2020 07:16
if conditions in javascript
// 0 and '' are evaluated to false in JS.
let x = 0;
if(x) {
...
} else {
// Will come here
}
let str = '';
@saqibameen
saqibameen / creating-objects.js
Created August 7, 2020 21:00
Use computed keys in objects while creating them.
// In ES5.
function createObjWithKey(key) {
let newObj = {};
newObj.[key] = 1;
return newObj;
}
// In ES6
function createObjWithKey(key) {
@saqibameen
saqibameen / redirection-next.js
Created August 5, 2020 15:42
Server side and client side redirection in next.js
import Router from 'next/router';
const redirectLocation = '/error';
// If server.
if (ctx.res) {
ctx.res.writeHead(303, { Location: redirectLocation });
ctx.res.end();
} else {
// If browser.
Router.push(redirectLocation);
@saqibameen
saqibameen / redirection-next.js
Created August 5, 2020 15:42
Server side and client side redirection in next.js
import Router from 'next/router';
const redirectLocation = '/error';
// If server.
if (ctx.res) {
ctx.res.writeHead(303, { Location: redirectLocation });
ctx.res.end();
} else {
// If browser.
Router.push(redirectLocation);
@saqibameen
saqibameen / redirection-next.js
Created August 5, 2020 15:42
Server side and client side redirection in next.js
import Router from 'next/router';
const redirectLocation = '/error';
// If server.
if (ctx.res) {
ctx.res.writeHead(303, { Location: redirectLocation });
ctx.res.end();
} else {
// If browser.
Router.push(redirectLocation);
@saqibameen
saqibameen / string-to-expression.js
Created July 27, 2020 14:13
Convert a string into a an actual JavaScript expression/statement
// Source: https://stackoverflow.com/questions/55074927/eval-vs-function-constructor
(() => {
let secret = 42;
eval("console.log(secret)"); // 42
let fn = new Function("console.log(secret)");
fn(); // secret is not defined
})();