Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍
Programming

Travis Clarke clarketm

🐍
Programming
View GitHub Profile
@clarketm
clarketm / largestBinaryGap.js
Last active Jul 24, 2021
Largest Binary Gap (JavaScript)
View largestBinaryGap.js
function largestBinaryGap(num) {
var bin = Math.abs(num).toString(2),
finalMax = 0,
currentMax;
for (var i = 0; i < bin.length; i++) {
currentMax = 0;
while (bin[i] === "0") {
++currentMax && ++i;
}
@clarketm
clarketm / google-dorks
Created Jan 30, 2017 — forked from stevenswafford/google-dorks
Listing of a number of useful Google dorks.
View google-dorks
" _ _ "
" _ /|| . . ||\ _ "
" ( } \||D ' ' ' C||/ { % "
" | /\__,=_[_] ' . . ' [_]_=,__/\ |"
" |_\_ |----| |----| _/_|"
" | |/ | | | | \| |"
" | /_ | | | | _\ |"
It is all fun and games until someone gets hacked!
@clarketm
clarketm / cyclicRotation.js
Last active Jun 16, 2021
Cyclic Rotation (JavaScript)
View cyclicRotation.js
function cyclicRotation(array, times) {
var rotatedArray = array;
while (times > 0) {
var currentArray = rotatedArray.slice();
for (var i = 0; i < currentArray.length; i++) {
rotatedArray[(i+1)%currentArray.length] = currentArray[i];
}
times--;
@clarketm
clarketm / socat_server.sh
Created Jun 23, 2017 — forked from CMCDragonkai/socat_server.sh
Socat: Simple HTTP Server
View socat_server.sh
socat \
-v -d -d \
TCP-LISTEN:1234,crlf,reuseaddr,fork \
SYSTEM:"
echo HTTP/1.1 200 OK;
echo Content-Type\: text/plain;
echo;
echo \"Server: \$SOCAT_SOCKADDR:\$SOCAT_SOCKPORT\";
echo \"Client: \$SOCAT_PEERADDR:\$SOCAT_PEERPORT\";
"
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@clarketm
clarketm / clockAngleProblem.js
Last active Jul 18, 2020
Clock Angle Problem (JavaScript)
View clockAngleProblem.js
function getClockAngle(hours, minutes, isPortionWithTwelve) { // using 12-hour OR 24-hour clock notation
hours = hours % 12;
var hourMinPart = 0.5 * minutes, // 30 degrees per 60 minutes => 1/2 degree per 1 minute => 0.5 * minute
hourHourPart = 30 * hours, // 30 degrees per 1 hour => 30 * hour
minAngle = 6 * minutes, // 360 degrees per 60 minutes => 6 degrees per 1 minute => 6 * minute
totalAngle = Math.abs(hourMinPart + hourHourPart - minAngle); // absolute difference
return isPortionWithTwelve ? 360 - totalAngle : totalAngle; // subtract the total angle from 360 to get the portion w/ 12
}
@clarketm
clarketm / get_oauth2_token.py
Last active Mar 1, 2020
How to get Google OAuth 2.0 access token in console using the Python API
View get_oauth2_token.py
#!/usr/bin/env python
'''
This script will attempt to open your webbrowser,
perform OAuth 2.0 authentication and print your access token.
To install dependencies from PyPI:
$ pip install oauth2client
Then run this script:
View sql-mongo_comparison.md

SQL to MongoDB Mapping Chart

SQL to MongoDB Mapping Chart

In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.

Executables

The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.

@clarketm
clarketm / private_fork.md
Created Nov 9, 2019 — forked from 0xjac/private_fork.md
Create a private fork of a public repository
View private_fork.md

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)
    git clone --bare git@github.com:usi-systems/easytrace.git
@clarketm
clarketm / WARNING.md
Created Sep 29, 2019 — forked from Ambroos/WARNING.md
Remove SentinelOne agent from Mac. Because honestly, it doesn't seem to do anything at all. Run as root, best is to do this from a recovery mode, single user mode with writeable filesystem, ...
View WARNING.md

USE AT OWN RISK

This was only tested on a partial SentinelOne installation on the High Sierra beta, where SentinelOne was never allowed to enable it's kernel extension.