Skip to content

Instantly share code, notes, and snippets.

View dexterogieosahon's full-sized avatar

Dexter Ogie-osahon dexterogieosahon

View GitHub Profile

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@dexterogieosahon
dexterogieosahon / AppHelper.java
Created January 6, 2017 16:56 — forked from anggadarkprince/AppHelper.java
Upload file with Multipart Request Volley Android
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import java.io.ByteArrayOutputStream;
/**
* Sketch Project Studio
* Created by Angga on 12/04/2016 14.27.
*/
public class AppHelper {
@dexterogieosahon
dexterogieosahon / MultipartRequest.java
Created January 7, 2017 07:22 — forked from ishitcno1/MultipartRequest.java
volley multipart request, post file image, android.
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyLog;
import org.apache.http.HttpEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
@dexterogieosahon
dexterogieosahon / PhonecallReceiver.java
Created January 11, 2017 19:39 — forked from Mariovc/ PhonecallReceiver.java
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@dexterogieosahon
dexterogieosahon / Log.java
Created January 11, 2017 19:39 — forked from Mariovc/Log.java
Android Log class improving the original class to do not log when it is on production and without tag needed
import com.antena3.floox.BuildConfig;
/**
* Author: Mario Velasco Casquero
* Date: 27/08/2015
*/
public class Log {
private static final int MAX_LOG_TAG_LENGTH = 23;
private static final boolean logsAllowed = BuildConfig.DEBUG;
@dexterogieosahon
dexterogieosahon / ShareUtils.java
Created January 11, 2017 19:39 — forked from Mariovc/ShareUtils.java
Utility to share text and url on Facebook, Twitter and Whatsapp
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
@dexterogieosahon
dexterogieosahon / AspectRatioImageView.java
Created January 11, 2017 19:40 — forked from JakeWharton/AspectRatioImageView.java
ImageView that respects an aspect ratio applied to a specific measurement.
// Copyright 2012 Square, Inc.
package com.squareup.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/** Maintains an aspect ratio based on either width or height. Disabled by default. */
public class AspectRatioImageView extends ImageView {
@dexterogieosahon
dexterogieosahon / ImagePickerWithCrop.java
Created January 11, 2017 19:40 — forked from Mariovc/ImagePickerWithCrop.java
[Android] Advanced utility for picking an image from Gallery/Camera with Android Intents (Crop included)
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
@dexterogieosahon
dexterogieosahon / PreferencesManager.java
Created January 11, 2017 19:40 — forked from Mariovc/PreferencesManager.java
[Android] Manager to store data in SharedPreferences
import android.content.Context;
import android.content.SharedPreferences;
import com.google.gson.Gson;
/**
* Author: Mario Velasco Casquero
* Date: 30/09/2015
* Email: m3ario@gmail.com
*/