Skip to content

Instantly share code, notes, and snippets.

View richardleggett's full-sized avatar

Richard Leggett richardleggett

View GitHub Profile
@shankarshastri
shankarshastri / LearnXInYMinProtocolBuffer.proto
Last active February 2, 2024 03:18
Self-Explanatory Protocol Buffer Lang Guide (CheatSheet)
/*
* Self-Explanatory Protocol Buffer Lang Guide
*/
/*
* Why Protocol Buffers?
* Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.
* You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.
* Protocol Buffers are Schema Of Messages. They are language agnostic.
@vitalybe
vitalybe / sample.kt
Created March 20, 2017 13:16
Kotlin async sample in Android, including wrapping a legacy callback function
package jp.keita.kagurazaka.sample.coroutine
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.widget.Button
import android.widget.Toast
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.experimental.async
@blipinsk
blipinsk / ControllableAppBarLayout.java
Last active September 15, 2020 11:32
An extension of Android AppBarLayout, that allows to programatically change the CollapsibleToolbarLayout state
/**
* Copyright 2015 Bartosz Lipinski
*
* 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
@marcocarnazzo
marcocarnazzo / 030_update_platform_config.js
Last active May 31, 2019 15:31
Ionic/Cordova update platform config
#!/usr/bin/env node
/** This hook updates platform configuration files based on preferences and config-file data defined in config.xml.
Currently only the AndroidManifest.xml and IOS *-Info.plist file are supported.
See http://stackoverflow.com/questions/28198983/ionic-cordova-add-intent-filter-using-config-xml
Preferences:
1. Preferences defined outside of the platform element will apply to all platforms
2. Preferences defined inside a platform element will apply only to the specified platform
@JedWatson
JedWatson / API-Auth-With-KeystoneJS.md
Last active April 16, 2023 02:11
API Auth with KeystoneJS

To implement API authentication in KeystoneJS, you need the following:

For key based authentication

  • Middleware that validates the key in the request body or a header

For session based authentication

  • An endpoint that handles signin
  • An endpoint that handles signout
@seanKenkeremath
seanKenkeremath / Android Lollipop Widget Tinting Guide
Last active November 17, 2023 12:40
How base colors in Lollipop apply to different UI elements
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. To use the support version of these attributes, remove the android namespace. For instance, "android:colorControlNormal" becomes "colorControlNormal". These attributes will be propagated to their corresponding attributes within the android namespace for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------
* ripple effect (Lollipop only) -- "colorControlHighlight"
Status Bar:
------------
* background (Lollipop only) - "colorPrimaryDark"
@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
@JedWatson
JedWatson / KeystoneApiExample.md
Last active July 26, 2021 11:29
Example of how to scaffold API endpoints for Posts in a Keystone project (based on the yo keystone example).

This is an example of how to scaffold API endpoints to list / get / create / update / delete Posts in a Keystone website.

It's a modification of the default project created with the yo keystone generator (see https://github.com/JedWatson/generator-keystone)

Gists don't let you specify full paths, so in the project structure the files would be:

routes-index.js        -->    /routes/index.js         // modified to add the api endpoints
routes-api-posts.js    -->    /routes/api/posts.js     // new file containing the Post API route controllers
@mikermcneil
mikermcneil / sails_heroku_postgres.md
Last active February 19, 2016 07:23
How to configure a Sails.js app with a remote Postgres database hosted on Heroku

Using a PostgreSQL database on Heroku with Sails.js

The trick to setting up a Sails.js app with a remote Postgres database hosted on Heroku is all about SSL. Here's how you do it:

In your adapters.js file

Note: This is for Sails v0.9.x, the stable release at the time of this writing.

In Sails v0.10.x, the config/adapters.js file has been replaced with config/connections.js

@magnetikonline
magnetikonline / README.md
Last active December 22, 2021 17:13
Using Dnsmasq with Ubuntu 16.04LTS/14.04LTS/12.04LTS for virtual machine web application testing.

Using Dnsmasq with Ubuntu for VM web application testing

When running virtual machines under a Linux host system for testing web apps in various browsers (e.g. Internet Explorer), I found it rather tedious having to continually tweak the hosts file within each VM for the purpose of adding entries pointing back to the host machine's development web server address.

Instead the steps below will setup Dnsmasq on a Ubuntu 16.04LTS, 14.04LTS or 12.04LTS host machine for the purpose of serving both it's own DNS queries and that of virtual machine guests. Dnsmasq will parse the /etc/hosts file on your host machine where we will keep a single set of DNS entires to our test web application(s).