Skip to content

Instantly share code, notes, and snippets.

@castorflex
castorflex / URLUtils.java
Created September 5, 2013 13:39
Simple snippet building a docs.google URL if you have a webview with a pdf, doc, etc URL.
public class URLUtils {
private static final String fGOOGLE_DOC_URL = "http://docs.google.com/gview?embedded=true&url=%s";
private enum GoogleDocType{
PDF(".pdf"), DOC(".doc"), XLS(".xls"), DOCX(".docx"), XLSX(".xlsx");
private String mSuffix;
GoogleDocType(String suffix){
mSuffix = suffix;
@sascha
sascha / bump_build_number.sh
Last active September 7, 2016 06:56
Xcode build script to automatically bump the build number and convert it to hexadecimal
# This script is based on the script provided at http://stackoverflow.com/questions/9258344/xcode-better-way-of-incrementing-build-number
# The only difference is, that it uses hexadecimal build numbers instead of decimal ones.
# For instructions on how to use this script, see the link above.
#!/bin/sh
if [ $# -ne 1 ]; then
echo usage: $0 plist-file
exit 1
/**
* Copyright 2013 Bo Wang
*
* 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
@lacek
lacek / update-jenkins.sh
Created August 23, 2015 14:36
Update Jenkins on Mac OS X
#!/bin/bash
DEFAULT_URL=http://updates.jenkins-ci.org/current/latest/jenkins.war
TMP_PATH=/tmp/jenkins.war
APP_PATH=/Applications/Jenkins/jenkins.war
PLIST_PATH=/Library/LaunchDaemons/org.jenkins-ci.plist
url=${1-$DEFAULT_URL}
echo 'Downloading WAR package...'
[ -f Cartfile.resolved ]; then
CARTFILE_CHANGED=`git diff --stat $(GIT_PREVIOUS_SUCCESSFUL_COMMIT) $(GIT_COMMIT) | grep '\|' | awk '{print $$1}' | grep Cartfile.resolved`
if test "$(CARTFILE_CHANGED)" ; then
echo "## STEP: Updating Carthage"
carthage bootstrap --platform iOS --no-use-binaries
else
echo "## Carthage is up to date"
fi
else
echo "## STEP: Installing Carthage Dependencies"
@hameno
hameno / publishMavenLocal.gradle
Last active November 26, 2019 13:54 — forked from Robyer/maven-publish-helper-usage.gradle
Gradle script for publishing Android library to local Maven repository using maven-publish plugin. With dependencies (also handling transitive: false and custom exclude rules), including sources and javadoc.
apply plugin: 'maven-publish'
project.afterEvaluate {
def androidExtension = project.extensions.findByName("android")
if (androidExtension.hasProperty('libraryVariants')) {
androidExtension.libraryVariants.all { final variant ->
task("${variant.name}Javadoc", type: Javadoc) {
description "Generates Javadoc for ${variant.name}."
failOnError = false
source = variant.javaCompile.source
@cbess
cbess / gist:4444374
Last active March 16, 2020 06:10
Xcode Delete and Duplicate Selected Lines
<key>Customized</key>
<dict>
<key>Delete Line</key>
<string>selectLine:, deleteBackward:</string>
<key>Duplicate Lines</key>
<string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
<key>Duplicate Current Line</key>
<string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
</dict>
@sheharyarn
sheharyarn / RVEmptyObserver.java
Created May 13, 2017 13:55
Set Empty Layout for RecyclerViews in Android
/**
* Custom implementation of AdapterDataObserver to show empty layouts
* for RecyclerView when there's no data
*
* Usage:
*
* adapter.registerAdapterDataObserver(new RVEmptyObserver(recyclerView, emptyView));
*/
public class RVEmptyObserver extends RecyclerView.AdapterDataObserver {
private View emptyView;
@chairco
chairco / leetcode.md
Last active February 20, 2021 08:34
leecode, 30 分鐘來解題。多多用腦身體好,就從解決 leetcode 問題開始吧!
@ethanhuang13
ethanhuang13 / detect-string-language.swift
Created March 23, 2017 03:46
Detect string language with Swift
//: Playground - noun: a place where people can play
//
// The result is not guaranteed to be accurate. Typically, the function requires 200-400 characters to reliably guess the language of a string.
// Reference: [CFStringTokenizerCopyBestStringLanguage(_:_:)](https://developer.apple.com/reference/corefoundation/1542136-cfstringtokenizercopybeststringl)
//
import Foundation
extension String {
func guessLanguage() -> String {