Skip to content

Instantly share code, notes, and snippets.

View raulsilvamx's full-sized avatar

Raul Silva raulsilvamx

  • Korero
  • Monterrey, Nuevo León, Mexico
  • 23:22 (UTC -06:00)
  • X @raulsilvamx
View GitHub Profile
@ashleydw
ashleydw / nginx.conf
Last active January 8, 2024 15:32
Laravel nginx conf file
server {
listen 80 default_server;
server_name example.com www.example.com;
access_log /srv/www/example.com/logs/access.log;
error_log /srv/www/example.com/logs/error.log;
root /srv/www/example.com/public;
index index.php index.html;
@swinton
swinton / AESCipher.py
Last active April 30, 2023 05:48
Encrypt & Decrypt using PyCrypto AES 256 From http://stackoverflow.com/a/12525165/119849
#!/usr/bin/env python
import base64
from Crypto import Random
from Crypto.Cipher import AES
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
@iOSDigital
iOSDigital / gist:8379249
Created January 12, 2014 01:14
UIImage doesn't have a tint colour. UIImageView does. This little method returns a UIImage, tinted with a UIColor. It's useful for things like table icons, where the image view is read only. Means you don't have to create loads of PNGs in different colours.
-(UIImage *)imageWithTint:(UIImage *)image andTintColor:(UIColor *)tintColor {
UIImage *imageNew = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *imageView = [[UIImageView alloc] initWithImage:imageNew];
imageView.tintColor = tintColor;
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, NO, 0.0);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@anaglik
anaglik / gist:6055542
Last active January 5, 2018 10:57
Example of "CIMaskToAlpha" filter's usage.
CIContext *context = [CIContext contextWithOptions:nil];
UIImage *entryImage = [UIImage imageNamed:@"someImage.png"];
CIImage *image = [CIImage imageWithCGImage:[entryImage CGImage]];
CIFilter *filter = [CIFilter filterWithName:@"CIMaskToAlpha"];
[filter setValue:image forKey:kCIInputImageKey];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
CGImageRef cgImage = [context createCGImage:result fromRect:[result extent]];
UIImage *newImage = [UIImage imageWithCGImage:cgImage scale:[entryImage scale] orientation:UIImageOrientationUp];
@snikch
snikch / gist:3661188
Created September 6, 2012 23:16
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}