Skip to content

Instantly share code, notes, and snippets.


MUA msuzoagu

  • Space
View GitHub Profile
msuzoagu / experience.rb
Created Mar 3, 2021 — forked from mamantoha/experience.rb
Rails API Filtering and Sorting
View experience.rb
# app/models/experience.rb
# == Schema Information
# Table name: experiences
# id :integer not null, primary key
# title :string
# description :text
# created_at :datetime not null
View JSON API Partial


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


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 / Image.m
Created Dec 30, 2020 — forked from shpakovski/Image.m
iOS: How to retrieve image dimensions without loading CGImage into memory
View Image.m
// 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 /
Created Nov 21, 2020 — forked from derwiki/
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 / ScaleAspectFitImageView.swift
Last active Sep 10, 2020 — forked from algal/ScaleAspectFitImageView.swift
UIImageView subclass that works with Auto Layout to express its desired aspect ratio
View ScaleAspectFitImageView.swift
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
View CustomSegmentedControl.swift
//: 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)
View ParallaxHeader.swift
// ParallaxHeader.swift
// MealPlanUI
// Created by Simon Ljungberg on 2017-11-15.
// Copyright © 2017 Filibaba. All rights reserved.
import Foundation
import UIKit
msuzoagu /
Created Jun 3, 2020 — forked from FrancesCoronel/
A sample README for all your GitHub projects.


INSERT GRAPHIC HERE (include hyperlink in image)

Repository Title Goes Here

Subtitle or Short Description Goes Here

msuzoagu / application.rb
Created Aug 24, 2019 — forked from keighl/application.rb
Faster Rails asset precompilation via Capistrano .. just do it locally!
View application.rb
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
msuzoagu / deploy.rb
Created Aug 24, 2019 — forked from uhlenbrock/deploy.rb
Precompile assets locally for Capistrano deploy
View deploy.rb
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}