Skip to content

Instantly share code, notes, and snippets.

@dnet
dnet / gist:9505053
Created March 12, 2014 11:26
Erlang workshop code from 2013-11-21 see http://hsbp.org/erlang#Workshop
-module(teszt).
-export([init/1, handle_call/3, q/1, init/0]).
-behaviour(gen_server).
init() ->
gen_server:start_link(?MODULE, [], []).
q(Pid) -> gen_server:call(Pid, q).
init([]) -> {ok, 0}.
handle_call(q, _, N) -> {reply, N, N + 1}.
@dnet
dnet / gist:335901
Created March 18, 2010 00:15
Java policy file for JDBC lab
grant codeBase "http://rapid.eik.bme.hu/-" {
permission java.net.SocketPermission "rapid.eik.bme.hu:1521", "connect";
permission java.util.PropertyPermission "oracle.jdbc.*", "read";
permission java.util.PropertyPermission "user.name", "read";
};
@dnet
dnet / gist:468518
Created July 8, 2010 20:01
#hspbp Topic Generator ötletforrás
# hspbp-topicgen ötletforrás
# http://github.com/dnet/hspbp-topicgen
#
# minden ötlet kerüljön külön sorba, a #-el kezdődő ill. üres sorok megjegyzések
# az ötletekben két ~s lehet, első a feladóra, második a tárgyra helyettesítődik be
# minta: [levlista] Felado: ~s || Targy: ~s
# az első IRC-s ötlet, később törölhető nyugodtan, csak ne legyen üres a fájl
kepzeljetek, ~s irt a levlistara ~s targgyal
@dnet
dnet / ivd.erl
Created June 12, 2011 08:53
Indavideó downloader
% Downloader for http://indavideo.hu/
% Author: András Veres-Szentkirályi <vsza@vsza.hu>
% License: MIT
-module(ivd).
-export([getvideos/1]).
getvideos(URL) ->
VID = url2vid(URL),
AmfReq = <<"\0\x03\0\0\0\x01\0!player.playerHandler.getVideoData\0\x02"
@dnet
dnet / gist:1021840
Created June 12, 2011 18:20
SUDS: PasswordText without nonce and created
POST /?wsdl HTTP/1.1
Accept-Encoding: identity
Content-Length: 757
Soapaction: "say_hello"
Host: 127.0.0.1:15100
User-Agent: Python-urllib/2.7
Connection: close
Content-Type: text/xml; charset=utf-8
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="tns" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header><wsse:Security mustUnderstand="true"><wsse:UsernameToken><wsse:Username>foo</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">bar</wsse:Password></wsse:UsernameToken></wsse:Security></SOAP-ENV:Header><ns0:Body><ns1:say_hello><ns1:name>world</ns1:name><ns1:times>3</ns1:times></ns1:say_hello></ns0:Body></SOAP-ENV:Envelope>
@dnet
dnet / github.erl
Last active September 26, 2015 03:38
GitHub module for IRCnet #hspbp channel
% depends: https://github.com/talentdeficit/jsx
-module(github).
-export([ircmain/1, ircproc/1, reload/2]).
query_repo_json(User, Repo) ->
URL = "https://api.github.com/repos/" ++ User ++ "/" ++ Repo,
{ok, {_, _, JSON}} = httpc:request(get,
{URL, [{"User-Agent", "dehat-github"}]}, [], [{body_format, binary}]),
JSON.
@dnet
dnet / leet.erl
Created June 23, 2011 18:41
1337 module for IRCnet #hspbp channel
-module(leet).
-export([ircmain/1, ircproc/1, reload/2]).
ircmain(Contact) ->
spawn(?MODULE, ircproc, [Contact]).
reload(Contact, Pid) ->
Pid ! reloaded,
ircproc(Contact).
@dnet
dnet / videotar.sh
Created October 14, 2011 20:49
MTV videotár player
#!/bin/sh
# MTV videotar player
if [ $# -lt 1 ]; then
echo "Usage: $0 <videotar URL> [additional parameters to player]" >&2
exit 1
fi
CURL="curl -silent"
URL=$($CURL "$1" | sed -n 's/^.*\(http.*wmv\).*$/\1/p')
@dnet
dnet / unshort.erl
Created February 9, 2012 12:28
Simple Erlang URL unshortener
-module(unshort).
-export([unshort/1]).
unshort(URL) -> unshort(URL, 32).
unshort(URL, TTL) when TTL > 0 ->
{ok, {_, Headers, _}} = httpc:request(head, {URL, []}, [{autoredirect, false}], []),
case proplists:get_value("location", Headers) of
undefined -> URL;
Location -> unshort(Location, TTL - 1)
end.
@dnet
dnet / unshortener.erl
Created February 9, 2012 12:30
Erlang IRC bot unshortener module
% depends: https://gist.github.com/1779650
-module(unshortener).
-export([ircmain/1, ircproc/1, reload/2]).
recognize_url(Input) ->
{match, URLs} = re:run(Input,
"https?://(t.co|tinyurl.com|bit.ly)/[a-zA-Z0-9\-_]+",
[{capture, first, list}, global]),
"[unshortened] " ++ string:join(lists:map(fun unshort:unshort/1,