Skip to content

Instantly share code, notes, and snippets.

💪
Charging UP!

Serdar Dogruyol - Sedo セド sdogruyol

💪
Charging UP!
Block or report user

Report or block sdogruyol

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sdogruyol
sdogruyol / arch_linux_prax.md
Created Mar 22, 2018
Prax setup on Arch Linux
View arch_linux_prax.md

Prax Installation on Arch Linux

1 - Install dnsmasq

sudo pacman -Syu
sudo pacman -S dnsmasq

2 - Configure dnsmasq to resolve .test domains to localhost via creating /etc/NetworkManager/dnsmasq.d/prax:

@sdogruyol
sdogruyol / channel_benchmark.cr
Created Jul 31, 2017
Crystal Channel send benchmark
View channel_benchmark.cr
require "benchmark"
channel = Channel(Int32).new
spawn do
loop do
channel.receive
end
end
View short_source_rabin_karp.cr
require "benchmark"
require "colorize"
require "http"
require "spec/dsl"
class String
private PRIME_RK = 2097169u32
def index_old(search : String, offset = 0)
offset += size if offset < 0
View benchmark_setup.sh
sysctl -w fs.file-max=12000500
sysctl -w fs.nr_open=20000500
ulimit -n 20000000
sysctl -w net.ipv4.tcp_mem='10000000 10000000 10000000'
sysctl -w net.ipv4.tcp_rmem='1024 4096 16384'
sysctl -w net.ipv4.tcp_wmem='1024 4096 16384'
sysctl -w net.core.rmem_max=16384
sysctl -w net.core.wmem_max=16384
View global_struct_method.cr
struct Upload
field : String
data : IO::Delimited
meta : HTTP::FormData::FileMetadata
headers : HTTP::Headers
end
def parse_multipart(env)
HTTP::FormData.parse(env.request) do |field, data, meta, headers|
yield Upload.new field, data, meta, headers
View capistrano-kemal.rb
lock '3.5.0'
set :application, 'your-app'
set :repo_url, 'https://github.com/your/app'
set :deploy_to, '/home/deploy/apps/your-app/'
namespace :deploy do
after :updated, :build do
on roles(:web) do
execute "cd '#{release_path}' && shards install"
View context_with_store.cr
# Context is the environment which holds request/response specific
# information such as params, content_type e.g
class HTTP::Server
class Context
STORE = {} of String => Box
def set(key, value)
STORE[key] = {"object": Box.box(value), "type": typeof(value)}
end
View string_benchmark.cr
require "benchmark"
Benchmark.bm do |x|
$status_code = "200"
$method = "GET"
$path = "api/v1/users"
x.report "Normal String" do
10000000.times do
"|#{$status_code}| #{$method} #{$path}"
View kemal-array.cr
require "kemal"
post "/json_params" do |env|
like_objects = env.params.json["_json"].as Array
like_objects.each do |likes|
likes_hash = (likes as Hash(String, JSON::Type))["likes"]
end
end
Kemal.run
View kemal_json_array.cr
require "kemal"
post "/json_params" do |env|
json = env.params.json["likes"].as Array
# You can learn the type like this
puts json.first.class
first = json.first.as Hash(String, JSON::Type)
puts first["id"]
end
You can’t perform that action at this time.