Skip to content

Instantly share code, notes, and snippets.

View bagpack's full-sized avatar

bagpack bagpack

View GitHub Profile
@bagpack
bagpack / gist:7319308
Last active December 27, 2015 11:29
Hooking buildType Tasks.
android.buildTypes.all{ theBuildType ->
task ("${theBuildType.name}MyCustomTask"){
dependsOn "compile${theBuildType.name.capitalize()}"
doLast{
println theBuildType.debuggable
}
}
}
@bagpack
bagpack / gist:7319338
Last active December 27, 2015 11:29
gradle with android plugin
android.applicationVariants.all { variant ->
variant.generateBuildConfig.dependsOn "preprocess${variant.name}"
}
@bagpack
bagpack / gist:7839754
Last active September 5, 2017 05:52
run script with android plugin. launching application after gradle install${buildType}.
android.buildTypes.all{ theBuildType ->
def buildType = theBuildType.name
def taskName = "run${theBuildType.name.capitalize()}"
task ("${taskName}") {
dependsOn "install${theBuildType.name.capitalize()}"
doLast {
def xml = new File(buildDir.toString() + "/manifests/${buildType}/AndroidManifest.xml")
def manifest = new XmlParser(false,true).parseText(xml.getText())
def ns = new groovy.xml.Namespace("http://schemas.android.com/apk/res/android", "ns")
@bagpack
bagpack / gist:b96f719bb3e7c138f3de
Last active August 29, 2015 14:07
ZF2:Assign variables to view models.
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$sharedEvents = $eventManager->getSharedManager();
// PostDispatch (priorityが1以上ならpre, 未満ならpost)
$sharedEvents->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH, [$this, 'injectDispatch'], -100);
}
@bagpack
bagpack / gist:cfb67fa31c8e5a863750
Created May 15, 2015 02:32
Twitter Kit For Android:Support media/upload
public class TwitterUploadClient {
private final String UPLOAD_ENDPOINT = "https://upload.twitter.com";
MediaService service;
final RestAdapter adapter;
TwitterUploadClient(TwitterAuthConfig authConfig, Session session, SSLSocketFactory sslSocketFactory, ExecutorService executorService) {
if(session == null) {
throw new IllegalArgumentException("Session must not be null.");
@bagpack
bagpack / .eslintrc
Last active August 29, 2015 14:22
My first webpack.
{
"parser": "babel-eslint",
"rules": {
"no-extra-strict": 0,
"dot-notation": 0,
"quotes": 0
},
"globals": {
"global": true,
},
@bagpack
bagpack / playbook.yml
Last active August 29, 2015 14:22
My first ansible.
---
- hosts: all
sudo: yes
tasks:
- name: Add repository 'epel-repo'
yum: name=http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm state=present
- name: Add repository 'rpmforge-repo'
yum: name=http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm state=present
@bagpack
bagpack / UIImage+Snapshot.m
Last active September 9, 2015 01:21 — forked from anthonycastelli/UIImage+Snapshot.m
Snapshotting on iOS
+ (UIImage *)snapshotView:(UIView *)view {
UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, [[UIScreen mainScreen] scale]); //0
[view drawViewHierarchyInRect:view.frame afterScreenUpdates:YES];
UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return snapshot;
}
+ (UIImage *)snapshot {
CGSize imageSize = CGSizeZero;
@bagpack
bagpack / simple.agent.js
Last active April 20, 2016 06:28
simple promisify XMLHttpRequest
(function(global, Promise) {
'use strict';
var DEFAULT_TIMEOUT = 10000; // millisec
// Class ------------------------------------------------
function SimpleAgent(params) {
params = !params || {};
this.timeout = params.timeout || DEFAULT_TIMEOUT;
this.headers = params.headers || {};
@bagpack
bagpack / Dockerfile-mysql
Last active February 21, 2020 11:01
docker-lamp-development-environment(Apache,PHP,MySQL Stacks)
FROM mysql:5.6.23
COPY ./my.cnf /etc/mysql/my.cnf
COPY ./docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/