Skip to content

Instantly share code, notes, and snippets.

View blitzblade's full-sized avatar
🎯
Focused.

Kwesi Dadson blitzblade

🎯
Focused.
View GitHub Profile
@blitzblade
blitzblade / check_ip_port.py
Created May 30, 2018 04:42
This is a piece of code for checking if an ip:port is open and also do continuous checks.
import socket
from time import sleep
def is_open(ip,port,timeout=5):
socket.setdefaulttimeout(timeout)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, int(port)))
s.shutdown(2)
@blitzblade
blitzblade / flask nuggets
Last active October 31, 2019 16:16
Python Diary
install requirements with pipenv:
pipenv install -r requirements.txt
run python file in pipenv:
pipenv run python file.py
add manager so you can use migrations (using alembic)
initialize migration:
python manage.py db init
@blitzblade
blitzblade / titleizer.rb
Created August 27, 2019 12:18
[Titleize hyphenated names in ruby] #titleize #capitalize #ruby #rails
def titleizer(name)
name.split.map{ |part| part.split("-").map{ |p| p.capitalize }.join("-") }.join(" ")
end
@blitzblade
blitzblade / NumberToWords.cs
Last active August 27, 2019 16:12
[Number to words in C#] #c# #string #words #number
public static string NumberToWords(long number)
{
if (number == 0)
return "zero";
if (number < 0)
return "minus " + NumberToWords(Math.Abs(number));
string words = "";
#STEP 1
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE SCHEMA audit;
REVOKE ALL ON SCHEMA audit FROM public;
COMMENT ON SCHEMA audit IS 'Out-of-table audit/history logging tables and trigger functions';
--
@blitzblade
blitzblade / learn-react.md
Created February 28, 2020 10:07 — forked from claeusdev/learn-react.md
How to become a React expert
  1. Carefully do the official [tutorial][].
  2. Read the official guide to [main concepts][].
  3. Read the official [advanced guides][].
  4. Watch [building React from scratch][] to get an idea of how React actually works (this covers the "stack" reconciler which was used in React 15 and earlier).
  5. Go through the [React "fiber" architecture][] which is the default reconciler since React 16.
  6. Go crazy, build your own projects, and stop doing React tutorials!
@blitzblade
blitzblade / #go bible
Last active January 7, 2021 05:24
#go
run go docs locally:
godoc -http=:6060
ping a group of servers called taapp:
ansible -i hosts taapp -m ping
run command, load from inventory:
ansible -i inventory all -m command -a "iptables -F" --become
send "ls" command to group taapp:
ansible taapp -m command -a "ls"
@blitzblade
blitzblade / react bible
Created January 6, 2021 13:19
#react #typescript
npx create-react-app app-name --template typescript
@blitzblade
blitzblade / quantconnect.py
Created January 19, 2021 03:34
#quantconnect #trading #python
from datetime import date
from dateutil.relativedelta import relativedelta
import numpy as np
class DynamicHorizontalContainmentField(QCAlgorithm):
def Initialize(self):
six_months_ago = date.today() + relativedelta(months=-6)
self.SetStartDate(six_months_ago) # Set Start Date
self.SetEndDate(date.today())