Skip to content

Instantly share code, notes, and snippets.

View pratamawijaya's full-sized avatar

Pratama Nur Wijaya pratamawijaya

View GitHub Profile

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@pratamawijaya
pratamawijaya / database.php
Last active August 29, 2015 14:27 — forked from jonmarkgo/database.php
Twilio SMS Verification Example
<?php
$db_host='dbserver';
$db_name='dbame';
$db_user='dbuser';
$db_passwd='dbpassword';
mysql_connect($db_host, $db_user, $db_passwd)
or die('Could not connect: ' . mysql_error());
mysql_select_db($db_name) or die('Could not select database');
@pratamawijaya
pratamawijaya / whatsapp-image-compression
Last active August 29, 2015 14:27 — forked from akshay1188/whatsapp-image-compression
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
// http://stackoverflow.com/questions/17535918/aes-gets-different-results-in-ios-and-java
- (NSData *)AES256EncryptWithKey:(NSString *)key {
// 'key' should be 32 bytes for AES256, will be null-padded otherwise
char keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused)
bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)
// fetch key data
[key getCString:keyPtr maxLength:sizeof(keyPtr) encoding:NSUTF8StringEncoding];
@pratamawijaya
pratamawijaya / include_list_viewpager.xml
Last active September 8, 2015 03:58 — forked from iPaulPro/include_list_viewpager.xml
CollapsingToolbarLayout with TabLayout
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2015 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
@pratamawijaya
pratamawijaya / InstagramOAuthActivity.java
Last active February 9, 2016 12:01 — forked from j4rs/InstagramOAuthActivity.java
Android activity to authenticate using Instagram client side auth.
/**
*
*/
package com.bwuit.app.activities;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
@pratamawijaya
pratamawijaya / CharacterCountErrorWatcher.java
Created September 28, 2015 08:03 — forked from slightfoot/CharacterCountErrorWatcher.java
Material Design - Text field input - Over/under character or word count (android.support.design.widget.TextInputLayout) http://www.google.com/design/spec/patterns/errors.html#errors-user-input-errors
import android.graphics.Color;
import android.support.design.widget.TextInputLayout;
import android.text.Editable;
import android.text.Layout;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextWatcher;
import android.text.style.AlignmentSpan;
import android.text.style.ForegroundColorSpan;
@pratamawijaya
pratamawijaya / RxFirebase.java
Created October 26, 2015 13:10 — forked from gsoltis/RxFirebase.java
RxJava Bindings for Firebase
package com.firebase.client;
import com.firebase.client.core.Constants;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Func1;
import rx.subscriptions.Subscriptions;
public class RxFirebase {
@pratamawijaya
pratamawijaya / simple-git-workflow.md
Created November 18, 2015 09:31 — forked from leesmith/simple-git-workflow.md
Simple Git Workflow For Continuous Delivery

Simple Git Workflow For Continuous Delivery

Workflow guidelines:

  • master branch is always production-ready, deployable, 100% green test suite
  • New development is done on feature branches, with frequent rebasing onto master
  • Clean commit history by preferring to rebase instead of merge (git pull is configured to automatically rebase)

rebase workflow

Workflow