Skip to content

Instantly share code, notes, and snippets.

View AlexHedley's full-sized avatar
💭
⚀⚁⚂⚃⚄⚅

Alex Hedley AlexHedley

💭
⚀⚁⚂⚃⚄⚅
View GitHub Profile
@AlexHedley
AlexHedley / Activity_Main.xml
Last active August 29, 2015 14:14
Image Button - Set Image
<ImageButton
...
android:src="@drawable/NAME"
android:background="@null"
android:tint="@android:color/white"
/>
//Transparent Background add "@null"
@AlexHedley
AlexHedley / AndroidManifest.xml
Last active August 29, 2015 14:14
Creating a Preference Activity in Android
<application
......./>
<activity
android:name=".PrefsActivity"
android:theme="@android:style/Theme.Black.NoTitleBar" >
</activity>
</application>
@AlexHedley
AlexHedley / Activity.java
Last active August 29, 2015 14:14
Android - Custom URL Scheme
//XXX://settings/?d=hello
Intent intent = getIntent();
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
Uri data = intent.getData();
Log.d(TAG, "URI Data: " + data.toString());
String d = data.getQueryParameter("d");
Log.d(TAG, "d:" + d);
}
@AlexHedley
AlexHedley / Macro.m
Last active August 29, 2015 14:15
Pull to Refresh
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
@AlexHedley
AlexHedley / 0_reuse_code.js
Last active August 29, 2015 14:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@AlexHedley
AlexHedley / ButtonGradient.m
Last active August 29, 2015 14:18
Button Gradient
CAGradientLayer* gradientLayer = [[CAGradientLayer alloc] init];
[gradientLayer setBounds:[buttonTest bounds]];
[gradientLayer setPosition:
CGPointMake([buttonTest bounds].size.width/2, [buttonTest bounds].size.height/2)];
[gradientLayer setColors:
[NSArray arrayWithObjects:
(id)[[UIColor blueColor] CGColor],
(id)[[UIColor cyanColor] CGColor], nil]];
[[buttonTest layer] insertSublayer:gradientLayer atIndex:0];
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellIdentifier = [[NSUserDefaults standardUserDefaults] stringForKey:@"Theme"];
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
return cell.bounds.size.height;
}
@AlexHedley
AlexHedley / Export.m
Last active August 29, 2015 14:20
Export SQLite to CSV
FMDatabase *db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
[db open];
FMResultSet *results = [db executeQuery:@"SELECT * FROM tblScores"];
//CHCSVWriter *csvWriter = [[CHCSVWriter alloc] initForWritingToCSVFile:[NSHomeDirectory() stringByAppendingPathComponent:@"demo.csv"]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *document = [[NSString alloc] initWithFormat:@"%@/demo.csv", documentsDirectory];
CHCSVWriter *csvWriter = [[CHCSVWriter alloc] initForWritingToCSVFile:document];
while([results next]) {
#import <MessageUI/MessageUI.h>
@interface ViewController : UIViewController <MFMailComposeViewControllerDelegate>
@AlexHedley
AlexHedley / date.sql
Created May 10, 2015 08:46
SQLite Help
SELECT * FROM Table ORDER BY date(dateColumn) DESC