Skip to content

Instantly share code, notes, and snippets.

View akhy's full-sized avatar

Akhyar Amarullah akhy

View GitHub Profile
@akhy
akhy / postly-usage.php
Created January 23, 2011 11:46
testing posterous PHP API
<?php
require('posterous-api.php');
$api = new PosterousAPI('email', 'password');
header('Content-type: text/html');
function pre_dump($var) {
echo "<pre>";
var_dump($var);
echo "</pre>";
@akhy
akhy / FTPuploader.php
Created June 24, 2012 10:38
PHP FTP Upload with Recursive Mkdir
<?php
/* PHP class for uploading file via FTP wich automatically make non-exist directory recursively */
<?php
class FTPUploader {
private static function make_directory($ftp_stream, $dir)
{
// if directory already exists or can be immediately created return true
if (FTPUploader::ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) return true;
This is an excerpt. Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat.
<!-- more -->
The rest of the content goes here.Duis aute irure dolor in reprehenderit
in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
@akhy
akhy / WeakTask.java
Created August 23, 2013 10:24
Wrapper abstract class for Android's built-in AsyncTask with weak reference to target object. For example you can do any image processing in background (asynchronously) and set the output to a garbage collectible ImageView once completed. If for some reason the ImageView isn't available anymore (e.g. due to user switching activity), the `applyOu…
package net.akhyar.android.async;
import java.lang.ref.WeakReference;
import android.os.AsyncTask;
public abstract class WeakTask<I, O, T> extends AsyncTask<Void, Void, O> {
protected final WeakReference<T> targetRef;
protected I input;
public WeakTask(I input, T target) {
@akhy
akhy / drawablegen.py
Created May 19, 2014 16:32
Android State XML Drawable Generator
"""
script by @akhy
generate android xml state drawables from png
"""
from sys import argv
from os import listdir
Verifying myself: My Bitcoin username is +akhyar. https://onename.io/akhyar
@akhy
akhy / DemoActivity.java
Last active September 9, 2015 07:50 — forked from markusfisch/DemoBubblesView.java
Draw text in a given rectangle and automatically wrap lines on a Android Canvas
package de.markusfisch.android.textrect;
import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@akhy
akhy / gist:91a8005cf0b6baa2854f
Created October 15, 2015 05:15 — forked from maxkandler/gist:5233150
Hide the iTerm2 Dock icon.
/usr/libexec/PlistBuddy -c 'Add :LSUIElement bool true' /Applications/iTerm.app/Contents/Info.plist
@akhy
akhy / delete_builds.groovy
Created October 27, 2015 08:14
Delete All Jenkins Build in a Job by Number Range
// Jenkins > Manage Jenkins > Script Console
Jenkins.instance.getItemByFullName('JobName').builds.findAll { it.number > 5 && it.number < 10 }.each { it.delete() }
@akhy
akhy / GravatarHelpers.kt
Last active September 26, 2017 14:57
Android Kotlin Helpers
// requires StringHelpers
enum class GravatarDefault(val str: String) {
ERROR_404 ("404"),
MYSTERY ("mm"),
IDENTICON ("identicon"),
MONSTER ("monsterid"),
WAVATAR ("wavatar"),
RETRO ("retro"),
BLANK ("blank"),