Skip to content

Instantly share code, notes, and snippets.

@oligazar
oligazar / 0_reuse_code.js
Last active October 10, 2017 09:39
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
@oligazar
oligazar / build.gradle(Project)
Last active October 3, 2017 10:55
Base Android Project set up. - Gradle settings - ProGuard rules - Support library guide: https://guides.codepath.com/android/Design-Support-Library - CodePath: https://guides.codepath.com/android - gitignore - Android Best Practices: https://github.com/futurice/android-best-practices
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"
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
@oligazar
oligazar / npm.md
Last active October 12, 2017 03:35

_

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 = {}
};
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
initViewPagerAndTabs()
}
private fun initViewPagerAndTabs() {
@oligazar
oligazar / BitmapUtils.kt
Last active September 18, 2018 00:02
Helper extension functions 1. ViewUtils 2. ColorUtils 3. StringUtils 4. ContextUtils 5. GsonParsingUtils 6. FirebaseExtensions 7. CollectionUtils 8. BitmapUtils 9. ParcelExtensions
/**
* 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)
@oligazar
oligazar / SomeActivity.kt
Last active October 24, 2017 01:11
When soft keyboard is present it's impossible to make EditText content scroll. Only with custom textListener that disallows touch event interception.
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
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 ->
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