Skip to content

Instantly share code, notes, and snippets.

View sumerman's full-sized avatar
🔮
DATABASE, DATABASE, JUST LIVING IN A DATABASE

Valery Meleshkin sumerman

🔮
DATABASE, DATABASE, JUST LIVING IN A DATABASE
View GitHub Profile
anonymous
anonymous / gist:3385336
Created August 18, 2012 08:32
Решение тринадцатого конкурса по функциональному программированию под эгидой ФП(ФП) на языке Prolog
% Для удобства вводим предикат "безумен", соответствующий отрицанию предиката "в своём уме"
% используем negation as failure
insane(X) :- \+ sane(X).
% Далее мы, по сути, почти дословно переписываем условия задачи -
% основную работу за нас будет делать логический движок Prolog.
% Используем такую формализацию: если X в своём уме, то то что
% X думает является истиной (фактом). У нас фигуранты думают
% исключительно о нормальности друг друга. :)
@w495
w495 / lgps.erl
Created August 27, 2012 12:09
Генератор запоминающихся случайных последовательностей символов, например, капчи или паролей
%%
%% @file lgps.erl Генератор запоминающихся случайных
%% последовательностей символов, например, капчи или паролей
%%
-module(lgps).
-export([
new/0, %% Создает последовательность символов по умолчанию.
new/1, %% Создает последовательность символов, по описанию (см ниже).
@jamiely
jamiely / offline_map.md
Created September 1, 2012 19:17
Generating offline maps for iOS applications

Intro

Recently, I had to implement an offline mapping solution for an iOS application. Here's a walkthrough of how to do it.

Summary

I generated a tile database using TileMill. I used the Route-Me iOS library which provides a map view that supports offline tile sources.

TileMill

@stolen
stolen / gs_up.erl
Created September 27, 2012 09:33
gen_server with self-upgrading state prototype
-module(gs_up).
-export([init/1, handle_call/3, terminate/2]).
-record(state, {
own_fields,
field1,
field2,
field3
}).
@dmitriid
dmitriid / maybe.erl
Created November 19, 2012 16:01
lift
-spec lift(fun()) -> maybe(_, _).
%% @doc Lift F into maybe().
lift(F) ->
try F() of
ok -> {ok, ok};
{ok, Res} -> {ok, Res};
error -> {error, error};
{error, Rsn} -> {error, Rsn};
Res -> {ok, Res}
catch
@NicolasT
NicolasT / paxos.rst.lhs
Created December 7, 2012 22:29
Basic Paxos in Haskell
> module Paxos.Basic where
> import Data.List (maximumBy)
> import Data.Maybe (catMaybes)
Phase 1a: Prepare
=================
A Proposer (the leader) creates a proposal identified with a number N. This
number must be greater than any previous proposal number used by this Proposer.
Then, it sends a Prepare message containing this proposal to a Quorum o
@viktorklang
viktorklang / NettyChannelFutureToScalaFuture.scala
Created December 19, 2012 16:57
Shows how you can use the Promise API of SIP-14 to bridge between Netty ChannelFutures and scala.concurrent.Future
object NettyFutureBridge {
import scala.concurrent.{ Promise, Future }
import scala.util.Try
import java.util.concurrent.CancellationException
import org.jboss.netty.channel.{ Channel, ChannelFuture, ChannelFutureListener }
def apply(nettyFuture: ChannelFuture): Future[Channel] = {
val p = Promise[Channel]()
nettyFuture.addListener(new ChannelFutureListener {
def operationComplete(future: ChannelFuture): Unit = p complete Try(
@dmitriid
dmitriid / ideas
Last active December 11, 2015 02:28
[ категории новостей: [ события/конференции
| библиотеки(аппликухи)
| статьи о языке(общего характера)
]
, проверка новостей перед отправкой: есть ли смысл вообще писать про этот проект
, коллективные переводы статей
, ссылки на материалы с прошедших событий/конференций
, теги к статьям/новостям (не только авторы)
, собирать и сохранять у себя презентации/видео/прочие ресурсы
, нормальная фильтрация потока с твиттера
@maxlapshin
maxlapshin / mpegts_alloc.S
Created May 7, 2013 09:34
mpegts_alloc:new(1000000). returns preallocated binary with size 1000000 that can be filled with your data.
{module, mpegts_alloc}. %% version = 0
{exports, [{module_info,0},{module_info,1},{new,1}]}.
{attributes, []}.
{labels, 7}.
{function, new, 1, 2}.
@scy
scy / opening-and-closing-an-ssh-tunnel-in-a-shell-script-the-smart-way.md
Last active May 7, 2025 21:41
Opening and closing an SSH tunnel in a shell script the smart way

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost