Skip to content

Instantly share code, notes, and snippets.

@blinks
blinks / smtpcheck.py
Created January 16, 2009 16:35
Check if an email address exists without sending an email. Technique from: http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/
#!/usr/bin/env python
"""
Check that a particular email address exists.
Adam Blinkinsop <blinks@acm.org>
WARNING:
Checking email addresses in this way is not recommended, and will lead to
your site being listed in RBLs as a source of abusive traffic. Mail server
admins do like it when they get connections that don't result in email being
sent, because spammers often use this technique to verify email addresses.
@nalitzis
nalitzis / gist:2857519
Created June 2, 2012 09:34
Audio record
public static final int FREQUENCY = 44100;
public static final int CHANNEL_CONFIGURATION = AudioFormat.CHANNEL_CONFIGURATION_MONO;
public static final int AUDIO_ENCODING = AudioFormat.ENCODING_PCM_16BIT;
private void recordSound(){
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/"+RECORDED_FILENAME);
// Delete any previous recording.
if (file.exists())
private void mixFiles(){
try {
InputStream is1 = getResources().openRawResource(R.raw.test1);
List<Short> music1 = createMusicArray(is1);
InputStream is2 = getResources().openRawResource(R.raw.test2);
List<Short> music2 = createMusicArray(is2);
InputStream is3 = getResources().openRawResource(R.raw.test3);
List<Short> music3 = createMusicArray(is3);
@atermenji
atermenji / ExpandablePanel.java
Created November 8, 2012 11:06
A layout that expands/collapses its content by pressing on some view
package some.awesome.package;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.Transformation;
import android.widget.RelativeLayout;
@devunwired
devunwired / GifDecoder.java
Last active January 26, 2024 21:14
An optimized implementation of GifDecoder for Android devices.
/**
* Copyright (c) 2013 Xcellent Creations, Inc.
*
* 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:
@dominicthomas
dominicthomas / Android Screen Size
Created January 4, 2014 16:40
Android screen size with platform backwards compatibility.
private Point getScreenSize() {
Point size = new Point();
WindowManager w = getWindowManager();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
w.getDefaultDisplay().getSize(size);
}else{
Display d = w.getDefaultDisplay();
size.x = d.getWidth();
size.y = d.getHeight();
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.PendingIntent;
@niusounds
niusounds / FloatSeekBar.java
Created March 12, 2014 11:50
Custom SeekBar for Android that treat its value as float type. floatMax and floatMin can be negative value.
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.SeekBar;
public class FloatSeekBar extends SeekBar {
private float max = 1.0f;
private float min = 0.0f;
public FloatSeekBar(Context context, AttributeSet attrs, int defStyle) {
@niusounds
niusounds / LayeredImageView.java
Last active August 29, 2015 13:57
https://gist.github.com/niusounds/7905659 の後にまた作った。複数レイヤーを重ねて表示するView。Layerごとに色相・明るさ・コントラスト・透明度の指定が可能。
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Matrix;
@steveliles
steveliles / Foreground.java
Last active January 22, 2024 18:06
Class for detecting and eventing whether an Android app is currently foreground or background (requires API level 14+)
package com.sjl.util;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import java.util.List;