Skip to content

Instantly share code, notes, and snippets.

View jpiche's full-sized avatar

Joseph J. Piché jpiche

View GitHub Profile
import UIKit
public protocol KeyboardChangeDelegate {
func doKeyboardAnimateTo(toValue: CGFloat)
}
open class KeyboardChangeViewController: UIViewController {
override open func viewWillAppear(_ animated: Bool) {
@jpiche
jpiche / EditTextUtils.java
Created January 20, 2016 19:55
Change cursor color on an EditText
protected static void setCursorDrawableColor(EditText editText, int color) {
try {
Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
fCursorDrawableRes.setAccessible(true);
int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
Field fEditor = TextView.class.getDeclaredField("mEditor");
fEditor.setAccessible(true);
Object editor = fEditor.get(editText);
Class<?> clazz = editor.getClass();
Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
//
// Threading.swift
//
import Foundation
private let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
func async(closure: () -> ()) {
dispatch_async(dispatch_get_global_queue(priority, 0), closure)
}
@jpiche
jpiche / .gitignore
Created October 30, 2014 18:00
Xcode.gitignore
# Mac files
.DS_Store
# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
@jpiche
jpiche / gist:a15e625368216eb0baa6
Last active November 23, 2015 23:27
UIKeyboardWillChangeFrameNotification method
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillChange:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
}
- (void)viewWillDisappear:(BOOL)animated
@jpiche
jpiche / my.cnf
Created April 12, 2013 19:46
Beyond what is shipped by default in MySQL or MariaDB my.cnf config files, I always make sure to put these in and edit memory settings appropriately.
[mysqld]
bind-address = 127.0.0.1
skip-name-resolve
default_storage_engine = InnoDB
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 8M
innodb_file_per_table = 1
innodb_open_files = 400
innodb_io_capacity = 400
innodb_flush_method = O_DIRECT
<?php
class Box
{
private $_private_data;
private $_changed_keys = array();
public function __construct(Array $data)
{
$this->_private_data = $data;
@jpiche
jpiche / .vimrc
Last active October 13, 2015 23:27
A basic vimrc, perhaps for servers.
set nocp noswapfile
syn on
set ai bs=indent,eol,start et sm is ic scs ruler
set ts=2 sts=2 sw=2
set guioptions-=T
set mouse=
set number
autocmd FileType php set ts=4 sts=4 sw=4
@jpiche
jpiche / play.conf
Last active October 8, 2015 00:47
Play Framework 2.2 upstart conf
description "start and stop play framework"
version "1.0"
author "Joseph J. Piché"
start on runlevel [2345]
stop on runlevel [06]
env USER=site
env GROUP=nginx
env PLAY_HOME="/home/site/appname"
@jpiche
jpiche / .tmux.conf
Created July 16, 2012 14:51
Tmux config file
# remap prefix to Control + a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# quick pane cycling