Skip to content

Instantly share code, notes, and snippets.

View stargatex's full-sized avatar
🎯
Focusing

Lahiru J stargatex

🎯
Focusing
View GitHub Profile
@ndfred
ndfred / gist:775896
Created January 12, 2011 08:53
Saving a login and a password to the iOS keychain
- (void)setCredentialsFromKeychain {
NSMutableDictionary *query = [NSMutableDictionary dictionary];
NSDictionary *result = nil;
[query setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass];
[query setObject:kLCSessionManagerKeychainSubscriptionServiceKey forKey:(id)kSecAttrService];
[query setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnAttributes];
[query setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnData];
if (SecItemCopyMatching((CFDictionaryRef)query, (CFTypeRef *)&result) == errSecSuccess) {
@bartprokop
bartprokop / POM.xml
Created June 9, 2012 20:35
JPA 2.0 for GAE with Maven
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!-- Project description -->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>bart.prokop.name</groupId>
<artifactId>parent-pom</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
@erikdoe
erikdoe / CCMKeychainHelper.m
Last active March 17, 2023 18:06
It took me way too long to wade through Keychain documentation and examples, but, finally, I got to a sane implementation of a basic Objective-C interface for managing internet passwords in Keychain. This is from my CCMenu project (http://ccmenu.org).
#import "CCMKeychainHelper.h"
@implementation CCMKeychainHelper
+ (BOOL)setPassword:(NSString *)password forURLString:(NSString *)aString error:(NSError **)errorPtr
{
return [self setPassword:password forURL:[NSURL URLWithString:aString] error:errorPtr];
}
+ (BOOL)setPassword:(NSString *)password forURL:(NSURL *)aURL error:(NSError **)errorPtr
@aniXification
aniXification / NetworkChangeReceiver
Created June 30, 2013 18:12
Check internet connection change via Broadcast Receiver in background. #android
public class NetworkChangeReceiver extends BroadcastReceiver{
private static final String LOG_TAG = "NetworkChangeReceiver";
private boolean isConnected = false;
@Override
public void onReceive(Context context, Intent intent) {
Log.v(LOG_TAG, "Receieved notification about network status");
isNetworkAvailable(context);
}
@iainconnor
iainconnor / Android Studio .gitignore
Created January 24, 2014 20:20
A .gitignore for use in Android Studio
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
@vtanathip
vtanathip / gitignore-android-studio-list
Last active May 26, 2021 09:12
Git Ignore files list that should use in Android Studio Projects
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@burgalon
burgalon / AccountAuthenticator.java
Last active July 15, 2023 08:29
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
@sheharyarn
sheharyarn / CardSwingAnimations.md
Last active March 16, 2021 08:04
Swing Animations for CardViews in Android

SwingUp Animations for Android

I use these snippets to implement Google Now Card appear-animations on Android. Add these two files to your res/anim/ folder and add a swing_anim_time integer to your values:

<!-- res/values/strings.xml -->
<integer name="swing_anim_time">750</integer>
@koesie10
koesie10 / ApiModule.java
Created October 3, 2015 07:40
Retrofit 1 error handling behaviour in Retrofit 2
// Dagger 1 example
@Module(
complete = false,
library = true
)
public final class ApiModule {
@Provides
@Singleton
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.package.name" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"