Skip to content

Instantly share code, notes, and snippets.

View palumbo's full-sized avatar

Joseph Palumbo palumbo

View GitHub Profile
@palumbo
palumbo / in_array.php
Last active May 7, 2017 05:08
in_array example
<?php $numbers = [8, 23, 15, 42, 16, 5]; ?>
<?php # is 15 in array?
$ans = in_array("15", $numbers);
if ($ans == 1) {
echo "true"; # returns true
} else {
echo "false";
};
@palumbo
palumbo / UISwitches.swift
Last active October 8, 2017 21:40
Swift 4 solution for controlling 2 UISwitch elements and UILabels
//
// ViewController.swift
// Basic
//
// Created by Joseph Palumbo on 10/8/17.
// Copyright © 2017 Joseph Palumbo. All rights reserved.
//
import UIKit
//
// ViewController.swift
// Say Hello
//
// Created by Joseph Palumbo on 10/8/17.
// Copyright © 2017 Joseph Palumbo. All rights reserved.
//
import UIKit
@palumbo
palumbo / mrrExtractor.gs
Last active October 16, 2017 05:04
Google Script that reformats pasted in text from HostOps and creates a chart showing revenue over a period of time
function onOpen(e) {
// create custom menu
var ui = SpreadsheetApp.getUi();
ui.createMenu('Functions')
.addItem('Extract MRR', 'mrrExtractor')
.addItem('Reset Sheet', 'resetSheet')
.addToUi();
};
@palumbo
palumbo / hn.html
Last active November 4, 2017 16:38
web page that pulls the top stories from hacker news firebase using jQuery
<html>
<head>
<title>Hacker News</title>
<link rel="stylesheet" href="../main.css" type="text/css" />
<style type="text/css" media="screen">
#gist {
display: none;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
@palumbo
palumbo / zapier.js
Created January 10, 2018 01:06
JS for pulling CloudWatch alarm data into zapier
/*
EXAMPLE:
input.messy_data_from_previous_trigger_or_action = 'This is a single string of text that contains lots of different data. {"name": "John"} Sometimes when you are building a Zap, you will need to pull out one piece of data from a long, messy string of text. {"email": "[email protected]"} Thankfully, you can use the "Formatter by Zapier" app or the "Code by Zapier" app to extract the information you need.'
*/
function extract_piece_of_data(entire_string_of_text, characters_before_desired_data, characters_after_desired_data) {
var desired_data_with_stuff_after_it = entire_string_of_text.substr(entire_string_of_text.indexOf(characters_before_desired_data) + characters_before_desired_data.length);
@palumbo
palumbo / email.gs
Created May 28, 2018 22:25
Code that emails notifications from my Customer Success Tracker made in Google Sheets
function onEdit(e) {
// setting common variables
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var user = Session.getActiveUser();
var cell = sheet.getActiveCell().getA1Notation();
var val = sheet.getActiveCell().getValue();
var range = sheet.getRange("A1:Z182"); // creates range needed to use getCell() later
var url = ss.getUrl();
@palumbo
palumbo / wordpress.sh
Last active September 22, 2024 15:25
AWS EC2 Wordpress bootstrap script
#!/bin/bash
yum install httpd php-mysql -y
amazon-linux-extras install -y php7.3
cd /var/www/html
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
cp -r wordpress/* /var/www/html/
rm -rf wordpress
rm -rf latest.tar.gz
chmod -R 755 wp-content
import sys
import requests
import os
from urllib.request import urlopen
from bs4 import BeautifulSoup
# unpack argv
script, url = sys.argv
# get URL
@palumbo
palumbo / moveRows.gs
Created May 29, 2022 14:17
Google Apps Script that copies rows to a new sheet based on a cell value.
function onOpen(e) {
let ui = SpreadsheetApp.getUi();
ui.createMenu('🤖 Automation Tools')
.addItem('Move reps to individual sheets', 'moveRows')
.addToUi();
};
function moveRows() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getActiveSheet();