Skip to content

Instantly share code, notes, and snippets.

View rahulspace's full-sized avatar
🚴‍♂️
Speed up

Rahul rahulspace

🚴‍♂️
Speed up
View GitHub Profile
@rahulspace
rahulspace / gist:c936425045ef078f9c60ad3813e18e39
Created June 1, 2024 05:17
Tilt React Component Move Using Framer Motion - Tilt Children On Mouse
// components/Tilt.js
import React, { useState, useEffect } from "react";
import { motion } from "framer-motion";
const Tilt = ({ children }) => {
const [mousePosition, setMousePosition] = useState({ x: window.innerWidth / 2, y: window.innerHeight / 2 });
useEffect(() => {
const handleMouseMove = (e) => {
setMousePosition({
@rahulspace
rahulspace / Random Color Generator.js
Created September 19, 2022 08:41
Random Color Generator JavaScript
export default {
generate() {
var letters = "BCDEF";
var color = "#";
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * letters.length)];
}
return color;
},
};

React js

Create element

const e = React.createElement;

Create component

alias gits='git status'
alias gita='git add'
alias gitaa='git add .'
alias gitc='git commit -m'
alias gitl='git log'
alias gitb='git branch'
alias gitch='git checkout'
alias gitr='git reset HEAD^'
alias gitph='git push origin'
alias gitpl='git pull origin'
Commits count by author: git shortlog -s -n --all --no-merges
All insertions and deletions by author: git log --shortstat --pretty="%cE" | sed 's/\(.*\)@.*/\1/' | grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' | sort | sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' | awk 'BEGIN {name=""; files=0; insertions=0; deletions=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net"; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net";}'
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php7.2-common php7.2-cli php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-mbstring php7.2-bcmath php7.2-imap php7.2-xml php7.2-zip
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
@rahulspace
rahulspace / gist:08187b9480357b1e2194cd0fc05c1639
Created September 20, 2019 12:23
keywords generate from sentance
var message = 'a quick brown fox jumps over the lazy dog'
const splited = _.split(message, ' ')
var keywords = []
_.forEach(splited, (item, index) => {
for(var i = 0; i < splited.length ; i++) {
var data = _.take(splited, i + 1)
data = _.join(data, ' ')
keywords.push(data)
console.log(data)
@rahulspace
rahulspace / mongodb sharding with docker instances
Created August 22, 2019 06:50
mongodb sharding with docker instances
sudo mongod --configsvr --replSet csr --dbpath data/db/ --port 27019 --logpath /var/log/mongodb/mongod.log --bind_ip 0.0.0.0 --fork
rs.initiate({
_id: "csr",
configsvr: true,
members: [
{ _id: 0, host : "10.128.0.44:27019"},
{ _id: 1, host : "10.128.0.45:27019"},
]
})

###Visual Studio Code

CMD+P for search file in directory