Skip to content

Instantly share code, notes, and snippets.

View MarkNjunge's full-sized avatar

Mark Njung'e MarkNjunge

View GitHub Profile
@MarkNjunge
MarkNjunge / Animated elipses.kt
Created December 29, 2018 09:51
Animated ellipses in Android
val spannableString = SpannableString("Loading...")
val transparentColorSpan = ForegroundColorSpan(Color.TRANSPARENT)
ValueAnimator.ofInt(0, 4).apply {
repeatCount = 10
duration = 1000
addUpdateListener { valueAnimator ->
val dotsCount = valueAnimator.animatedValue as Int
if (dotsCount < 4) { // 4 is the number of ellipses + 1
spannableString.setSpan(
var text = editText.text.toString()
// Save the original text without the tags
val original = text.replace(spoilerTag, "")
// Get the character ranges
val ranges = mutableListOf<Pair<Int, Int>>()
while (text.contains(spoilerTag)) {
// Get start and end of spoiler tags
val start = text.indexOf(spoilerTag)
private fun updateTextView(plainText: String, ranges: MutableList<Pair<Int, Int>>) {
val spannableString = SpannableString(plainText)
ranges.forEach { range ->
// Make the range
spannableString.setSpan(object : ClickableSpan() {
override fun onClick(widget: View) {
// Remove clicked range from the list
ranges.remove(Pair(range.first, range.second))

Overview

What is XSS?

Cross-site scripting (XSS) is a code injection attack that allows an attacker to execute malicious Javascript in another user's browser.

Unlike other attacks such as SQL injection, XSS does not target the application, rather it targets the end user. However, the attacker does so by explioting a vulnerability in a website that the user visits.

How the malicious Javascript is injected

@MarkNjunge
MarkNjunge / build.gradle
Created January 30, 2020 09:54
Apk with timestamp
defaultConfig {
android.applicationVariants.all { variant ->
variant.outputs.all {
def date = new Date()
def formattedDate = date.format('YYYYMMdd')
outputFileName = "appname-${variant.name}-${formattedDate}.apk"
}
}
}
{
"name": "Mark Njung'e Kamau",
"email": "mark.kamau@outlook.com",
"github": "https://github.com/MarkNjunge",
"website": "https://marknjunge.com",
"linkedin": "https://linkedin.com/in/marknjunge",
"cv": "https://marknjunge.com/Mark Kamau CV.pdf",
"seekingEmployment": false,
"experience": [
{
version: '3'
services:
# MongoDB: https://hub.docker.com/_/mongo/
mongo:
image: mongo:4.2
networks:
- graylog
volumes:
- mongo_data:/data/db
# Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/docker.html