Skip to content

Instantly share code, notes, and snippets.

@dnet
dnet / share.sh
Created February 12, 2013 18:08
Simple web file sharing script using SHA-256 hash as file name to avoid brute force attacks
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 <filename>" >&2
exit 1
fi
HASH=$(sha256sum $1 | cut -c -64)
EXT=$(echo "$1" | sed 's/^.*\.//')
scp "$1" remote_host:directory_available_from_web/$HASH.$EXT
@dnet
dnet / youtube.erl
Last active February 22, 2018 15:16
YouTube title plugin for Erlang IRCbot
% depends: https://github.com/talentdeficit/jsx
-module(youtube).
-export([ircmain/1, ircproc/1, reload/2]).
-define(API_KEY, "GetYourOwnApiKeyFromGoogle").
query_gdata_feed(VID) ->
URL = "https://www.googleapis.com/youtube/v3/videos?part=snippet&"
"fields=items/snippet(channelTitle,title)&key=" ?API_KEY "&id=" ++ VID,
@dnet
dnet / direct_blink.ino
Created December 16, 2012 17:39
Arduino workshop: szoftveres teljesítménynövelés (2012. december 13.)
@dnet
dnet / stepper_repl.ino
Created December 6, 2012 19:39
Arduino workshop: nagyobb vasak (2012. december 6.)
// http://hsbp.org/arduino
#include <Stepper.h>
Stepper myStepper(100, 8, 10, 9, 11);
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
Serial.begin(9600);
@dnet
dnet / eeprom_repl.ino
Created December 5, 2012 21:18
Arduino workshop: adattárolás (2012. november 29.)
#include <EEPROM.h>
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
@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,
@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 / 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 / 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 / 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.