Skip to content

Instantly share code, notes, and snippets.

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"rekognition:DetectLabels",
"rekognition:GetCelebrityRecognition",
"rekognition:GetContentModeration",
@jawngee
jawngee / functions.php
Last active February 2, 2019 04:02
Imgix parameters
<?php
add_filter('ilab-imgix-filter-parameters', function($params, $size, $id, $meta) {
// $params contains the imgix parameters
// $size is either an array of two numbers for width/height, or it is the name of a size
// $id is the attachment ID
// $meta is the attachment's meta
if (!is_array($size) && ($size == 'download')) {
// Full size
@jawngee
jawngee / google-cors-policy.json
Created January 30, 2019 09:19
Google Cloud Storage CORS Sample Policy
[
{
"origin": ["https://yourdomain.com"],
"responseHeader": ["*"],
"method": ["GET", "HEAD", "DELETE", "POST", "PUT", "OPTIONS"],
"maxAgeSeconds": 3600
}
]
@jawngee
jawngee / functions.php
Created January 15, 2019 17:56
Fix for MyListing Theme
<?php
function fixJobAttachmentURL($parentPostID, $url) {
global $wpdb;
$path = parse_url($url, PHP_URL_PATH);
$imageName = basename($path);
$query = $wpdb->prepare("select ID from {$wpdb->posts} where guid like %s and post_type='attachment' and post_parent=%d order by ID desc limit 1", '%'.$wpdb->esc_like($imageName), $parentPostID);
$attachmentID = $wpdb->get_var($query);
@jawngee
jawngee / functions.php
Created December 18, 2018 02:17
Disable things
<?php
add_filter('ilab_s3_can_calculate_srcset', function($true) {
return false;
});
add_filter('ilab_media_cloud_filter_content', function($true) {
return false;
});
@jawngee
jawngee / functions.php
Last active December 17, 2018 09:46
Disable srcset generation
<?php
// Add to your functions.php
// Disable SRCSET
add_filter('wp_get_attachment_image_attributes', function($attr) {
if (isset($attr['sizes'])) {
unset($attr['sizes']);
}
if (isset($attr['srcset'])) {
@jawngee
jawngee / imgix-policy.json
Created December 12, 2018 17:07
Imgix IAM Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket",
"s3:GetBucketLocation"
],
@jawngee
jawngee / cors.json
Last active July 19, 2021 16:26
Sample Media Cloud S3 Bucket CORS Configuration
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"HEAD"
@jawngee
jawngee / policy.json
Created October 30, 2018 09:01
Sample Media Cloud S3 IAM Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:DeleteObjectTagging",
"s3:ListBucketMultipartUploads",
"s3:DeleteObjectVersion",
"s3:ListBucket",
@jawngee
jawngee / loopingVideo.m
Created August 11, 2018 15:21
Background Looping Video
@import AVFoundation;
@import AVKit;
AVQueuePlayer *player = [[AVQueuePlayer alloc] init];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame = self.bounds;
playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.layer addSublayer:playerLayer];