Skip to content

Instantly share code, notes, and snippets.

View tuscen's full-sized avatar
🐼

Aleksey Usatov tuscen

🐼
View GitHub Profile
@tuscen
tuscen / hexlet.slack.log
Last active August 29, 2015 14:28 — forked from namreg/hexlet.slack.log
почему дефолты в БД зло, Continuos Delivery
kirill.mokevnin [8:19 PM]
тут в соседнем чате спросили почему дефолты в базе зло, но по скольку это касается не только руби, предлагаю обсудить
kirill.mokevnin [8:19 PM]
тут
kirill.mokevnin [8:20 PM]
Кто согласен не согласен?
ivanlemeshev [8:21 PM]
@tuscen
tuscen / hexlet.slack.log
Last active August 29, 2015 14:28 — forked from namreg/hexlet.slack.log
про функциональный подход и стейты.
sumyuga [7:57 PM] вот такой вопрос меня последние два дня волнует:
а пишут ли веб в функциональном стиле? читал что Lisp используют для веба и даже в продакшене он себя хорошо чувствует.
просто на мой взгляд это скорее эзотерика, хотя с приходом reactjs может многое изменится, кто что думает?
kirill.mokevnin [8:05 PM]
В функциональном стиле пишут функции, а не веб
когда в любом языке программирования вы используете функцию map, вы пишите этот кусочек программы в функциональном стиле
sumyuga [8:06 PM]
ну в общем вы меня поняли )) да, есть же clojure, совсем забыл ))
@tuscen
tuscen / The Technical Interview Cheat Sheet.md
Last active August 28, 2015 05:05 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@tuscen
tuscen / bijective.rb
Last active September 19, 2015 20:49 — forked from zumbojo/bijective.rb
Simple bijective function (base(n) encode/decode)
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@tuscen
tuscen / RedisJobQueue.cs
Created July 14, 2017 15:18 — forked from tenowg/RedisJobQueue.cs
A Message/Job Queue based on StackExchange.Redis and Redis Server
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using StackExchange.Redis;
namespace CitySurvival.Redis
{
@tuscen
tuscen / add_intellij_launcer
Created August 6, 2017 20:55 — forked from rob-murray/add_intellij_launcer
Add Intellij launcher shortcut and icon for ubuntu
// create file:
sudo vim /usr/share/applications/intellij.desktop
// add the following
[Desktop Entry]
Version=13.0
Type=Application
Terminal=false
Icon[en_US]=/home/rob/.intellij-13/bin/idea.png
Name[en_US]=IntelliJ

Rate limiting with Redis

June 2011 - Chris O'Hara - (archived original post)

Rate limiting can be an effective way of conserving resources and preventing automated or nefarious activities on your site.

A common use case is to limit the amount of requests an IP can make over a certain time frame. For example, you might want to restrict users from using an expensive search utility on your site. If the user attempts to search more than 5 times a minute, you can redirect them to another page informing them that they need to wait.

IP based rate limiting is already in use on larger sites. Google and Yahoo both employ the technique to prevent (or at least complicate) automated requests to their services.

@tuscen
tuscen / RouteParser.cs
Created September 16, 2017 23:32 — forked from wcharczuk/RouteParser.cs
C# Route Parser
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Text.RegularExpressions;
//TODO: probably want to change this if you're using it your project
namespace ClothesHorse.Core
{
@tuscen
tuscen / tap.md
Created September 23, 2017 02:01 — forked from ripesunflower/tap.md
The Task-based Asynchronous Pattern