Skip to content

Instantly share code, notes, and snippets.

View aminelaadhari's full-sized avatar

Amine Laadhari aminelaadhari

  • thefabulous.co
View GitHub Profile
@romannurik
romannurik / CheatSheet.java
Last active May 16, 2023 13:42
Android helper class for showing cheat sheets (tooltips) for icon-only UI elements on long-press. This is already default platform behavior for icon-only action bar items and tabs. This class provides this behavior for any other such UI element.
/*
* Copyright 2012 Google Inc.
*
* 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
@Mattieuga
Mattieuga / MyViewController.mm
Last active October 12, 2015 09:28
Code snippet for Twilio/Parse sample app
// Call our Cloud Function that sends an SMS with Twilio
[PFCloud callFunctionInBackground:@"inviteWithTwilio"
withParameters:@{ number : phoneNumber }
block:^(id object, NSError *error) {
[[[UIAlertView alloc] initWithTitle:@"Invite Sent!"
message:@"Your SMS invitation has been sent!";
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil, nil] show];
}];
@imminent
imminent / AccountUtils.java
Created November 12, 2012 19:55
Utility to retrieve user profile on Android device
/**
* A collection of authentication and account connection utilities. With strong inspiration from the Google IO session
* app.
* @author Dandré Allison
*/
public class AccountUtils {
/**
* Interface for interacting with the result of {@link AccountUtils#getUserProfile}.
*/
@timgshi
timgshi / main.js
Created November 22, 2012 00:42
This uses Parse Cloud Code to attempt to save instagram relationships from an instagram json object.
// Use Parse.Cloud.define to define as many cloud functions as you want.
// For example:
Parse.Cloud.define("hello", function(request, response) {
response.success("Hello world!");
});
Parse.Cloud.define("receiveinstagram", function(request, response) {
var photo = request.params.data;
var query = new Parse.Query("instagram_moment");
@dokkaebi
dokkaebi / gist:4173446
Created November 30, 2012 02:39
Android: Set listview item heights to fill available listview height.
public class MyAdapter extends SimpleCursorAdapter {
// constructor, etc...
@Override
public void bindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
// Stretch list item height if there are too few to fill the content area.
ListView listView = getListView();
@ZenGardenDubai
ZenGardenDubai / aftersave
Created December 18, 2012 12:35
Add User to Role in AfterSave Callback
Parse.Cloud.afterSave(Parse.User, function(request) {
Parse.Cloud.useMasterKey();
query = new Parse.Query(Parse.Role);
query.equalTo("name", "normalUser");
query.first ( {
success: function(object) {
object.relation("users").add(request.user);
@kwhinnery
kwhinnery / main.js
Last active December 11, 2015 09:59
var twilio = require('twilio'),
cloudConfig = require('cloud/cloudConfig');
//Initialize the Twilio cloud module
twilio.initialize(cloudConfig.accountSid, cloudConfig.authToken);
//Define a cloud function to send an SMS
Parse.Cloud.define('sendLink', function(request, response) {
//format phone number
var n = request.params.phoneNumber.replace(/[^\d.]/g, '');
@justinsaliba
justinsaliba / include-layout.xml
Last active December 13, 2015 20:08
A Simple Loading Screen for Android Applications - Snippets for a blog at http://bytesizedandroid.blogspot.com/2013/02/a-simple-loading-screen-for-android.html
<include layout="@layout/loading_layout" />
@naholyr
naholyr / A_Sample.md
Last active December 14, 2015 11:48
A dumb event emitter service for Angular, primary usage is to allow transparent communication between controllers → http://jsfiddle.net/NuCjC/1/

Sample usage on JSFiddle

Disclaimer

This may be a dumb solution, you'd better use $rootScope.$on(event, handler) and $rootScope.$emit(event, args…) and not use a third-party service.

My solution will bring you:

  • support for off() if you really want to clean up your event handlers
  • maybe a conceptually better solution than using scopes, as with a service you make yourself independant from your view
@scottdweber
scottdweber / ExpandingCircleAnimationDrawable.java
Created March 22, 2013 02:14
An example showing how to create and use a Drawable that animates.
package com.example.manualanimation;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.view.animation.AnimationUtils;