Skip to content

Instantly share code, notes, and snippets.

View duke79's full-sized avatar

duke79 duke79

View GitHub Profile
@duke79
duke79 / react-connect.jsx
Created January 1, 2020 16:42
Redux in 30 seconds {PART 2}
import { connect } from 'react-redux';
const = MyComponent => (props) {
console.log(props.reduxState);
return null;
}
const mapStateToProps = function(state) {
return {
reduxState: state,
@duke79
duke79 / reducer.ts
Last active January 1, 2020 16:44
Redux in 30 seconds
const state = {}
...
const myReducer = ({ action, data }) => {
switch (action) {
case 'A_STRING_REPRESENTING_AN_ACTION':
return {
...state,
//some modifications based on 'data'
}
default:
@duke79
duke79 / msfinstall
Created December 15, 2019 09:33
metasploit
#!/bin/sh
print_pgp_key() {
cat <<-EOF
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFDAy/0BEAC8I5bw5gLQqHKx5JCacYcXFL6AZowl3qIOTxo5yfBl8CepNpWY
OOERvIUJb17WehhhbWOo9WjpBalDXBRtI1NvfArewOT8fLm7BdhYe8U45moBfkYi
xFtNrPw3pdIltHQISrB8PufhliN8obQuq0rcxYV8NblvYo4gIGNjBfO1QGvBNmp7
kBtjlAuZguScZmUTdPOwfv8fqN52X9tCv1ahQk1hg8XG9YwW0vXb5z93jkLXBb5b
@duke79
duke79 / bot.py
Created December 12, 2019 11:33
Slack Bot
# ref : https://github.com/slackapi/python-slackclient
import sys
import uuid
import slack
from lib.py.core.config import Config
slack_token = Config()["slackbot"]["user_token"]
authorized_users = Config()["slackbot"]["authorized_user_ids"]
client = slack.WebClient(slack_token)
@duke79
duke79 / dep.bat
Created June 19, 2019 09:46
python dependencies
@echo off
set PYTHONPATH=%~dp0..\..
python %~dp0..\py\dependencies.py %*
REM cli dep %*
@duke79
duke79 / retirement_plan.py
Last active May 10, 2019 15:53
Calculators
class Portfolio:
AGE=29 # Starting year
CTC=1000000 # Total CTC, it's assumed that only 75% comes in hand
HIKE=100000 # Assuming 1 lakh hike every year
RETURNS_PER_ANNUM = 1.10 # Assuming investment returns are 10% per annum
EXPENSES_PER_MONTH = 40000 # Assuming monthly expenses are 40k, inflation taken into account while calculating though
INFLATION=1.07 # Assuming 7% inflation
ASSETS=0 # Assuming there's no investment so far
DURATION=50 # Assuming death after 50 years
// ==UserScript==
// @name Emby - local path
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://localhost:8096/*
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// ==/UserScript==
@duke79
duke79 / IntelIJTrialReset.bat
Created January 15, 2019 05:23
How to Reset InteIIiJ IDEA Evaluation Key in Windows
cd "C:%HOMEPATH%\.IntelliJIdea*\config"
rmdir "eval" /s /q
del "options\options.xml"
reg delete "HKEY_CURRENT_USER\Software\JavaSoft\Prefs\jetbrains\idea" /f
:: It is Highly Advised to Purchase the JetBrain Softwares
:: This is only for the case You just want to Extend the
:: Trial Period and Evaluate the IDE for some more Time
@duke79
duke79 / packages.txt
Created August 29, 2018 16:02
Kubuntu Config
apt-get install git
add-apt-repository ppa:nathan-renniewaldock/flux
apt-get install git
sudo apt-get install python-pip
git clone "https://github.com/xflux-gui/fluxgui.git"
@duke79
duke79 / CodeChef.py
Created May 13, 2018 09:44
CodeChef - Python
def mainFile():
f = open("CodeChefInput.txt", "r")
f.readline()
def nextLine():
line = f.readline()
elems = line.split()
if len(elems) < 2:
return int(line)
else:
for idx in range(len(elems)):