Skip to content

Instantly share code, notes, and snippets.

View AKiniyalocts's full-sized avatar
🔭

Anthony Kiniyalocts AKiniyalocts

🔭
  • Big Nerd Ranch
  • Southgate, KY
View GitHub Profile
@AKiniyalocts
AKiniyalocts / SwipeDelete.java
Created September 29, 2015 23:41
Swipe to delete/archive items in a RecyclerView
mRecycler.setHasFixedSize(true);
mRecycler.setLayoutManager(new LinearLayoutManager(mActivity));
mRecycler.setAdapter(adapter);
mRecycler.getItemAnimator().setSupportsChangeAnimations(false);
Callback callback = new Callback() {
@Override
public int getMovementFlags(RecyclerView recyclerView, ViewHolder viewHolder) {
final int movementFlags;
if(viewHolder.getItemViewType() == UploadAdapter.VIEW_TYPE_ROW) {
@AKiniyalocts
AKiniyalocts / EdgeDecorator.java
Created December 8, 2016 21:00
Quick way to add padding to first and last item in recyclerview via decorators
package com.batterii.mobile.ui.component.decorators;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* Created by anthonykiniyalocts on 12/8/16.
*
* Quick way to add padding to first and last item in recyclerview via decorators
@AKiniyalocts
AKiniyalocts / com.ngrok.startup.plist
Created February 22, 2019 14:13
Start ngrok at startup as a LaunchDaemon. Place in your /Library/LaunchDaemons dir
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.ngrok.onstartup</string>
@AKiniyalocts
AKiniyalocts / ColorTransition.java
Created September 1, 2016 19:15
Status/Toolbar color transition animator
private void safeAnimateToolbarAndStatus(boolean reverse){
Integer colorFrom = reverse ? ContextCompat.getColor(this, R.color.limeade) : ContextCompat.getColor(this, R.color.b4);
Integer colorTo = reverse ? ContextCompat.getColor(this, R.color.b4) : ContextCompat.getColor(this, R.color.limeade);
Integer colorStatusFrom = reverse ? ContextCompat.getColor(this, R.color.limeade_pressed) : ContextCompat.getColor(this, R.color.dark_grey);
Integer colorStatusTo = reverse ? ContextCompat.getColor(this, R.color.dark_grey) : ContextCompat.getColor(this, R.color.limeade_pressed);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
@AKiniyalocts
AKiniyalocts / generate_icons.sh
Last active October 16, 2018 18:03
Generate resized icons for your android applications using imagemagick!
#!/bin/bash
# This requires imagemagick (a super awesome image tool)
# Install via: sudo apt-get install imagemagick
echo "Enter the path to the 512x512 icon"
read icon
mkdir "drawable-mdpi" "drawable-hdpi" "drawable-xhdpi" "drawable-xxhdpi" "drawable-xxxhdpi"
@AKiniyalocts
AKiniyalocts / GroupBy.swift
Created October 5, 2018 15:11
GroupBy.swift
extension Collection{
/**
* Groups elements of the original collection by the key returned by the given [keySelector] function
* applied to each element and returns a map where each group key is associated with a list of corresponding elements.
*
* The returned map preserves the entry iteration order of the keys produced from the original collection.
**/
public func groupBy<Value>(by keySelector:(Element) -> Value?) -> [Value?:[Element]]{
@AKiniyalocts
AKiniyalocts / Scrolling.m
Created September 26, 2016 14:47
Scrolling a tableview along with a cursor inside of a UITextView
-(void)textViewDidChangeSelection:(UITextView *)textView {
CGPoint cursorPosition = [textView caretRectForPosition:textView.selectedTextRange.start].origin;
[self.tableView scrollRectToVisible:CGRectMake(cursorPosition.x, cursorPosition.y
, textView.frame.size.width, textView.frame.size.height) animated:YES];
}
@AKiniyalocts
AKiniyalocts / DeCryptor.java
Created February 23, 2017 05:26 — forked from JosiasSena/DeCryptor.java
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/
@AKiniyalocts
AKiniyalocts / GrayscaleTransformation.java
Created January 15, 2016 18:31
Picasso Grayscale Transformation
/*
* Copyright (C) 2014 Square, 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
*
* Unless required by applicable law or agreed to in writing, software
@AKiniyalocts
AKiniyalocts / build_light.py
Created August 20, 2016 20:01
Python build light for greenhouse
import requests
import json
import time
import RPi.GPIO as GPIO
alive = True
while(alive):
headers = {'token': 'YOUR_TOKEN', 'release':'False'}
r = requests.get('https://app.greenhouseci.com/api/projects/YOUR_PROJECT_ID', headers)