Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Hanging out at localhost

Yunus Emre Dilber yunusemredilber

:shipit:
Hanging out at localhost
View GitHub Profile
@yunusemredilber
yunusemredilber / _form.html.erb
Last active Apr 16, 2021
Auto Growing text-area [Stimulus] [Rails]
View _form.html.erb
<!-- Some form -->
<div data-controller="auto-grow-textarea">
<%= form.text_area :body, cols: 20, row: 2, placeholder: 'Bir yorum yazın...', class:'form-control', data: { action: 'input->auto-grow-textarea#resize', target: 'auto-grow-textarea.input' } %>
</div>
<!-- Some form continued -->
@yunusemredilber
yunusemredilber / react_spring_example.jsx
Created Dec 19, 2020
React spring animation example
View react_spring_example.jsx
import { render } from 'react-dom'
import React, { useState } from 'react'
import { useSprings, animated } from 'react-spring'
const items = ['hey', 'yooo']
function ReactSpringExample() {
const [pos, setPos] = useState(0)
const springs = useSprings(items.length, items.map((item, i) => ({
opacity: pos === i ? 1 : 0,
View ActivityLifecycleListener.java
import android.app.Activity;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
import java.lang.ref.WeakReference;
import java.util.function.Consumer;
public class ActivityLifecycleListener implements LifecycleObserver {
View rails_polymorphic_association_query.md

Rails Polymorphic Association Query

Example use case:

class User < ApplicationRecord
  belongs_to :authable, polymorphic: true, optional: true
end
 
class Google < ApplicationRecord
@yunusemredilber
yunusemredilber / MultipleTurbolinksViewActivity.java
Last active Jul 13, 2020
Multiple turbolinks view with bottom navigation bar [Android]
View MultipleTurbolinksViewActivity.java
/*
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
implementation 'com.google.android.material:material:1.1.0-alpha08'
*/
public class MultipleTurbolinksViewActivity extends BaseActivity {
private ActivityMultipleTurbolinksViewBinding binding;
private String[] paths = new String[]{"/", "/profile"};
@yunusemredilber
yunusemredilber / loading_animation.cr
Created May 24, 2020
Crystal termial/cli loading animation
View loading_animation.cr
require "colorize"
arr_loading = ["", "", "", "", "", "", "", "", "", ""]
i = 0
loop do
print "#{arr_loading[i % arr_loading.size]}\r".colorize(:light_magenta)
i += 1
sleep(0.1)
end
@yunusemredilber
yunusemredilber / local_to_android.md
Last active May 20, 2020
Connecting to a local rails project from android
View local_to_android.md

Connecting to a local rails project from android

Find your public ip

ifconfig |grep inet

or

@yunusemredilber
yunusemredilber / AndroidManifest.xml
Last active May 20, 2020
Android Firebase Cloud Messaging Skeleton
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.example">
<!-- ... -->
<application
<!-- ... --> >
<!-- ... -->
@yunusemredilber
yunusemredilber / text_horizontal_scrollable.xml
Created May 12, 2020
Android horizontal scrollable text
View text_horizontal_scrollable.xml
<androidx.appcompat.widget.AppCompatEditText
android:background="@null"
android:inputType="none"
android:textIsSelectable="false"
android:cursorVisible="false"
android:focusable="false"
android:layout_width="200dp"
app:layout_constrainedWidth="true"
android:scrollHorizontally="true"
android:singleLine="true"
@yunusemredilber
yunusemredilber / RxBus.java
Created May 7, 2020
Asynchronous and event-based data passing in Android with RxJava
View RxBus.java
public final class RxBus {
// String can be replaced with any kind of Object.
private static final BehaviorSubject<String> behaviorSubject
= BehaviorSubject.create();
public static Disposable subscribe(@NonNull Consumer<String> action) {
return behaviorSubject.subscribe(action);
}
public static void publish(@NonNull String value) {