Skip to content

Instantly share code, notes, and snippets.

View msuzoagu's full-sized avatar

MUA msuzoagu

  • Space
View GitHub Profile

Status

This extension was developed as part of the jsonapi module for Drupal.

Introduction

It is possible for a server to have mixed success and error responses when dealing with a single or multiple entities at once. For instance, when generating collections of resource entities there is a chance that the GET operation results in a partial success. That is because each entity can generate errors independently from the other. In such scenarios the server MAY respond to the request with a partial success response.

Servers and clients MUST negotiate support for and use of the Partial Success extension as described in the base specification using partialsuccess as the name of the extension.

@msuzoagu
msuzoagu / Image.m
Created December 30, 2020 18:54
iOS: How to retrieve image dimensions without loading CGImage into memory
// This method requires ImageIO.framework
#import <ImageIO/ImageIO.h>
- (CGSize)sizeOfImageAtURL:(NSURL *)imageURL
{
// With CGImageSource we avoid loading the whole image into memory
CGSize imageSize = CGSizeZero;
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)imageURL, NULL);
if (source) {
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:(NSString *)kCGImageSourceShouldCache];
@msuzoagu
msuzoagu / README.md
Created November 21, 2020 23:56 — forked from derwiki/README.md
Ruby module that you can use in a `before_action` on sensitive controllers for which you'd like a usage audit trail

Adding an audit log to your Rails app

If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:

  • controller entry points with parameter values
  • permanent information about the user, like user_id
  • transient information about the user, like IP and user_agent

Using the Rails framework, this is as simple as adding a before_action to your admin controllers. Here’s a basic version that I’m using in production.

@msuzoagu
msuzoagu / ScaleAspectFitImageView.swift
Last active September 10, 2020 01:53 — forked from algal/ScaleAspectFitImageView.swift
UIImageView subclass that works with Auto Layout to express its desired aspect ratio
import UIKit
// known-good: Xcode 8.2.1
/**
UIImageView subclass which works with Auto Layout to try
to maintain the same aspect ratio as the image it displays.
This is unlike the usual behavior of UIImageView, where the
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
class Responder: NSObject {
@objc func segmentedControlValueChanged(_ sender: UISegmentedControl) {
UIView.animate(withDuration: 0.3) {
buttonBar.frame.origin.x = (segmentedControl.frame.width / CGFloat(segmentedControl.numberOfSegments)) * CGFloat(segmentedControl.selectedSegmentIndex)
}
//
// ParallaxHeader.swift
// MealPlanUI
//
// Created by Simon Ljungberg on 2017-11-15.
// Copyright © 2017 Filibaba. All rights reserved.
//
import Foundation
import UIKit
@msuzoagu
msuzoagu / sampleREADME.md
Created June 3, 2020 23:40 — forked from FrancesCoronel/sampleREADME.md
A sample README for all your GitHub projects.

FVCproductions

INSERT GRAPHIC HERE (include hyperlink in image)

Repository Title Goes Here

Subtitle or Short Description Goes Here

@msuzoagu
msuzoagu / application.rb
Created August 24, 2019 00:10 — forked from keighl/application.rb
Faster Rails asset precompilation via Capistrano .. just do it locally!
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
@msuzoagu
msuzoagu / deploy.rb
Created August 24, 2019 00:10 — forked from uhlenbrock/deploy.rb
Precompile assets locally for Capistrano deploy
load 'deploy/assets'
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}
end
require 'rubygems'
require 'pry'
$nodes = Hash.new
class Index
attr_reader :children, :name
attr_accessor :parent
def initialize(size, name, children = Array.new)