Skip to content

Instantly share code, notes, and snippets.

@olimortimer
olimortimer / gist:3032672
Created July 2, 2012 10:48
JS: jQuery Replace HREF Query String
// www.website.com/page?id=100
$('#pageLink').attr('href', $('#pageLink').attr('href').replace(/((\?|&)id\=)[0-9]*/, '$1' + '123'));
// www.website.com/page?id=123
@akhgupta
akhgupta / debug-CustomMultiDexApplication.java
Last active February 27, 2020 02:22
leakcanary-android-no-op - Class,Method not found solution
// app/src/debug/java/com/akhil/sampleapp/CustomMultiDexApplication.java
package com.akhil.sampleapp;
import android.support.multidex.MultiDexApplication;
import com.squareup.leakcanary.AndroidExcludedRefs;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
@shekibobo
shekibobo / README.md
Last active March 2, 2020 11:04
Android: Base Styles for Button (not provided by AppCompat)

How to create custom button styles using Android's AppCompat-v7:21

Introduction

AppCompat is an Android support library to provide backwards-compatible functionality for Material design patterns. It currently comes bundled with a set of styles in the Theme.AppCompat and Widget.AppCompat namespaces. However, there is a critical component missing which I would have thought essential to provide the a default from which we could inherit our styles: Widget.AppCompat.Button. Sure, there's Widget.AppCompat.Light.ActionButton, but that doesn't actually inherit from Widget.ActionButton, which does not inherit from Widget.Button, so we might get some unexpected behavior using that as our base button style, mainly because Widget.ActionButton strictly belongs in the ActionBar.

So, if we want to have a decently normal default button style related to AppCompat, we need to make it ourselves. Let's start by digging into the Android SDK to see how it's doing default styles.

Digging In

@claviska
claviska / vertically-centered-bootstrap-modals.js
Last active May 15, 2020 06:29
Vertically Centered Bootstrap Modals
/**
* Vertically center Bootstrap 3 modals so they aren't always stuck at the top
*/
$(function() {
function reposition() {
var modal = $(this),
dialog = modal.find('.modal-dialog');
@rudchenkos
rudchenkos / CenterCropDrawable.java
Created July 14, 2017 12:47
Maintain aspect ratio of bitmap drawables set as windowBackground on Android
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@donnfelker
donnfelker / android-19-circle.yml
Last active March 12, 2021 13:19
Sample CircleCI Configuration For an Android App
#
# Build configuration for Circle CI
#
general:
artifacts:
- /home/ubuntu/your-app-name/app/build/outputs/apk/
machine:
environment:
/*
Add a "How did you hear about us?" field Membership Checkout for new members only.
Display the field for admins-only in the profile and in the Members List CSV export.
*/
function my_pmpro_how_hear_fields() {
global $current_user;
if(class_exists( 'PMProRH_Field' ) && (!pmpro_hasMembershipLevel() || current_user_can( 'edit_users' ) ) ) {
pmprorh_add_checkout_box( 'additional', 'Additional Information' );
@nasirkhan
nasirkhan / git command.markdown
Last active May 12, 2022 03:17
`git` discard all local changes/commits and pull from upstream

git discard all local changes/commits and pull from upstream

git reset --hard origin/master

git pull origin master

@bshaffer
bshaffer / Drive.php
Created December 28, 2015 19:56
Google Drive API (v3) - PHP
<?php
/*
* Copyright 2010 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
*
@mbostock
mbostock / .block
Last active April 6, 2023 11:58
Epicyclic Gearing
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/epicyclic-gearing