Blog Posts

Delete Duplicate Photo Albums in XCode Objective-C

I accidentally created too many photo albums with the same name, I needed a solution to delete it all without manually deleting it. There’s probably an easier way to do this if you know it let me know. NSString *albumName = @"SOME ALBUM"; __block PHAssetCollection *albumCollection = [[PHAssetCollection alloc] init]; PHFetchOptions *albumOptions = [[PHFetchOptions alloc] init]; [albumOptions setPredicate:[NSPredicate predicateWithFormat:@"estimatedAssetCount >= 0"]]; PHFetchResult *userAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:albumOptions]; dispatch_async(dispatch_get_main_queue(), ^{ [userAlbums enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop)

Continue Reading

Send Email Attachments With MailJet

I didn’t use the mailjet wrapper, instead I used curl to call the request. Here’s an example code to send a pdf attachment file with mailjet. I believe its similar to the code in their documentation. function sendMailjetAttachment($email = '', $name = '', $subject = '', $message = '', $file = '') { $mailjetApiKey = ''; $mailjetApiSecret = ''; $pdfBase64 = base64_encode(file_get_contents($file)); $data = [ 'Messages' => [ [ 'From' => [ 'Email' => "[email protected]", 'Name' => "From Email" ],

Continue Reading

How To Disable selectWoo If It’s Not Working In WooCommerce

I have this issue with selectWoo and WooCommerce where if you change the country the states select field doesn’t hide. I didn’t have time to debug it or find a solution so I just removed it completely by de-registering the selectWoo scripts and styles. The quick fix (place this in your themes functions.php): add_action( 'wp_enqueue_scripts', function () { if ( class_exists( 'woocommerce' ) ) { wp_dequeue_style( 'selectWoo' ); wp_deregister_style( 'selectWoo' ); wp_dequeue_script( 'selectWoo' ); wp_deregister_script( 'selectWoo' ); } } );

Continue Reading

Force Item To Add To Cart On Page Load In WordPress WooCommerce Cart

This probably isn’t useful for anyone but I’m currently using WooCommerce with WordPress and I needed a solution where a product item would automatically be added to cart on page load. The code below is what I came up with, this code will also force the user to have only 1 quantity of the item. To use, fill in the $product_id variable with your product id and paste the code in your child themes functions.php file. add_action( 'wp_loaded', function() {

Continue Reading

Site Footer

Sliding Sidebar


Nice to meet you, my name is Ryan and I build stuff for the web. Welcome to my website where you can learn about me and my interests.