Skip to content

Instantly share code, notes, and snippets.

Avatar

Dmitrii 'Mamut' Dimandt dmitriid

View GitHub Profile
View beepbeep_mw.erl
%%
%% передаем в stack ewgi-контекст и список миддлварей таким оразом:
%%
%% stack(Ctx, [
%% module1,
%% module2,
%% {module3, [Option1, Option2]
%% ])
%%
%% миддлварь должна реализовывать run/2 или run/3 таким образом
View beep_web_dispatch.erl
-module(beep_web_dispatch).
-export([run/2]).
-include("rberl.hrl").
run({ewgi_context, Request, _} = Ctx, App) ->
PathInfo = string:tokens(ewgi_api:path_info(Ctx), "/"),
Path = list_to_binary(PathInfo),
View webmachine_multipart2.erl
%% @author Bob Ippolito <bob@mochimedia.com>
%% @copyright 2007 Mochi Media, Inc.
%% @doc Utilities for parsing multipart/form-data. Shamless rip-off off mochiweb
-module(webmachine_multipart2).
-author('dmitrii@dmitriid.com').
-export([parse_form/1, parse_form/2]).
-export([parse_multipart_request/2]).
View banner_gen.erl
-export([
init/1
, content_types_provided/2
, provide_content/2
]).
-include_lib("webmachine_resource.hrl").
-include_lib("zotonic.hrl").
View draw_text.py
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------
# test stuff
from optparse import OptionParser
import Image, ImageFont, ImageDraw, sys, codecs
if __name__ == "__main__":
parser = OptionParser()
parser.add_option("-l", "--label")
View something.js
var soId = '';
var soNumber = '';
var toCartForm = new Array();
var rec;
var today = new Date();
today = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0, 0);
var tommorow = new Date(today.getFullYear(), today.getMonth(), (today.getDate()+1), 0, 0, 0, 0);
View gist:2724806
convert(S) ->
convert(S, [], [], []).
convert([], Ip, Port, _) ->
{Ip, Port};
%% ща будет порт
convert([$:|T], Ip, _Port, _Acc) ->
convert([], Ip, list_to_integer(T), []);
%% ща будет следующая цыфра
convert([$.|T], Ip, Port, _Acc) ->
View gist:2781291
// Type C++ code here, or load an example.
#include <iostream>
int main(){
std::cout << "aa";
return 0;
}
@dmitriid
dmitriid / mo.erl
Created Jul 7, 2012
Parse out Mod, Func, Name from function type spec
View mo.erl
%% Consider
%% mod:func([A],{A,B},list(), any(), some_type({A,list(),B})) -> ok | error.
%%
%% Start from the beginning. Scan each character
%%
%% 1. Once we hit ":", we've got our module name, start looking for function
%% name.
%% 2. Once we hit "(", we've got our method name, start looking for arguments
%% 3. Arguments are a bit trickier
%% 3.1 If we encounter a "{", "[", "(" we don't care about anything
View plt_cache_server.erl
-module(plt_cache_server).
-behaviour(gen_server).
%%%
%%% Exports
%%%
%%
%% API
%%