_
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
buildscript { | |
ext.kotlin_version = '1.1.2-3' | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:2.3.2' | |
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
classpath "io.realm:realm-gradle-plugin:3.1.2" |
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
0 info it worked if it ends with ok | |
1 verbose cli [ '/usr/local/Cellar/node/8.6.0/bin/node', | |
1 verbose cli '/usr/local/bin/npm', | |
1 verbose cli 'install', | |
1 verbose cli '-g', | |
1 verbose cli 'npm@latest' ] | |
2 info using npm@5.3.0 | |
3 info using node@v8.6.0 | |
4 verbose npm-session 3b16d9640c03ac08 | |
5 silly install loadCurrentTree |
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
let a = Object.create(null); // doesn't have a prototype | |
let b = { }; // has Object.prototype | |
var User = function(name) { | |
this.name = name; | |
/* jshint proto: true */ | |
this.__proto__ = b; | |
// User.prototype.constructor = User // This constructor creates automatically, | |
// but it could be easyly overriden with User.prototype = {} | |
}; |
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 MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
setSupportActionBar(toolbar) | |
initViewPagerAndTabs() | |
} | |
private fun initViewPagerAndTabs() { |
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
/** | |
* Created by Admin on 15/2/18. | |
* Bitmap extensions | |
*/ | |
fun Bitmap.scaleDown(maxImageSize: Float, filter: Boolean): Bitmap { | |
val ratio = Math.min( | |
maxImageSize / width, | |
maxImageSize / height) |
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
etText.setOnTouchListener { v, event -> | |
if (v.id == R.id.etText) { | |
v.parent.requestDisallowInterceptTouchEvent(true) | |
when (event.action and MotionEvent.ACTION_MASK) { | |
MotionEvent.ACTION_UP -> | |
v.parent.requestDisallowInterceptTouchEvent(false) | |
} | |
} | |
false |
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
private var listener: ChildEventListener? = null | |
override fun onStart() { | |
super.onStart() | |
Log.d("OffersFragment", "onStart\n") | |
listener = mDbRef.addChildEventListener(object : ChildEventListener { | |
override fun onChildAdded(snap: DataSnapshot, previousName: String?) { | |
snap.getValue(Category::class.java)?.let { category -> |
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 savePictures(contentResolver: ContentResolver, uris: Array<String>, onUploaded: (ArrayList<String>) -> Unit) { | |
timeStart = System.currentTimeMillis() / 1000 | |
val storage = FirebaseStorage.getInstance() | |
val resultUris = mutableMapOf<Int, String>() | |
val tasks = mutableMapOf<Int, Task<Uri>>() | |
uris.forEachIndexed { position, path -> | |
if (isInStorageAlready(path)) { | |
resultUris[position] = path |
OlderNewer