Skip to content

Instantly share code, notes, and snippets.

View KevinTCoughlin's full-sized avatar

Kevin Coughlin KevinTCoughlin

View GitHub Profile
@jasonseney
jasonseney / git-review
Last active August 29, 2015 14:02
Quickly jump to a remote branch and sync. Usage: `git review some-branch-name`
#!/usr/bin/env bash
# Checks out to headless state of a remote branch and syncs
# Usage: `git review some-branch-name`
red='\033[31m'
green='\033[32m'
NC='\033[0m' # No Color
echo -e "${green}Stashing current changes...${NC}";
@KevinTCoughlin
KevinTCoughlin / themes-debug.xml
Last active September 8, 2015 12:01 — forked from dlew/themes-debug.xml
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>
@msluyter
msluyter / gist:1925069
Created February 27, 2012 16:22
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
anonymous
anonymous / linus.c
Created January 22, 2013 22:35
In response to: http://meta.slashdot.org/story/12/10/11/0030249/linus-torvalds-answers-your-questions An explanation of the two different types of singly-linked list removal explained by Linus Torvalds, using the variable names introduced here: http://stackoverflow.com/questions/12914917/
#include <stdio.h>
typedef struct ll {
int value;
struct ll *next;
} ll;
void print_list(ll *list_head)
{
@ericleong
ericleong / SaveAndParseResponse.java
Created January 5, 2016 21:00
Method to simultaneously save and parse the response from an OkHttp ResponseBody.
@SuppressWarnings({ "unchecked", "rawtypes" })
private static <T> Pair<String, T> saveAndParseResponse(final ResponseBody response, final TypeReference type)
throws IOException {
final Buffer sink = new Buffer();
final StringBuilder builder = new StringBuilder();
final Charset charset = responseCharset(response);
response.source().readAll(new ForwardingSink(sink) {
@rharter
rharter / AppRater.java
Created September 5, 2014 14:51
A simple utility class to manage rating (or really anything) call to action display.
package com.ryanharter.android.util;
import android.content.Context;
import android.content.SharedPreferences;
/**
* Keeps track of the number of app launches, and days since first launch, and
* provides an easy way to determine whether you should show a rating prompt
* or not.
*/
@OlavHN
OlavHN / gist:ff73b104bb25e5e08a51
Last active June 28, 2017 19:27
React render to polymer components!
<!doctype html>
<html>
<head>
<!-- Web Component Polyfill for old browsers -->
<script src="https://www.polymer-project.org/platform.js"></script>
<!-- Release candidate of next React -->
<script src="http://fb.me/react-with-addons-0.12.0-rc1.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.0-rc1.js"></script>
<!-- Import a web component -->
@mrowl
mrowl / ThingsAdapter.java
Created February 28, 2015 16:57
Shim between RecyclerView.Adapter and ParseAdapter
public class ThingsAdapter extends RecyclerView.Adapter<ThingsAdapter.ViewHolder> {
private ParseQueryAdapter<ParseObject> parseAdapter;
private ViewGroup parseParent;
private ThingsAdapter thingsAdapter = this;
public ThingsAdapter(Context context, ViewGroup parentIn) {
parseParent = parentIn;
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_50">#fde0dc</color>
<color name="red_100">#f9bdbb</color>
<color name="red_200">#f69988</color>
<color name="red_300">#f36c60</color>
<color name="red_400">#e84e40</color>
<color name="red_500">#e51c23</color>
<color name="red_600">#dd191d</color>
<color name="red_700">#d01716</color>
@irace
irace / BIWebViewDelegate.m
Created September 10, 2012 02:51
JavaScript/native bridge for iOS's UIWebView
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
NSString *urlString = [[request URL] absoluteString];
if ([urlString hasPrefix:@"js:"]) {
NSString *jsonString = [[[urlString componentsSeparatedByString:@"js:"] lastObject]
stringByReplacingPercentEscapes];
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;