This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
IP_ADDRESS=$(adb shell ifconfig wlan0 | awk '{print $3}') | |
echo $IP_ADDRESS | |
adb tcpip 5555 | |
adb connect $IP_ADDRESS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *html = @"<div style='font: 18pt Helvetica-Light; color: #3498DB;'>Blue Text<span style='color: #AAAAAA;'>GreyText</span></div>"]; | |
NSData *htmlData = [html dataUsingEncoding:NSUTF8StringEncoding]; | |
NSMutableAttributedString *htmlAttributedString = [[NSMutableAttributedString alloc] initWithData:htmlData options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil]; | |
[label setAttributedText:htmlAttributedString]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// magic macros | |
#define N(x) [NSNumber numberWithInt: x] | |
#define B(x) [NSNumber numberWithBool: x] | |
NSMutableArray *array = [[NSMutableArray alloc] init]; | |
// long way | |
[array addObject:[NSNumber numberWithBool:YES]]; | |
[array addObject:[NSNumber numberWithInt:1]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-menu/core-menu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<link rel="import" href="../paper-checkbox/paper-checkbox.html"> | |
<link rel="import" href="../paper-button/paper-button.html"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'kotlin-kapt' | |
android { | |
... | |
} | |
dependencies { | |
... | |
// Room | |
compile 'android.arch.persistence.room:runtime:1.0.0-alpha1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
data class Person( | |
@PrimaryKey(autoGenerate = true) | |
val uid: Long, | |
val firstName: String = "", | |
val lastName: String = "" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Dao | |
interface PersonDao { | |
@Query("SELECT * FROM person") | |
fun getAllPeople(): Flowable<List<Person>> | |
@Insert | |
fun insert(person: Person) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Database(entities = arrayOf(Person::class), version = 1) | |
abstract class MyDatabase : RoomDatabase() { | |
abstract fun personDao(): PersonDao | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp : Application() { | |
companion object { | |
var database: MyDatabase? = null | |
} | |
override fun onCreate() { | |
super.onCreate() | |
MyApp.database = Room.databaseBuilder(this, MyDatabase::class.java, "we-need-db").build() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun addPerson(firstName: String, lastName: String) { | |
val person = Person(0, firstName, lastName) | |
Single.fromCallable { | |
MyApp.database?.personDao()?.insert(person) | |
}.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()).subscribe() | |
} |
OlderNewer