Skip to content

Instantly share code, notes, and snippets.

View kosiara's full-sized avatar

Bartosz Kosarzycki kosiara

View GitHub Profile
@kosiara
kosiara / main.dart
Created September 2, 2018 09:07
Flutter portrait only
void main() {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
.then((_) {
runApp(new MyApp());
});
}
@kosiara
kosiara / proguard-rules.pro
Last active September 1, 2018 10:44
proguard rules for Twitter UI
# Twitter core rules
-keepattributes *Annotation* #GSON
-dontwarn java.nio.file.** #Okio
-dontwarn org.codehaus.mojo.animal_sniffer.** #Okio
-dontwarn javax.annotation.* #Okio
-dontwarn javax.annotation.concurrent.* #Okio
-dontnote retrofit2.Platform #Retrofit 2
-dontnote retrofit2.Platform$IOS$MainThreadExecutor #Retrofit 2
-dontwarn retrofit2.Platform$Java8 #Retrofit 2
-keepattributes Signature #Retrofit 2
@kosiara
kosiara / TwitterViewComponent.kt
Last active August 30, 2018 19:02
Custom Twitter TweetView Style
override fun success(result: Result<Tweet>?) {
val tweet = result!!.data
componentInstance.addView(TweetView(componentInstance.context, tweet, R.style.CustomTwitterStyle))
invalidate()
}
@kosiara
kosiara / TweetViewUtil.kt
Last active August 30, 2018 19:09
Reformat Twitter date
/**
* Reformat Twitter date to a new pattern
*/
fun TweetView.reformatDate(newDatePattern: String) {
val twitterDatePattern = "EEE MMM dd HH:mm:ss Z yyyy" // Mon Apr 21 04:08:37 +0000 2018
val dateTextView = findViewById<AppCompatTextView>(R.id.tw__tweet_timestamp)
dateTextView.text = parseDate(tweet.createdAt, twitterDatePattern).format(newDatePattern)
}
/**
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="tweetId"
type="com.bk.sample.android.util.databinding.ObservableString" />
</data>
@kosiara
kosiara / TwitterViewComponent.kt
Created August 30, 2018 07:45
TwitterViewComponent - simple
package com.bk.sample.android.component
[...]
import com.bk.sample.android.util.databinding.ObservableString
import com.twitter.sdk.android.core.Callback
import com.twitter.sdk.android.core.Result
import com.twitter.sdk.android.core.TwitterException
import com.twitter.sdk.android.core.models.Tweet
import com.twitter.sdk.android.tweetui.TweetUtils
import com.twitter.sdk.android.tweetui.TweetView
@kosiara
kosiara / python3_http_simple_server.py
Created September 21, 2017 07:57
Simple Python3 HTTP Server; one-line python GET method
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse
import subprocess
class GetHandler(BaseHTTPRequestHandler):
ls_l_cmd = ['ls','-l']
def do_GET(self):
parsed_path = urlparse(self.path)
@kosiara
kosiara / app build.gradle
Last active April 21, 2017 20:49
@ParametersAreNonnullByDefault for all subpackages includes src, test and androidTest
apply plugin: 'com.android.application'
apply from: 'nonnull.gradle'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
[...]
}
@kosiara
kosiara / nonnull.gradle
Last active February 7, 2024 10:08
@ParametersAreNonnullByDefault for all subpackages
/**
* File: nonnull.gradle
*
* Generates package-info.java for appropriate packages
* inside src/main/java folder.
*
* This is a workaround to define @ParametersAreNonnullByDefault for all Java classes in a package
* i.e. including all subpackages (note: edit line no. 19).
*/
task generateNonNullJavaFiles(dependsOn: "assembleDebug", type: Copy) {
@kosiara
kosiara / karabiner.json
Created September 29, 2016 07:31
Karabiner-Elements-PL-right-command-alt-cmd-alt-swap
#save this file under: ~/.karabiner.d/configuration/karabiner.json
{
"profiles": [
{
"name": "Default profile",
"selected": true,
"simple_modifications": {
"right_command": "right_option",
"right_option": "right_command"