Skip to content

Instantly share code, notes, and snippets.

View steveliles's full-sized avatar

Steve Liles steveliles

View GitHub Profile
image: my-docker-hub/my-pipeline-container
options:
docker: true
pipelines:
branches:
production:
- step:
caches:
@steveliles
steveliles / Foreground.java
Created April 20, 2014 15:30
Class for detecting and eventing the foreground/background state of an Android app - API-level 14+
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;
@steveliles
steveliles / VerticalViewPager.java
Last active December 23, 2019 23:34
A vertical-paging version of ViewPager - the existing implementations that I found did not work for me. This is a simple hack-up of the standard v4 support ViewPager to convert its horizontal behaviour to vertical.
package com.sjl.views;
/*
* Copyright (C) 2011 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
@steveliles
steveliles / embed.jsx
Created February 12, 2018 17:14
embedly with react.js
import React, {Component} from 'react'
import { connect } from 'react-redux'
// one-time init of the embedly platform.js, hidden behind
// typeof check not to blow up on server-side render
if (typeof window !== 'undefined') {
let init_embedly = function(w,d){
var id='embedly-platform', n = 'script';
if (!d.getElementById(id)){
w.embedly = w.embedly || function() {(w.embedly.q = w.embedly.q || []).push(arguments);};
@steveliles
steveliles / mentions-with-draft.js
Created September 20, 2017 12:47
Implementing @Mention's in Draft.js
const { Editor, EditorState, CompositeDecorator, Modifier, SelectionState } = Draft;
const getMentionPosition = () => {
const range = window.getSelection().getRangeAt(0).cloneRange();
const rect = range.getBoundingClientRect();
return { top: rect.bottom, left: rect.left }
}
const getCaretPosition = (editorState) => {
return editorState.getSelection().getAnchorOffset()
@steveliles
steveliles / Foreground.java
Last active January 22, 2024 18:06
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;