Skip to content

Instantly share code, notes, and snippets.

View sdogruyol's full-sized avatar
🏠
Working from home

Serdar Dogruyol - Sedo セド sdogruyol

🏠
Working from home
View GitHub Profile
@pine
pine / AdventCalendar_Crystal_20151215.md
Last active December 16, 2015 12:16
『 東京 Crystal 勉強会 #3 in 恵比寿 』 を開催します!!!!

🎉🎉🎉 東京 Crystal 勉強会 #3 を開催します 🎉🎉🎉

この記事は Crystal Advent Calendar 2015 の 15 日目の記事です

昨日は Kemal の開発者である sdogruyol さんの記事でした。
今日は、私 pine613 が次の Crystal 勉強会の告知記事を書きます!

💎 TL;DR

  • 2016年1月22日 (金) に Cookpad さんで開催決定
@sdogruyol
sdogruyol / RailsMysqlExisting.md
Last active December 16, 2015 18:19
Rails 3.2 Connection To Existing Mysql DB

Install Active Record Mysql Bindings

gem install activerecord-mysql2-adapter

Add mysql2 to your .Gemfile

gem 'mysql2'

Configure your DB Settings in config/database.yml

development:
    adapter: mysql2
    encoding: utf8
    database: mysql_db_name

pool: 5

@vigo
vigo / tr-developer-podcasts.md
Last active June 9, 2017 11:11
Türkçe Developer PodCast'leri

Türkçe Developer PodCast’leri

devPod

[Web][1a] - [iTunes][1b]

webBox5

[Web][2a] - [iTunes][2b]

@ysbaddaden
ysbaddaden / MT.md
Last active October 30, 2018 15:31

Crystal MTs (Multi Threaded schedulers)

Goals:

  • developers must only care about fibers and channels;
  • crystal runtime should start 1 upto N threads;
  • each thread can take & resume any fiber in the loop;
  • channels as user-code sync primitives;
  • also propose fiber-aware mutex/monitors;
  • additional sync primitives (e.g. IO events, ...)
@jamesob
jamesob / nodejs-question.md
Last active January 26, 2019 22:50
An open question (rant) about node.js

Most developers would agree that, all other things being equal, a synchronous program is easier to work with than an asynchronous one. The logic for this is pretty clear: one flow of execution is easier for the human mind to simulate than n concurrent flows.

After doing two small projects in node.js (one of which is here -- ready for the blinding flurry of criticism), there's one question that I can't shake: if asynchronicity is an optimization (that is, a complexity introduced for the sake of performance), why would people, a priori, turn to a framework that imposes it for everything? If asynchronous code is harder to reason about, why would we elect to live in a world where it is the default?

It could be argued pretty well that the browser is a domain that inherently lends itself to an async model, but I'd be very curious to hear a defense of "async-first" thinking for problems that are typically solved on the server-side. When working with node, I've noticed

@shiroyasha
shiroyasha / dog.rb
Created February 16, 2016 22:20
Method tracer for Ruby classes
class Dog
attr_writer :name
def initialize(name)
@name = name
end
def bark
puts "patrick"
end

Node.js Resources

What is node.js?

Node.js is just JavaScript running on the server side. That's it. That's all there is to it.

Express

  • Express Docs, if you want to get started and already know JavaScript this is the place to be

Transactions

As your business logic gets complex you may need to implement transactions. The classic example is a bank funds transfer from account A to account B. If the withdrawal from account A fails then the deposit to account B should either never take place or be rolled back.

Basics

All the complexity is handled by ActiveRecord::Transactions. Any model class or instance has a method named .transaction. When called and passed a block, that block will be executed inside a database transaction. If there's an exception raised, the transaction will automatically be rolled back.

Example

@olivierlacan
olivierlacan / migrate_postgresql_database.md
Last active March 24, 2022 20:30
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X. See upgraded version of this guide: http://olivierlacan.com/posts/migrating-homebrew-postgres-to-a-new-version/

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important:

@nhoffmann
nhoffmann / deploy.rb
Created April 3, 2012 14:07
Capistrano recipe for deploying static content.
set :application, "My Static Content"
set :servername, 'test.example.com'
# no git? simply deploy a directory
set :scm, :none
set :repository, "." # the directory to deploy
# using git? deploy from local git repository
# set :scm, :git
# set :repository, 'file//.' # path to local git repository