Skip to content

Instantly share code, notes, and snippets.

View mdakram's full-sized avatar
🎯
Focusing

Mohammad Akram mdakram

🎯
Focusing
View GitHub Profile
@jamztang
jamztang / LICENSE
Created January 6, 2012 18:28
Cancelable Scheduled Blocks in Objective-C
Copyright (c) 2013 Jamz Tang <jamz@jamztang.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@cocoahero
cocoahero / gist:3177422
Created July 25, 2012 17:33
OSMDroid MBTiles
XYTileSource MBTILESRENDER = new XYTileSource("mbtiles", ResourceProxy.string.offline_mode, 1, 20, 256, ".png", "http://example.org/");
DefaultResourceProxyImpl mResourceProxy = new DefaultResourceProxyImpl(this.getApplicationContext());
SimpleRegisterReceiver simpleReceiver = new SimpleRegisterReceiver(this.getActivity());
File f = new File(Environment.getExternalStorageDirectory(), "mymbtilesfile.mbtiles");
IArchiveFile[] files = { MBTilesFileArchive.getDatabaseFileArchive(f) };
MapTileModuleProviderBase moduleProvider = new MapTileFileArchiveProvider(simpleReceiver, MBTILESRENDER, files);
@Goles
Goles / CountryCodes.json
Created July 29, 2012 05:37
Country and Dial or Phone codes in JSON format
[{"name":"Israel","dial_code":"+972","code":"IL"},{"name":"Afghanistan","dial_code":"+93","code":"AF"},{"name":"Albania","dial_code":"+355","code":"AL"},{"name":"Algeria","dial_code":"+213","code":"DZ"},{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},{"name":"Andorra","dial_code":"+376","code":"AD"},{"name":"Angola","dial_code":"+244","code":"AO"},{"name":"Anguilla","dial_code":"+1 264","code":"AI"},{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG"},{"name":"Argentina","dial_code":"+54","code":"AR"},{"name":"Armenia","dial_code":"+374","code":"AM"},{"name":"Aruba","dial_code":"+297","code":"AW"},{"name":"Australia","dial_code":"+61","code":"AU"},{"name":"Austria","dial_code":"+43","code":"AT"},{"name":"Azerbaijan","dial_code":"+994","code":"AZ"},{"name":"Bahamas","dial_code":"+1 242","code":"BS"},{"name":"Bahrain","dial_code":"+973","code":"BH"},{"name":"Bangladesh","dial_code":"+880","code":"BD"},{"name":"Barbados","dial_code":"+1 246","code":"BB"},{"name":"Belarus","dial_code":"+375","
@kylehowells
kylehowells / UIScrollView-auto-height.mm
Created March 19, 2013 22:46
Automatically set the height of a UIScrollView to fit it's content.
CGFloat scrollViewHeight = 0.0f;
CGFloat scrollViewWidth = 0.0f;
for (UIView *view in scrollView.subviews) {
CGFloat height = (view.frame.size.height + view.frame.origin.y);
scrollViewHeight = ((height > scrollViewHeight) ? height : scrollViewHeight);
CGFloat width = (view.frame.size.width + view.frame.origin.x);
scrollViewWidth = ((width > scrollViewWidth) ? width : scrollViewWidth);
}
@keyboardr
keyboardr / FragmentUtils.java
Last active March 8, 2019 05:30
Utility method for getting the appropriate parent of a Fragment for a given callback interface.
import android.support.v4.app.Fragment;
public class FragmentUtils {
/**
* @param fragment
* The Fragment whose parent is to be found
* @param parentClass
* The interface that the parent should implement
* @return The parent of fragment that implements parentClass,
@tylerchesley
tylerchesley / gist:6198074
Created August 9, 2013 23:10
Function to recursively copy files from an Android asset directory
public void copyFileOrDir(String path) {
AssetManager assetManager = this.getAssets();
String assets[] = null;
try {
assets = assetManager.list(path);
if (assets.length == 0) {
copyFile(path);
} else {
String fullPath = "/data/data/" + this.getPackageName() + "/" + path;
File dir = new File(fullPath);
@jnagels
jnagels / AbstractActivity.java
Last active January 30, 2018 05:44
StartActivityForResult with nested Fragments
public abstract class AbstractActivity extends FragmentActivity implements FragmentUtils.ActivityForResultStarter
{
private SparseArray<Bundle> requests;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null)
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active June 4, 2024 04:16
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

/*
* Copyright (C) 2014 Chris Banes
*
* 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
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing