Skip to content

Instantly share code, notes, and snippets.

View ar-android's full-sized avatar
:octocat:
NULL

Ahmad Rosid ar-android

:octocat:
NULL
View GitHub Profile
@ar-android
ar-android / update.java
Created February 13, 2017 08:52 — forked from vuhung3990/update.java
File write, read, delete example ,must have READ, WRITE permissions
/**
* Write content into file
*
* @param path require WRITE_EXTERNAL
* @param contentString
*/
public static void writeContentFile(String path, String contentString) {
File file = new File(path);
if (!file.exists())
@ar-android
ar-android / get app info from the Manifest file
Created February 13, 2017 08:23 — forked from vuhung3990/get app info from the Manifest file
Get app info from the Manifest file
/**
* Get the "android:versionName" value from the Manifest file.
*
* @param context The current Context or Activity that this method is called from
* @return the application version string, or "Unknown" if versionName cannot be found for
* the given context.
*/
public static String getVersionName(Context context) {
String versionName;
try {
@ar-android
ar-android / RxBus.java
Created February 13, 2017 08:18 — forked from vuhung3990/RxBus.java
Rxjava 2 Bus
/**
* for send object between fragment, activity, service...
* REMEMBER: dispose if not in use to avoid leak memory
*/
public class RxBus<T> {
private static final String PREFIX = "$^%)@";
private static RxBus instance;
private PublishSubject<BusMessage<T>> subject = PublishSubject.create();
@ar-android
ar-android / default
Created February 9, 2017 13:56 — forked from dtomasi/default
Brew Nginx PHP7
server {
listen 80;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default.access.log main;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}
@ar-android
ar-android / readme.md
Created February 9, 2017 13:39 — forked from Niteshvgupta/readme.md
Install PHP7-compatible memcache on Mac OS X

1. Install PHP7 with brew

brew install php70

2. Install Memcache from source on PHP7 branch

git clone -b NON_BLOCKING_IO_php7 https://github.com/websupport-sk/pecl-memcache.git
cd pecl-memcache
phpize
./configure
make &amp;&amp; make install
@ar-android
ar-android / HijriCalendar.java
Created February 7, 2017 09:40 — forked from akmalxxx/HijriCalendar.java
Umm Al-Qura Java Calendar
/*
Umm Al-Qura Islamic Calendar
valid from 1356 AH (14 March 1937 CE) to 1500 AH (16 November 2077 CE).
Outside this interval, the converter will give erroneous results.
ported from javascript from:
http://www.staff.science.uu.nl/~gent0113/islam/ummalqura_converter.htm#top
*/
import java.util.Calendar;
@ar-android
ar-android / php-webscraping.md
Created December 25, 2016 18:34 — forked from anchetaWern/php-webscraping.md
web scraping in php

Have you ever wanted to get a specific data from another website but there's no API available for it? That's where Web Scraping comes in, if the data is not made available by the website we can just scrape it from the website itself.

But before we dive in let us first define what web scraping is. According to Wikipedia:

{% blockquote %} Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites. Usually, such software programs simulate human exploration of the World Wide Web by either implementing low-level Hypertext Transfer Protocol (HTTP), or embedding a fully-fledged web browser, such as Internet Explorer or Mozilla Firefox. {% endblockquote %}

Sexy transition between Activities (based on Twitter transition)

Looking at the officiel Twitter Android client I've noticed the slight cool & sexy transition between activities. I was curious to know how that worked so I had fun with android xml animations and ended up with that:

push_left_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
@ar-android
ar-android / colors.xml
Last active April 8, 2018 02:34 — forked from stkent/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_50">#fde0dc</color>
<color name="red_100">#f9bdbb</color>
<color name="red_200">#f69988</color>
<color name="red_300">#f36c60</color>
<color name="red_400">#e84e40</color>
<color name="red_500">#e51c23</color>
@ar-android
ar-android / gist:9c7b8a0446dea3af910b87213f6a5850
Created June 18, 2016 15:00 — forked from adrienne/gist:3180103
Haversine formula (PHP/MySQL)
/**
* Generates the string for the Haversine function. We assume that the `zipcode`, `latitude`,
* and `longitude` columns are named accordingly. We are also not doing much error-checking
* here; this is a simple text cruncher to make things prettier.
* We may also be integrating some extra SQL in, passed in via the $extra parameter
*
* @param string $table The table to search in
* @param float $lat The latitude part of the reference coordinates
* @param float $lng The longitude part of the reference coordinates
* @param int $radius The radius to search within