Skip to content

Instantly share code, notes, and snippets.

View webinista's full-sized avatar

Tiffany Brown webinista

View GitHub Profile
@webinista
webinista / RunAProxyOnAmazonEC2VPC.md
Last active April 27, 2024 12:21
Create a proxy server on an Amazon EC2 (VPC) instance

This will create a proxy server in whatever your availability zone your VPC is in. For me, that's us-east-1b. For you, that may be something different. Steps 10+ should more or less work regardless of your provider since those steps cover the setup and configuration of TinyProxy.

  1. Click the Launch Instance button.
  2. Choose Ubuntu Server 14.04 LTS (HVM), SSD Volume Type. This isn't strictly necessary. If you choose another OS, check its documentation for how to install new packages.
  3. On the Choose an Instance Type screen, select t2.micro. It's Free Tier eligible.
  4. Click the Next: ... buttons until you reach the Configure Security Group screen.
    • You may wish to reduce the amount of storage on the Add Storage screen. This is optional.
    • You may wish to add a tag on the Tag Instance screen. This is also optional.
  5. On the Configure Security Group screen:
  • Select Create a new security group.
@webinista
webinista / pelicanconf.py
Last active April 10, 2023 23:07
A Pelican configuration for having a home page and blog index or landing page.
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
# --------------------------------------
# Now compatible with Pelican 4.0.x!
# --------------------------------------
# Added by me
import time
@webinista
webinista / array.chunk.js
Last active March 29, 2023 23:02
Array.prototype.chunk: Splits an array into an array of smaller arrays containing `groupsize` members
/*
Split an array into chunks and return an array
of these chunks.
With kudos to github.com/JudeQuintana
This is an update example for code I originally wrote 5+ years ago before
JavaScript took over the world.
Extending native objects like this is now considered a bad practice, so use
@webinista
webinista / iso8601ToSeconds.php
Created December 13, 2018 03:46
PHP: Convert an ISO 8601 duration / date (Such as the one YouTube uses) interval to seconds
<?php
function iso8601ToSeconds($input) {
$duration = new DateInterval($input);
$hours_to_seconds = $duration->h * 60 * 60;
$minutes_to_seconds = $duration->i * 60;
$seconds = $duration->s;
return $hours_to_seconds + $minutes_to_seconds + $seconds;
}
@webinista
webinista / ChunkAlphabetically.php
Last active August 8, 2022 13:56
Split an array into chunks based on the first letter of one of its column values.
<?php
global $alpha_chunks;
# Initialize array
$alpha_chunks = array();
function chunkNames(&$value, $key, $letter) {
global $alpha_chunks;
const formatDate = ( dateStr ) => {
let returned = '';
if( 'Intl' in window ) {
const dateObj = new Date( dateStr );
const options = {
month: 'long',
timeZone: 'America/Los_Angeles',
day: 'numeric',
year: 'numeric'
};
Tested on macOS 11.3.1 with ffmpeg installed with homebrew
Use the h264_videotoolbox codec. -b:v is the bitrate flag. Using a higher
bitrate improves quality, but increases file size.
760k (include the k!) gives a nice balance between quality and file size.
ffmpeg -i input.gif -vcodec h264_videotoolbox -b:v 760k output.h264.mp4
@webinista
webinista / HowToFixPycURLErrorMacOS.md
Last active April 23, 2021 07:18
PycURL error: ConfigurationError: Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually.

Partly pulled from the comments here: pycurl/pycurl#526

May also be a fix for this error:

ImportError: pycurl: libcurl link-time ssl backend (none/other) is different from compile-time ssl backend (openssl)

If you try to install PycURL and receive this error:

@webinista
webinista / mode.php
Created June 22, 2019 02:54
find the mode of an array using PHP
function array_mode($$arr) {
/*
Count the frequency of occurrence of values in the array.
This will make each duration value into a key, with its frequency as the
value
*/
$counts = array_count_values($$arr);
/*
Get all of the count values and find the unique values, then sort them,
@webinista
webinista / isNumeric.js
Created May 29, 2019 23:22
isNumeric function for JavaScript
// Simple way to check whether a particular value is numeric. Saving it here so that I don't have to solve it twice.
const isNumeric = (value) => {
return !Number.isNaN(parseFloat(value,10));
}