Skip to content

Instantly share code, notes, and snippets.

View guruguruman's full-sized avatar

Tomoyuki Kato guruguruman

  • Tokyo, Japan
View GitHub Profile
@guruguruman
guruguruman / UIView+ImageCapture
Created May 11, 2013 08:32
Capturing image from rendered view.
+ (UIImage *)viewAsImage:(UIView *)aView {
if (!aView) {
return nil;
}
UIGraphicsBeginImageContext(aView.bounds.size);
[aView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *aViewAsImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return aViewAsImage;
}
@guruguruman
guruguruman / UIWebView+StopBouncing
Created May 22, 2013 01:20
Disable bouncing on the other hand not disabling zooming and scrolling
UIWebView webView;
for (id subview in webView.subviews ) {
if([subview isKindOfClass: [UIScrollView class]]){
UIScrollView *scrollView = (UIScrollView *)subview;
scrollView.bounces = NO;
scrollView.scrollEnabled = YES;
scrollView.minimumZoomScale = 1.0f;
scrollView.bouncesZoom = NO;
scrollView.alwaysBounceVertical = NO;
@guruguruman
guruguruman / itunes-icon-generator.sh
Last active December 18, 2015 09:39
Create icons necessary for submitting the app to AppStore.
#!/bin/sh
################################################################################
#
# iTunes Icon Generator v 0.3
#
#
# This script requires ImageMagick.
# See link below for more defailed information:
@guruguruman
guruguruman / rm-git.sh
Created June 15, 2013 08:33
Remove '.git' from current repository
rm -rf `find ./ -type d -name .git ! -regex \.git/. -print`
#Remove '.gitignore' also.
rm -rf `find ./ -type d -name .gitignore ! -regex \.gitignore/. -print`
@guruguruman
guruguruman / apns-certificate-creator.sh
Last active August 29, 2015 14:02
Create pem file from certificate and keys on Apple Push Notification Service (APNs).sh
################################################################################
#
# Apple Push Notification Certificate Creator v 0.1
#
################################################################################
#After exporting APNs certificates for development as "apns_dev.p12" and the one for production as "apns_pro.p12"
# Development
openssl pkcs12 -clcerts -nokeys -out apns_dev_cert.pem -in apns_dev.p12
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
@guruguruman
guruguruman / onesignal.php
Created September 6, 2016 14:03
Managing to send push notification using OneSignal https://onesignal.com/
<?php namespace App\Services;
use GuzzleHttp\Client;
class OneSignal {
const API_URL_ADD_PLAYER = 'https://onesignal.com/api/v1/players';
const API_URL_CREATE_PUSH = 'https://onesignal.com/api/v1/notifications';
const DEVICE_TYPE_IOS = 0;
const DEVICE_TYPE_ANDROID = 1;
@guruguruman
guruguruman / Podfile
Last active January 31, 2017 15:56
Forcedly set CocoaPods Build Only Architecture to NO hooking`post_install`
post_install do |installer|
pods_project = installer.pods_project
pods_project.build_configurations.each do |configuration|
pods_project.build_settings(configuration.name)['ONLY_ACTIVE_ARCH'] = 'NO'
end
puts "Forcedly set CocoaPods project `Pods`’s `Build Only Architecture` to `NO`”
end
@guruguruman
guruguruman / TravisCI.swift
Last active September 18, 2018 01:43
Determining TravisCI enviroment
class TravisCI {
/*
* check whether test is running on TravisCI or not using TravisCI enviroment variables.
*
* as for TravisCI enviroment variables availables @see https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
*
*/
static var isRunningOnTravisEnviroment: Bool {
let isTravisEnviromentVariableName = "CI"
@guruguruman
guruguruman / ScrapingProxyProvider.php
Last active January 24, 2021 14:33
Rotate public listed proxies per each request in PHP.
<?php
/**
* A class which provide public listing proxies rotated when client request.
*/
Class ScrapingProxyProvider
{
// Proxies available.
private $proxyDatas = array();