Skip to content

Instantly share code, notes, and snippets.

View andermoran's full-sized avatar

Ander Moran andermoran

  • Microsoft
View GitHub Profile
@andermoran
andermoran / sendMessageThruTerminal.sh
Created April 12, 2017 18:41
Allows sending of an iMessage thru terminal. Can't send message to self, yet...
#!/bin/sh
USAGE=$'Usage: imessage <number> <text>\nExample: message 9121231234 \"Hello!\"'
if [ "$#" -ne "2" ]; then
echo "$USAGE"
exit 1;
fi
exec <"$0" || exit;
for i in {1..12} # Reads the first x lines of the program
do
read v
@andermoran
andermoran / grabnumber.cpp
Created January 2, 2017 19:31
grabs user's phone number (works on el capitan)
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <cstdio>
#include <memory>
#include <stdexcept>
#include <fstream>
#include <iostream>
using namespace std;
string exec(const char* cmd); // Used for executing terminal commands in c++
string getPassword(); // Prompts the user for their system password and checks to see if it is the correct password
// If the password is correct, it returns it in a string
int main(int argc, char *argv[]) { // Example implementation of getPassword()
# Prompts user for password until the password is correct
# Useful for programs where you must get the correct password from the user in order to execute a command
passOk="false"
while [ "$passOk" != "true" ]
do
echo -n "Password: "
read password # Grabs username
if [[ $(echo $password | sudo -k -S echo valid) = "valid" ]] &>/dev/null; then
echo "Correct password"