Skip to content

Instantly share code, notes, and snippets.

View vicdecode's full-sized avatar
🎯
Focusing

Victor Ekpo vicdecode

🎯
Focusing
View GitHub Profile
// call this function on a cell via =ImportJSON("http://...") and data will show up verbatim
function ImportJSON(url) {
var response = UrlFetchApp.fetch(url);
var data = JSON.parse(response.getContentText());
if (!data.length) {
return [];
}
var rows = [];
@vicdecode
vicdecode / find-cell-value-and-delete-row.js
Created February 25, 2021 21:35 — forked from dDondero/find-cell-value-and-delete-row.js
Google Apps script function to delete rows based on value in cell.
function deleteRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
var rowsDeleted = 0;
for (var i = 0; i <= numRows - 1; i++) {
var row = values[i];
if (row[0] == 'delete' || row[0] == '') { // This searches all cells in columns A (change to row[1] for columns B and so on) and deletes row if cell is empty or has value 'delete'.
@vicdecode
vicdecode / wget.sh
Created January 26, 2021 20:55 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@vicdecode
vicdecode / lambda-aws-ssm-run-command-on-ec2-instance.py
Created November 13, 2020 03:30 — forked from lrakai/lambda-aws-ssm-run-command-on-ec2-instance.py
Run commands on EC2 instances using Lambda and Systems Manager (SendCommand)
import boto3
import botocore
import time
def handler(event=None, context=None):
client = boto3.client('ssm')
instance_id = 'i-07362a00952fca213' # hard-code for example
response = client.send_command(
@vicdecode
vicdecode / optimize-images.php
Created September 23, 2020 18:56
Script to optimize images using ImageMagick line command and ImageOptim (only OSX) cli...
<?php
/**
* Optimize Images
*
* Script to optimize images using ImageOptim and ImageMagic
* Usage: optimize-images.php /path/to/image/or/directory [options]
*
* Options:
* --max-width
* --quality
@vicdecode
vicdecode / repo-reset.md
Created August 24, 2020 04:52 — forked from heiswayi/repo-reset.md
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
"UserData": {
"Fn::Base64": { "Fn::Join":["", [
"#!/bin/bash -ex\n",
"apt-get update\n",
"apt-get -y install python-setuptools\n",
"mkdir aws-cfn-bootstrap-latest\n",
"curl https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz | tar xz -C aws-cfn-bootstrap-latest --strip-components 1\n",
"easy_install aws-cfn-bootstrap-latest\n",
"/usr/local/bin/cfn-init --stack ", { "Ref":"AWS::StackName" }, " --resource WebServer", " --region ", { "Ref": "AWS::Region" }, "\n",
"\n",
"UserData": {
"Fn::Base64": { "Fn::Join":["", [
"#!/bin/bash -ex\n",
"apt-get update\n",
"apt-get -y install python-setuptools\n",
"mkdir aws-cfn-bootstrap-latest\n",
"curl https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz | tar xz -C aws-cfn-bootstrap-latest --strip-components 1\n",
"easy_install aws-cfn-bootstrap-latest\n",
"/usr/local/bin/cfn-init --stack ", { "Ref":"AWS::StackName" }, " --resource WebServer", " --region ", { "Ref": "AWS::Region" }, "\n",
"\n",
@vicdecode
vicdecode / UbuntuCFinit.yaml
Created June 25, 2020 15:29 — forked from mmasko/UbuntuCFinit.yaml
Configure cfn-hup, cloudformation tools on ubuntu 18. Based on a gist from https://gist.github.com/kixorz/10194688. Written in YAML.
#This script will install the cloudformation helper work on Ubuntu 18.
#Some values are hard coded. Make sure to update where needed, or add to the parameters section.
#This would probably work on other distros, but I have not tested yet. Try it out.
#Just make sure to change things like apt to yum if trying on another OS.
Parameters:
EnvironmentSize:
Type: String
Default: t3.nano
AllowedValues:
- t3.nano
@vicdecode
vicdecode / UbuntuCFinit.yaml
Created June 25, 2020 15:29 — forked from mmasko/UbuntuCFinit.yaml
Configure cfn-hup, cloudformation tools on ubuntu 18. Based on a gist from https://gist.github.com/kixorz/10194688. Written in YAML.
#This script will install the cloudformation helper work on Ubuntu 18.
#Some values are hard coded. Make sure to update where needed, or add to the parameters section.
#This would probably work on other distros, but I have not tested yet. Try it out.
#Just make sure to change things like apt to yum if trying on another OS.
Parameters:
EnvironmentSize:
Type: String
Default: t3.nano
AllowedValues:
- t3.nano