- Express ideas directly in code; §3.2.
- Define classes to represent application concepts directly in code; §3.2.
- Use concrete classes to represent simple concepts and performance-critical components; §3.2.1.
- Avoid ‘‘naked’’ new and delete operations; §3.2.1.2.
- Use resource handles and RAII to manage resources; §3.2.1.2.
- Use abstract classes as interfaces when complete separation of interface and implementation is needed; §3.2.2.
- Use class hierarchies to represent concepts with inherent hierarchical structure; §3.2.4. Section 3.5 Advice 85
This file contains hidden or 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
// Check if no view has focus: | |
View view = this.getCurrentFocus(); | |
if (view != null) { | |
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); | |
imm.hideSoftInputFromWindow(view.getWindowToken(), 0); | |
} |
This file contains hidden or 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
gradle.ext.dagger2Version = "2.2" | |
gradle.ext.retrofit2Version = "2.1.0" | |
gradle.ext.ageraVersion = "1.1.0" | |
gradle.ext.okHttp3Version = "3.4.1" | |
gradle.ext.rxJavaVersion = "1.1.8" | |
gradle.ext.rxAndroidVersion = "1.2.1" |
This file contains hidden or 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: 'com.android.application' | |
apply plugin: 'me.tatarka.retrolambda' | |
apply plugin: 'com.neenbedankt.android-apt' | |
// If enabled jack, You should use annotationProcessor dependency scope instead of apt. See http://android-developers.blogspot.fi/2016/05/android-studio-22-preview-new-ui.html (search for annotationProcessor) | |
// annotationProcessor "com.google.dagger:dagger-compiler:$gradle.dagger2Version | |
android { | |
compileSdkVersion gradle.ext.compileSdkVersion | |
buildToolsVersion gradle.ext.buildToolsVersion |
This file contains hidden or 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
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:2.1.2' | |
// dagger2 | |
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' |
This file contains hidden or 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
ndk { | |
platformVersion = 9 | |
moduleName = 'plasma' | |
toolchain = 'clang' | |
CFlags.addAll(['-Wall']) | |
ldLibs.addAll(['m', 'log', 'jnigraphics']) | |
} |
This file contains hidden or 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
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) { | |
std::string ret; | |
int i = 0; | |
int j = 0; | |
unsigned char char_array_3[3]; | |
unsigned char char_array_4[4]; | |
while (in_len--) { | |
char_array_3[i++] = *(bytes_to_encode++); | |
if (i == 3) { |
This file contains hidden or 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
#define RED "\x1B[31m" | |
#define GRN "\x1B[32m" | |
#define YEL "\x1B[33m" | |
#define BLU "\x1B[34m" | |
#define MAG "\x1B[35m" | |
#define CYN "\x1B[36m" | |
#define WHT "\x1B[37m" | |
#define RESET "\x1B[0m" | |
printf("This is " RED "red" RESET " and this is " BLU "blue" RESET "\n"); |
This file contains hidden or 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
/*- | |
* Copyright (c) 1991, 1993 | |
* The Regents of the University of California. All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions | |
* are met: | |
* 1. Redistributions of source code must retain the above copyright | |
* notice, this list of conditions and the following disclaimer. | |
* 2. Redistributions in binary form must reproduce the above copyright |
This file contains hidden or 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 Timer { | |
public: | |
Timer() : beg_(clock_::now()) {} | |
void reset() { beg_ = clock_::now(); } | |
double elapsed() const { | |
return std::chrono::duration_cast<second_>(clock_::now() - beg_).count(); | |
} | |
private: | |
typedef std::chrono::high_resolution_clock clock_; |