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
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# some more ls aliases | |
alias l='ls -CF' | |
alias ll='ls -lg' | |
alias la='ls -A' | |
alias f='open -a Finder ./' | |
alias home='cd ~' |
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-strict"; // required for tail call opt | |
Array.prototype.forEachRecursive = function(cb) { | |
function forEach(array, cb) { | |
return forEachRec(array, 0, cb); | |
} | |
function forEachRec(array, start, cb) { | |
if (start > array.length - 1) return; | |
cb(array[start], start); | |
return forEachRec(array, start + 1, cb); |
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
Array.prototype.megaFilter = function(cb) { | |
const iterator = this[Symbol.iterator](); | |
const iteration = iterator.next(); | |
const filteredArray = []; | |
iterate(iteration); | |
function iterate(iteration) { | |
if (iteration.done) return iteration; | |
if (cb(iteration.value)) filteredArray.push(iteration.value); | |
const nextIteration = iterator.next(iteration.value); | |
return iterate(nextIteration); |
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
/* Callbacks function */ | |
const asyncFn = (i, success, error) => { | |
if (i === 0) return error('Failed!'); | |
setTimeout(() => { | |
return success('Worked!!'); | |
}, 1000); | |
}; | |
/* Function call like in old times */ |
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
data class Item(val id: Long, val title: String, val url: String) | |
class RecyclerViewAdapter(val items: List<Item>, val listener: (Item) -> Unit) : RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>() { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
return ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.recycler_item_row, parent, false)) | |
} | |
override fun onBindViewHolder(holder: ViewHolder, position: Int) = holder.bind(items[position], listener) | |
override fun getItemCount(): Int = items.size |
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
/* | |
* Copyright 2002-2010 Guillaume Cottenceau. | |
* | |
* This software may be freely redistributed under the terms | |
* of the X11 license. | |
* | |
*/ | |
#include <unistd.h> | |
#include <stdlib.h> |