Skip to content

Instantly share code, notes, and snippets.

View yunusemredilber's full-sized avatar
:shipit:
Hanging out at localhost

Yunus Emre Dilber yunusemredilber

:shipit:
Hanging out at localhost
View GitHub Profile
@yunusemredilber
yunusemredilber / elementary_starter.sh
Last active April 5, 2020 15:29
Elementary OS commands for creating a development environment [Mostly for Android & Rails]
# Update and Upgrade System
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
# Install Tweaks (To enable dark mode and more)
sudo apt install software-properties-common
sudo add-apt-repository ppa:philip.scott/elementary-tweaks
sudo apt install elementary-tweaks
@yunusemredilber
yunusemredilber / postgresql_for_rails.sh
Created March 17, 2020 20:23
Potgresql installation for Rails [Ubuntu based distros]
$ sudo apt update
$ sudo apt install postgresql postgresql-contrib libpq-dev
$ sudo -u postgres createuser --interactive
> Enter name of role to add: yunus # Current OS Username
> Shall the new role be a superuser? (y/n) y
## This should work :)
## If any error comes up, the link at the bottom might help
@yunusemredilber
yunusemredilber / dashed_border_in.xml
Last active February 25, 2020 10:42
A container with dashed border and rounded corners in android
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
<corners android:radius="10dp" />
<solid android:color="#ffffff" />
<stroke
android:dashGap="5dp"
android:dashWidth="5dp"
android:width="3dp"
android:color="#0000FF" />
@yunusemredilber
yunusemredilber / MyModalBottomSheet.java
Created February 15, 2020 12:58
Android - Material Modal Bottom Sheets
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public class LocationPermissionBottomSheet extends BottomSheetDialogFragment {
@Override
public View onCreateView (LayoutInflater inflater,
@yunusemredilber
yunusemredilber / MainActivity.java
Created February 15, 2020 11:53
Android circular image view downloaded from the internet with AsyncTask
public class MapActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Download and set image of profile button. (async)
new DownloadButtonImageTask().execute(
new DownloadButtonImageTaskParams("https://images.unsplash.com/photo-1555436169-f998ad1259fd?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80",
@yunusemredilber
yunusemredilber / SomeActivity.java
Last active February 8, 2020 06:39
Webview In Navigation View (Drawer) [ Android ]
public class SomeActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview_in_drawer_layout);
// ...
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawerLayout, null, R.string.app_name, R.string.app_name);
@yunusemredilber
yunusemredilber / activity_fab_with_badge.xml
Created February 5, 2020 11:23
Android Material FAB With Badge Attached
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_view">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/notifications_button"
@yunusemredilber
yunusemredilber / MainActivity.java
Created December 3, 2019 12:21
Using Turbolinks Android with tabs.
public class MainActivity extends AppCompatActivity implements TurbolinksAdapter {
// Change the BASE_URL to an address that your VM or device can hit.
private static final String BASE_URL = "http://10.0.1.100:9292";
private static final String INTENT_URL = "intentUrl";
String tab1_path = "/tab1";
String tab2_path = "/tab2";
boolean tab1_is_visited = false;
boolean tab2_is_visited = false;
@yunusemredilber
yunusemredilber / _grid.html.erb
Created October 9, 2019 11:12
Bootstrap grid of images responsive [Rails] [Stimulus]
<div class="row">
<% photos.each_with_index do |photo, i| %>
<% if i == 0 %>
<%= render partial: 'image', locals: { image: image, col_length: 12, square: false }, cached: true %>
<% else %>
<%= render partial: 'image', locals: { image: image, col_length: 4, square: true }, cached: true %>
<% end %>
<% end %>
</div>
@yunusemredilber
yunusemredilber / _form.html.erb
Last active April 11, 2024 09:57
Auto Growing text-area [Stimulus] [Rails]
<!-- 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 -->