Skip to content

Instantly share code, notes, and snippets.

View ekowcharles's full-sized avatar
🎯
Focusing

ekow ekowcharles

🎯
Focusing
View GitHub Profile
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@ekowcharles
ekowcharles / ESPWebSock.ino
Created March 1, 2016 18:32 — forked from bbx10/ESPWebSock.ino
ESP8266 Web server with Web Socket to control an LED
/*
* ESP8266 Web server with Web Socket to control an LED.
*
* The web server keeps all clients' LED status up to date and any client may
* turn the LED on or off.
*
* For example, clientA connects and turns the LED on. This changes the word
* "LED" on the web page to the color red. When clientB connects, the word
* "LED" will be red since the server knows the LED is on. When clientB turns
* the LED off, the word LED changes color to black on clientA and clientB web
@ekowcharles
ekowcharles / json_to_html_list.js
Last active January 19, 2020 03:03
Convert JSON object to HTML list structure
function isObject(obj) {
var type = typeof obj;
return (type === 'function' || type === 'object') && !!obj;
}
function isArray(obj) {
return obj instanceof Array
}
Preferences > Settings > Workbench > Appearance > Edit settings.json
"workbench.colorCustomizations": {
"terminal.foreground": "#839496",
"terminal.background": "#002b36",
"terminalCursor.background": "#A89984",
"terminalCursor.foreground": "#A89984",
"terminal.ansiBlack": "#073642",
"terminal.ansiBlue": "#268bd2",
def project = 'ekowcharles/jenkins-jobs-repo'
def branchApi = new URL("https://api.github.com/repos/${project}/branches")
def branches = new groovy.json.JsonSlurper().parse(branchApi.newReader())
branches.each {
def branchName = it.name
def jobName = "${project}-${branchName}".replaceAll('/','-')
pipelineJob(jobName) {
triggers {
scm('* * * * *')
@ekowcharles
ekowcharles / iterm_tabs_and_panes.py
Last active May 4, 2022 16:40
Automate Tabs & Commands in iTerm2
#!/usr/bin/env python3.7
# As described by Daniela Baron -> https://danielabaron.me/blog/iterm-automation/
#
# The contents of a sample commands definition file may look like so:
# [
# {
# "title": "usrv",
# "panes": [
# {
@ekowcharles
ekowcharles / Makefile
Last active June 3, 2022 00:31
Process ALB Logs
setup:
python3 -m pip install -r requirements.pip
run:
rm -rf logs/*
aws s3 sync s3://<bucket>/AWSLogs/<account-id>/elasticloadbalancing/<region>/<year>/<month>/<day>/ `pwd`/logs
cd logs && gunzip *.log.gz
python3 upload.py
@ekowcharles
ekowcharles / main.go
Last active August 13, 2024 05:32
Interprate JPEG file according to spec
// specs -> https://www.w3.org/Graphics/JPEG/jfif3.pdf
// Suppose you have a JPEG file with the following segments:
// SOI (Start of Image): FFD8
// APP0 (JFIF): FFE0 followed by length and JFIF metadata
// DQT (Quantization Table): FFDB followed by length and quantization table data
// SOF0 (Baseline DCT): FFC0 followed by length and frame information
// DHT (Huffman Table): FFC4 followed by length and Huffman tables
// SOS (Start of Scan): FFDA followed by length and scan parameters
// Compressed Image Data: Huffman-encoded DCT coefficients