Skip to content

Instantly share code, notes, and snippets.

View holysheep's full-sized avatar

Alexandra holysheep

  • Utrecht, Netherlands
View GitHub Profile
package com.tunjid.demo.Util;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
@timyates
timyates / compose.kt
Created April 4, 2012 12:57
Composing functions in Kotlin
fun compose<T>( fa: ( T ) -> T, fb : ( T ) -> T ) : ( T ) -> T {
return { ( a : T ) : T -> fb( fa( a ) ) }
}
fun main( args : Array<String> ) {
val composed = compose<Int>( { ( a : Int ) : Int -> a + 10 }, // add 10
{ ( a : Int ) : Int -> a * 2 } ) // multiply by 2
println( composed( 2 ) ) // prints 24
}
public Bitmap blurBitmap(Bitmap bitmap){
//Let's create an empty bitmap with the same size of the bitmap we want to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
//Instantiate a new Renderscript
RenderScript rs = RenderScript.create(getApplicationContext());
//Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
@timdorr
timdorr / MainApplication.java
Created February 11, 2017 14:36
Tesla App is now React Native!
package com.teslamotors.TeslaApp;
import android.app.Application;
import com.BaiduMaps.BaiduPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.i18n.reactnativei18n.ReactNativeI18n;
@23maverick23
23maverick23 / heroku_commands.sh
Last active July 12, 2022 15:39
Bash: Heroku bash commands
# Heroku Django Commands #
# ---------------------- #
# Push local git changes to heroku
git push heroku master
# Login to heroku via toolbelt
heroku login
# View heroku processes
@ed-george
ed-george / AppBarStateChangedListener.java
Last active July 13, 2022 12:05
Simple listener to determine if the AppBarLayout of a view is collapsed or expanded
public abstract class AppBarStateChangedListener implements AppBarLayout.OnOffsetChangedListener {
public enum State {
EXPANDED,
COLLAPSED,
IDLE
}
private State mCurrentState = State.IDLE;
@scragly
scragly / discord_emoji.md
Last active September 3, 2023 10:07
Emoji for Discord Bots

Discord Emoji

Note: This is written for those using Python 3 and discord.py, so if you're using something else please reference the relevant documentation for your language or library if you choose to use this as a general reference.

On Discord, there are two different emoji types:

Each needs to be handled differently, as while unicode emoji are just simple unicode characters, Discord custom emoji are special objects available only in Discord, belonging to a specific Discord guild and having their own snowflake ID.

@Ahmed-Adel-Ismail
Ahmed-Adel-Ismail / IfElse.java
Last active February 8, 2024 14:44
Observable Operators that enables switch-case and if-else in RxJava stream, you can use them with lift() operator, and pass to them a Map of key/function , if the key is matched with the emitted item, it's function will be executed and it's value will be returned in the stream
/**
* an {@link ObservableOperator} that simulates an if-else in an RxJava Stream, it takes a {@link Map}
* of {@link Predicate} as key and a {@link Function} as value ... the if any emitted item passes
* the {@link Predicate}, this emitted item will be passed to the {@link Function} mapped to it,
* and this item will be invoked and it's result will continue down the stream
* <p>
* sample code :
* <p>
* {@code List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8);}<br>
* {@code Map<Predicate<Integer>, Function<Integer, String>> blocks = new LinkedHashMap<>(2)}<br>
@DasWolke
DasWolke / microservice bots.md
Last active March 23, 2024 16:41
Microservice bots

Microservice Bots

What they are and why you should use them

Introduction

Recently more and more chatbots appear, the overall chatbot market grows and the platform for it grows as well. Today we are taking a close look at what benefits creating a microservice chatbot on Discord - (a communication platform mainly targeted at gamers) would provide.

The concepts and ideas explained in this whitepaper are geared towards bots with a bigger userbase where the limits of a usual bot style appear with a greater effect

Information about Discord itself

(If you are already proficient with the Discord API and the way a normal bot works, you may skip ahead to The Concept)

@jbonney
jbonney / spotify_keybindings
Created June 9, 2013 13:22
Spotify - Linux key bindings. From XFCE / Ubuntu keyboard shortcuts configuration, assign the control command to their key. http://shkspr.mobi/blog/2011/12/linux-spotify-keybindings/
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious