Skip to content

Instantly share code, notes, and snippets.

🎯
learning scrapy and various web scraping tools.

eoin_a eoinahern

🎯
learning scrapy and various web scraping tools.
Block or report user

Report or block eoinahern

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@eoinahern
eoinahern / Main.kt
Created Jan 16, 2020
playing with pure functions curried functions
View Main.kt
fun main() {
val addOne : (Int) -> Int = { it + 1 }
val doubleStuff : (Int) -> Int = { it * 2}
val myFunc = composer(addOne, doubleStuff)
println(myFunc(3))
val add : (Int) -> (Int)-> Int= { a -> {b -> a + b}}
val num = add(1)(2)
println(num)
@eoinahern
eoinahern / client.js
Last active Dec 17, 2019
connecting to ktor websocket endpoints with simple node.js client (dont really use node a lot)
View client.js
const WebSocket = require('ws')
//setup input from console
var stdin_input = process.stdin;
stdin_input.setEncoding("utf-8");
//connect socket!!
const url = "ws://localhost:8080/output_all";
const connection = new WebSocket(url);
View myTest.kt
@Test
fun testGetCurrency() {
val item: Pair<DomainCurrency, List<DomainCurrency>> = Pair(
DomainCurrency("USD", "1.00", 2, "US DOLLAR"),
listOf(DomainCurrency("EUR", "12.00", 1, "EURO"))
)
@eoinahern
eoinahern / FormatRealTime.kt
Created Apr 9, 2019
trying to format text in edittext using the Locale to add decimal places and comma seperators after user has typed
View FormatRealTime.kt
val df = DecimalFormat("#,###", DecimalFormatSymbols(Locale.getDefault()))
var textChanged = false
df.minimumFractionDigits = 0
df.maximumFractionDigits = asset.investmentDecimalPlaces
layout.txt_amount.textChanges()
.debounce(400, TimeUnit.MILLISECONDS)
.map { layout.txt_amount.text.toString() }
.subscribeOn(AndroidSchedulers.mainThread())
View CustomShrinkLayoutBehavior.kt
class CustomShrinkLayoutBehavior(context: Context, attrs: AttributeSet) :
CoordinatorLayout.Behavior<NestedScrollView>(context, attrs) {
private var screenHeight: Int = context.resources.displayMetrics.heightPixels
override fun layoutDependsOn(parent: CoordinatorLayout, child: NestedScrollView, dependency: View): Boolean {
return dependency is AppBarLayout
}
override fun onDependentViewChanged(parent: CoordinatorLayout, child: NestedScrollView, dependency: View): Boolean {
View ViewModel.kt
val whatsappRelay: BehaviorRelay<Boolean> = BehaviorRelay.create()
val telegramRelay: BehaviorRelay<Boolean> = BehaviorRelay.create()
val checkTextValid: BehaviorRelay<Boolean> = BehaviorRelay.create()
val openAppIntentRelay: BehaviorRelay<Intent> = BehaviorRelay.create()
val checkShowTextUnderSend: BehaviorRelay<Boolean> = BehaviorRelay.create()
val messageSent: BehaviorRelay<Boolean> = BehaviorRelay.create()
fun checkAppsInstalled() {
View loadFavourites.kt
override fun loadFavourites() {
compositeDisposable.add(viewModel.getFavouritesFromBackend()
.subscribe {
if (it.isEmpty()) {
showFavouritesEmpty()
} else {
updateFavouritesListener?.updateFavourites(it)
loadData(it)
@eoinahern
eoinahern / KeyStoreHelper.java
Created Dec 20, 2018
android keystore encryption class
View KeyStoreHelper.java
public class KeyStoreHelper {
private static final String ALIAS = "mikey";
private static final String ANDROID_KEYSTORE = "AndroidKeyStore";
private final Context context;
private Calendar start;
private Calendar end;
private KeyStore keyStore;
@eoinahern
eoinahern / CallToApi.java
Created Jun 22, 2018
rx problem a guy was having on slack. put into a gist because the code was formatted badly. An attempt to make the code more readable.
View CallToApi.java
Interceptor addHeadersInterceptor = chain -> {
if (tokenInvalid){
String token = getToken()); //If multiple call stays here blocked.
}
};
public String getToken() {
View backNavigation.kt
//back navigation in android
//initate toolbar
val detailsToolbar: Toolbar by lazy { findViewById<Toolbar>(R.id.toolbar) }
//in onCreate
this.setSupportActionBar(detailsToolbar)
actionBar = supportActionBar
actionBar?.apply {
this.setDisplayHomeAsUpEnabled(true)
You can’t perform that action at this time.