Skip to content

Instantly share code, notes, and snippets.

View steveliles's full-sized avatar

Steve Liles steveliles

View GitHub Profile
@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);};
image: my-docker-hub/my-pipeline-container
options:
docker: true
pipelines:
branches:
production:
- step:
caches:
image: node:9.3.0
pipelines:
branches:
production:
- step:
caches:
- node
script:
# build and test the app
@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 / react-numerals-test.md
Last active May 9, 2017 10:44
Javascript developer, technical test

Technical Test - React Developer

Test Part I

The numeric system represented by Roman numerals originated in ancient Rome and remained the usual way of writing numbers throughout Europe well into the Late Middle Ages. Numbers in this system are represented by combinations of letters from the Latin alphabet. Roman numerals, as used today, are based on seven symbols:

| Symbol | I | V | X | L | C | D | M | | --------------------------------------------| | Value | 1 | 5 | 10 | 50 | 100 | 500 | 1000 |

@steveliles
steveliles / Foreground.java
Last active July 21, 2016 07:50
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
/**
* Copyright 2015 Steve Liles
*
* 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
@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;
@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
package androidconcurrency.chapter4;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
/**
* Adds support for isChangingConfigurations when minSdkVersion
* targets api-levels below 11.
*
* Unfortunately onSaveInstanceState is invoked AFTER onPause,