Skip to content

Instantly share code, notes, and snippets.

View secondBreakfastDev's full-sized avatar
🤓
Geeking

secondBreakfastDev

🤓
Geeking
View GitHub Profile
@secondBreakfastDev
secondBreakfastDev / AxiosTest.test.tsx
Created May 20, 2022 12:25
Axios Testing with Jest
import axios, { AxiosResponse } from 'axios';
jest.mock('axios');
const mAxios = axios as jest.Mocked<typeof axios>
describe('Axios test suite', () => {
it('Test GET', async () => {
mAxios.get.mockResolvedValueOnce({
@secondBreakfastDev
secondBreakfastDev / Jupyter PySpark.yaml
Last active August 20, 2019 04:07
Jupyter notebook with PySpark
version: '3'
services:
notebook:
image: jupyter/pyspark-notebook
environment:
JUPYTER_ENABLE_LAB: 'yes'
ports:
- 8888:8888
@secondBreakfastDev
secondBreakfastDev / server.py
Created July 12, 2019 07:02
Websockets server using Python
import threading, asyncio, websockets, time
# Global stop flag
stopFlag = False
"""
DataWorker thread responsible for data generation.
"""
class DataWorker (threading.Thread):
@secondBreakfastDev
secondBreakfastDev / rsa.sh
Created December 30, 2018 05:20
Extract public / SSH keys from RSA private key
# Extract RSA public key
openssl rsa -pubout -in mykey.pem
# Extract SSH key
ssh-keygen -y -f mykey.pem
@secondBreakfastDev
secondBreakfastDev / gpg.sh
Last active December 30, 2018 05:37
GPG quirks for MacOS X
# You will need Homebrew
# Install GPG
brew install gnupg
# Or the following:
# brew upgrade gnupg
# brew link --overwrite gnupg
# Install Pinentry and restart GPG agent
brew install pinentry-mac
@secondBreakfastDev
secondBreakfastDev / codecommit-iam.md
Created May 3, 2018 05:45
Use IAM role with EC2 and CodeCommit

This is a simple flow to allow EC2 instance that has assumed a role with CodeCommit policy to access CodeCommit

  1. Create EC2 Instance Role with AWSCodeCommitReadOnly policy
  2. Create EC2 with Amazon Linux AMI that assumes the role
  3. Install git: yum install git
  4. Run git config --global credential.helper '!aws codecommit credential-helper $@'
  5. Run git config --global credential.UseHttpPath true
  6. Clone your repo
@secondBreakfastDev
secondBreakfastDev / subl.md
Created April 29, 2018 04:39
Sublime Text 3 Plugins

List of essential plugins for Sublime Text 3

  • Package control
  • Babel
  • Pretty JSON
  • Seti_UI
  • Seti_UX
  • SideBarEnhancements
  • EditorConfig
  • Dockerfile Syntax Highlighting
@secondBreakfastDev
secondBreakfastDev / python.md
Last active March 18, 2018 06:23
Python Installation on Ubuntu 17.10

Motivation

By default Ubuntu 17.10 comes with Python 3.6.3 installed. You can start it by using python3 command. However, none of the following commands is enabled: pip, pip3, python. Moreover, there's no Python 2.7 installed.

Installataion steps

  1. sudo apt update
  2. sudo apt install python
  3. sudo apt install python-pip
  4. sudo apt install python3-pip
@secondBreakfastDev
secondBreakfastDev / histogram-classification.py
Last active September 28, 2017 13:12
Histogram classification based on k-NN
import os
import numpy as np
import cv2
from PIL import Image
def normalize_histogram(histogram):
return histogram / np.linalg.norm(histogram)
def get_image_data(path):
print('Loading image {}...'.format(path))
@secondBreakfastDev
secondBreakfastDev / OpenHome.md
Last active February 12, 2017 14:48
Smart Home

Overview

The following gist inteds to give a brief overview of the required components for building smart home using open technologies.

Hardware

  1. Aeotec Z-Stick GEN 5
  2. Fibaro FGWP101 Metered Wall Plug Switch
  3. Fibaro FGMS001 Motion Sensor firmware v2.8
  4. Fibaro FGMS001 Motion Sensor firmware v3.2
  5. Raspberry Pi 3