Skip to content

Instantly share code, notes, and snippets.

View mcmoe's full-sized avatar

Morgan Kobeissi mcmoe

View GitHub Profile
@mcmoe
mcmoe / gh-api-add-users-to-org.sh
Created February 29, 2024 23:07
Add users in bulk to a GitHub Organization using the gh cli API
# Below code is based on the gh cli api
# mainly on: https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-a-user
# and on: https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#create-an-organization-invitation
# idea is to get the user int id from the GitHub username, and then user that to invite the user to the org
# this is useful when you have a lot of users to invite - and would like to avoid to do it 1 by 1 from the GUI
# the final function is all you need really, passing it the org and a csv file with the usernames
# note that you will need to have gh installed and you would need to first authenticate gh
# ex: gh auth ligin -s admin:org
# you will also need jq to be installed which pipes the json response to return the id only
@mcmoe
mcmoe / priorityqueue.js
Created December 30, 2022 16:44
Simple array-based priority queue in JavaScript with change priority capability
// Priority Queue Item
class PQi {
constructor(item, priority) {
this.item = item;
this.priority = priority;
}
}
@mcmoe
mcmoe / Convert .mov or .MP4 to .gif.md
Last active April 8, 2024 09:15 — forked from SheldonWangRJT/Convert .mov or .MP4 to .gif.md
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This note is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@mcmoe
mcmoe / lit-element-in-browser.html
Created March 19, 2021 07:57
Using Lit Element without npm directly in the browser
<!-- From: https://gist.githubusercontent.com/sorvell/48f4b7be35c8748e8f6db5c66d36ee29/raw/67346e4e8bc4c81d5a7968d18f0a6a8bc00d792e/index.html -->
<!doctype html>
<html>
<head>
<!-- Polyfills only needed for Firefox and Edge. -->
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@latest/webcomponents-loader.js"></script>
</head>
<body>
<!-- Works only on browsers that support Javascript modules like
Chrome, Safari, Firefox 60, Edge 17 -->
@mcmoe
mcmoe / convert-svg-to-base64.js
Last active March 15, 2021 09:12
Convert an SVG to a base64 data image
let svgElement = document.getElementById('your_svg_id');
let svgString = new XMLSerializer().serializeToString(svgElement); // Serialize the svg to string
let decoded = unescape(encodeURIComponent(svgString)); // Remove any characters outside the Latin1 range
let base64 = btoa(decoded); // Use btoa to convert the svg to base64
let imgSource = `data:image/svg+xml;base64,${base64}`;
@mcmoe
mcmoe / aws-pyspark-jupyter.sh
Created August 26, 2019 22:50
How to set up pyspark and jupyter on aws ec2 instance
# Originally based on https://raw.githubusercontent.com/pzfreo/ox-clo/master/code/flintrock-jupyter.sh
sudo yum install gcc gcc-c++ -y
# sudo yum install python27-pip -y
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
#sudo pip-2.7 install jupyter
sudo pip2.7 install jupyter
export PYSPARK_DRIVER_PYTHON=jupyter
export PYSPARK_DRIVER_PYTHON_OPTS='notebook --no-browser'
@mcmoe
mcmoe / record-mediaElement.js
Last active June 26, 2020 15:32
Record a web mediaElement such as video
const stream = $0.captureStream();
const recorder = new MediaRecorder(stream);
const allChunks = [];
recorder.ondataavailable = (e) => allChunks.push(e.data);
recorder.start();
// recorder.pause();
// recorder.resume();
recorder.stop();
var fullBlob = new Blob(allChunks);
@mcmoe
mcmoe / swn-ox.md
Last active March 20, 2019 17:30
SWN

kali distribution

  • aircrack-ng
  • airmon-ng
  • airodump-ng
  • iwconfig
  • ifconfig
  • macchanger
  • dhclient
  • netdiscover
  • tail -f /var/log/messages
@mcmoe
mcmoe / stream-processing-etl.md
Last active November 30, 2018 17:39
Stream processing ETL