Skip to content

Instantly share code, notes, and snippets.

View ArdeshirV's full-sized avatar

Ardeshir ArdeshirV

View GitHub Profile
@createdbymahmood
createdbymahmood / Button.tsx
Last active January 9, 2021 05:01
This is how I render a react Button component with different conditions
import React from 'react';
import classnames from 'classnames';
// * these are the base custom button props
type ButtonSizeType = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
type ButtonTypeType =
| 'primary'
| 'info'
| 'light-info'
| 'warning'
@camperbot
camperbot / server.js
Last active December 5, 2022 05:52 — forked from ShaunSHamilton/server.js
Advanced Node and Express - How to Use Passport Strategies
'use strict';
require('dotenv').config();
const express = require('express');
const myDB = require('./connection');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const session = require('express-session');
const passport = require('passport');
const ObjectID = require('mongodb').ObjectID;
const LocalStrategy = require('passport-local');
@camperbot
camperbot / server.js
Last active December 5, 2022 05:53 — forked from ShaunSHamilton/server.js
Advanced Node and Express - Hashing Your Passwords
'use strict';
require('dotenv').config();
const express = require('express');
const myDB = require('./connection');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const session = require('express-session');
const passport = require('passport');
const ObjectID = require('mongodb').ObjectID;
const LocalStrategy = require('passport-local');
const bcrypt = require('bcrypt');
@camperbot
camperbot / routes.js
Last active September 16, 2021 19:50 — forked from ShaunSHamilton/routes.js
Advanced Node and Express - Implementation of Social Authentication
const passport = require('passport');
const bcrypt = require('bcrypt');
module.exports = function (app, myDataBase) {
app.route('/').get((req, res) => {
// Change the response to render the Pug template
res.render('pug', { title: 'Connected to Database', message: 'Please login', showLogin: true, showRegistration: true, showSocialAuth: true });
});
app.route('/login').post(passport.authenticate('local', { failureRedirect: '/' }), (req, res) => {
res.redirect('/profile');
@camperbot
camperbot / client.js
Last active July 9, 2022 01:35 — forked from ShaunSHamilton/client.js
Advanced Node and Express - Set up the Environment
// This file's full path is /public/client.js
$(document).ready(function () {
/* Global io */
let socket = io();
// Form submittion with new message in field with id 'm'
$('form').submit(function () {
let messageToSend = $('#m').val();
// Send message to server here?
$('#m').val('');
@camperbot
camperbot / server.js
Last active August 27, 2022 10:19 — forked from ShaunSHamilton/server.js
Advanced Node and Express - Authentication with Socket.IO
'use strict';
require('dotenv').config();
const express = require('express');
const myDB = require('./connection');
const fccTesting = require('./freeCodeCamp/fcctesting.js');
const session = require('express-session');
const passport = require('passport');
const routes = require('./routes');
const auth = require('./auth.js');
@camperbot
camperbot / client.js
Last active April 29, 2022 02:07 — forked from ShaunSHamilton/client.js
Advanced Node and Express - Send and Display Chat Messages
$(document).ready(function () {
/* Global io */
let socket = io();
socket.on('user', (data) => {
$('#num-users').text(data.currentUsers + ' users online');
let message = data.name + (data.connected ? ' has joined the chat.' : ' has left the chat.');
$('#messages').append($('<li>').html('<b>' + message + '</b>'));
});
@kvedala
kvedala / Wiki plots in simple SVG.ipynb
Last active July 29, 2023 12:38
Generate SVG graphs using linear, quadratic and cubic Bezier curve interpolation.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@CAFxX
CAFxX / golang_minimize_allocations.md
Last active March 9, 2025 14:32
Minimize allocations in Go

📂 Minimize allocations in Go

A collection of tips for when you need to minimize the number of allocations in your Go programs.

Use the go profiler to identify which parts of your program are responsible for most allocations.

⚠️ Never apply these tricks blindly (i.e. without measuring the actual performance benefit/impact). ⚠️

Most of these tricks cause a tradeoff between reducing memory allocations and other aspects (including e.g. higher peak memory usage, higher CPU usage, lower maintainability, higher probability of introducing subtle bugs). Only apply these tricks if the tradeoff in every specfic case is globally positive.