Skip to content

Instantly share code, notes, and snippets.

View cbilgili's full-sized avatar

Canbey Bilgili cbilgili

  • Istanbul
View GitHub Profile
@cbilgili
cbilgili / _messages.html.erb
Last active August 25, 2021 17:14
Simple Chat with Hotwire Turbo Stimulusjs
<%= 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 %>
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 April 4, 2020 13:41
Türkiye'deki İllerin Komşu İlleri Listesi - JSON - Turkish Provinces Borders List
[
{
"name": "Adana",
"borders": [
"Hatay",
"Osmaniye",
"Kahramanmaraş",
"Kayseri",
"Niğde",
"Mersin"
@cbilgili
cbilgili / gist:053215b8169b2763b9596cf65d21d663
Created January 7, 2020 14:42
Git: Ignore tracked files
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 July 10, 2018 21:10
Python check if tab separated file is correct
# 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 February 28, 2018 21:11
screen ssh long running commands
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 July 27, 2017 17:38
How to keep rails command from Rails Console running after SSH Client (PuTTy) closes
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
{"total":200,"completed":3}
@cbilgili
cbilgili / iconExample.js
Created February 24, 2017 10:15 — forked from flunder/iconExample.js
An example gist trying to show how to implement an icon within a tcomb form in react-native
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 December 27, 2016 08:59
Redux CRUD Saga (redux-saga)
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))