Skip to content

Instantly share code, notes, and snippets.

Avatar

Canbey Bilgili cbilgili

  • Istanbul
View GitHub Profile
@cbilgili
cbilgili / _messages.html.erb
Last active Aug 25, 2021
Simple Chat with Hotwire Turbo Stimulusjs
View _messages.html.erb
<%= turbo_frame_tag "new_message", target: "_top" do %>
<%= form_with(model: [@message.room, @message], data: { controller: "reset-form", action: "turbo:submit-end->reset-form#reset" }) do |form| %>
<%= form.text_field :content, autocomplete: 'off', placeholder: 'Write your message...' %>
<%= button_tag(type: :submit) do %>
<i class="fa fa-paper-plane" aria-hidden="true"></i>
<% end %>
<%= form.submit "Send", data: {disable_with: false} %>
<% end %>
<% end %>
View git squash commits
2020 Simple solution without rebase :
git reset --soft HEAD~2
git commit -m "new commit message"
git push --force
2 means the last two commits will be squashed. You can replace it by any number
@cbilgili
cbilgili / turkish_admin1_borders.json
Created Apr 4, 2020
Türkiye'deki İllerin Komşu İlleri Listesi - JSON - Turkish Provinces Borders List
View turkish_admin1_borders.json
[
{
"name": "Adana",
"borders": [
"Hatay",
"Osmaniye",
"Kahramanmaraş",
"Kayseri",
"Niğde",
"Mersin"
View gist:053215b8169b2763b9596cf65d21d663
git update-index --assume-unchanged [<file> ...]
To undo and start tracking again:
git update-index --no-assume-unchanged [<file> ...]
@cbilgili
cbilgili / check_tab_delimited.py
Created Jul 10, 2018
Python check if tab separated file is correct
View check_tab_delimited.py
# It shows if tab seperated file has any error, and print line number
# filename = "tab_file.txt"
with open(filename) as f:
i = 0
for line in f:
line = line.rstrip()
i = i + 1
if line:
try:
word, tag = line.split('\t')
@cbilgili
cbilgili / gist:082bf17792d4b7d148fa35c9a6c76703
Last active Feb 28, 2018
screen ssh long running commands
View gist:082bf17792d4b7d148fa35c9a6c76703
You want to be using GNU Screen. It is super awesome!
ssh me@myserver.com
screen #start a screen session
run-a-long-process
CTRL+a , d to detatch from your screen session
exit #disconnect from the server, while run-a-long-process continues
When you come back to your laptop:
@cbilgili
cbilgili / gist:1d6b9b1538996c7813e869c7ffc97b4b
Created Jul 27, 2017
How to keep rails command from Rails Console running after SSH Client (PuTTy) closes
View gist:1d6b9b1538996c7813e869c7ffc97b4b
Use sudo apt-get install screen to install screen. Then run it using screen. Now you have a separate console window which can be detached using Ctrl + A, then D. Closing putty will not end your screen-session. If you log back in at any later point, you may resume the sessions using screen -r.
To summarize:
> sudo apt-get install screen
> screen
# pops up a new shell
> rails c
# run your reindex operation
# press Ctrl + A, then D
@cbilgili
cbilgili / iconExample.js
Created Feb 24, 2017 — forked from flunder/iconExample.js
An example gist trying to show how to implement an icon within a tcomb form in react-native
View iconExample.js
const Form = t.form.Form;
const postOptions = t.struct({
publication: t.String,
tags: t.String,
more: t.String,
facebook: t.Boolean
})
const options = {
@cbilgili
cbilgili / crud-saga.js
Created Dec 27, 2016
Redux CRUD Saga (redux-saga)
View crud-saga.js
import { takeLatest } from 'redux-saga'
import { call, put } from 'redux-saga/effects'
import fetch from 'isomorphic-fetch'
import * as actions from './modules/grid'
import * as api from '../lib/api'
export function* fetchGrids(action) {
try {
const grids = yield call(api.GET, 'grids')
yield put(actions.fetchGridsSuccess(grids))