Skip to content

Instantly share code, notes, and snippets.

View xrubioj's full-sized avatar

Xavier Rubio Jansana xrubioj

View GitHub Profile
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@emil2k
emil2k / Connectivity.java
Last active December 22, 2023 06:03
Android utility class for checking device's network connectivity and speed.
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@romannurik
romannurik / CharsPerLineActivity.java
Last active December 17, 2021 03:15
Demonstrates how to identify and avoid line-length issues with TextView. The measure, or characters per line, of a block of text plays a key role in how comfortable it is to read (sometimes referred to as readability). A widely accepted optimal range for a text block's measure is between 45 and 75 characters. This code demonstrates two phases of…
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@nolanlawson
nolanlawson / completion-for-gradle.md
Last active April 5, 2024 07:43
Gradle tab completion for Bash. Works on both Mac and Linux.

Gradle tab completion script for Bash

A tab completion script that works for Bash. Relies on the BSD md5 command on Mac and md5sum on Linux, so as long as you have one of those two commands, this should work.

Usage

$ gradle [TAB]
@chrisbanes
chrisbanes / FloatLabelLayout.java
Last active March 15, 2024 06:39
FloatLabelLayout
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@chrisbanes
chrisbanes / SystemUiHelper.java
Last active March 2, 2024 18:57
SystemUiHelper
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@digitaljhelms
digitaljhelms / post-rewrite
Created September 22, 2014 14:49
Git hook to call `git submodule update` automatically.
#!/bin/sh
echo "[post-rewrite hook: $1]"
# quick script to call "git submodule update" automatically if the
# .gitmodules file is changed
changedfiles=( `git diff-tree --no-commit-id --name-only HEAD@{1} HEAD` )
if [[ "${changedfiles[*]}" =~ ".gitmodules" ]]; then
echo "initializing & updating submodule(s)"
@dazwin
dazwin / pullrequests.py
Last active November 16, 2020 14:03
Looks at all pull requests across all repos in a Bitbucket (http://bitbucket.org) team and is able to decline if there are not enough reviewers and/or merge if all/required participants have approved
#!/usr/bin/env python
# -*- coding: utf-8
# Example usage:
# BB_USERNAME=myuser BB_PASSWORD=###### python pullrequests.py --owner=myteam --auto-merge --auto-decline
import urllib2
import base64
import json
import re
@gauntface
gauntface / toggle-remote-styles.js
Last active March 12, 2020 12:56
A book marklet to toggle styles.
javascript:(function(){var styles = document.querySelectorAll('link[rel=\'stylesheet\']'); for (var s = 0; s < styles.length; s++) {styles[s].mediax = styles[s].media;if (styles[s].media === 'only x') { styles[s].media = styles[s].mediax; } else if (styles[s].media !== 'print') {styles[s].media = 'only x';}}})();
@bclymer
bclymer / HttpClient.kt
Created January 21, 2016 19:00
Kotlin Realm Primitive Arrays Workaround
val realmIntArrayType = object : TypeToken<RealmIntArray>() {}.type
val realmLongArrayType = object : TypeToken<RealmLongArray>() {}.type
val realmStringArrayType = object : TypeToken<RealmStringArray>() {}.type
val gson = GsonBuilder()
.setExclusionStrategies(object : ExclusionStrategy {
override fun shouldSkipClass(clazz: Class<*>?): Boolean {
return false
}
override fun shouldSkipField(f: FieldAttributes?): Boolean {