Skip to content

Instantly share code, notes, and snippets.

@rpip
rpip / tictactoe.py
Last active October 23, 2021 01:49
Simple Python implementation of the classic Tic Tac Toe game. Goal : Unbeatable AI.
#!/usr/bin/env python
#--------------------------------------------------------------------------
# Tic Tac Toe game in Python
# Author: Mawuli Adzaku <[email protected]>
# Date: 20-05-2013
# Tested with Python 2.7
# TO RUN:
# sudo chmod a+x tictactoe.py
# ./tictactoe.py
# OR JUST RUN : python tictactoe.py
The responses attached to the examples were taken from the Params part of the events method arguments
in the controller as in:
event({_Event, Params, _TriggerId, _TargetId}, Context) ->
io:format("Mod_Buffer Event params : ~p", [Params]).
# 1
{% wire id="delete-{{ buffer.id }}" action={growl text="buffer deleted"} %}
<a id="delete-{{ buffer.id }}" href="#delete-{{ buffer.id }}"><i class="icon-trash"></i>Delete</a>
%% @doc Install the given module
install({Name, Repository}, Context) ->
Site = m_site:get(site, Context),
PrivDir = z_utils:lib_dir(priv),
SiteModulesDir = filename:join([PrivDir, "sites", Site, "modules"]),
ModuleDirname = SiteModulesDir ++ Site ++ Name,
case filelib:is_file(ModuleDirname) of
true ->
z_render:growl(?__("***ERROR: " ++ Name ++ " already installed.", Context), Context);
false ->
@rpip
rpip / events.erl
Last active December 21, 2015 03:09
A simple events hooks and callbacks module. This is my Erlang port of https://github.com/facine/Events
%%%-------------------------------------------------------------------
%%% @author Mawuli Adzaku <[email protected]>
%%% @copyright (C) 2013, Mawuli Adzaku
%%% @doc
%%% A simple events hooks and callbacks module.
%%% @end
%%% Created : 14 Aug 2013 by Mawuli Adzaku <[email protected]>
%%%-------------------------------------------------------------------
-module(events).
@rpip
rpip / zotonic_demoserver_interface.erl
Last active December 31, 2015 20:39
An example webserver interface for Zotonic, similar to the File Service API.
-module(zotonic_demoserver_interface).
-behaviour(zotonic_webserver_interface).
-export([start/1, stop/0, restart/0]).
start(Config) ->
demoserver:start(Config).
stop() ->
demoserver:stop().
@rpip
rpip / gist:9922137
Created April 1, 2014 20:12
Erlang installation prerequisites
sudo apt-get -y install build-essential m4 libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxgtk2.8-dev libglu1-mesa-dev fop xsltproc default-jdk

Keybase proof

I hereby claim:

  • I am mawuli-ypa on github.
  • I am mawuli (https://keybase.io/mawuli) on keybase.
  • I have a public key whose fingerprint is F784 6E89 53C8 037C 8910 AF99 9283 B67A 05C4 E7DD

To claim this, I am signing this object:

@rpip
rpip / service_phpbb_auth.erl
Last active August 29, 2015 13:59
Expose Zotonic authentication via a REST API service. This example is built for use with phpBB authentication as documented here: https://wiki.phpbb.com/Authentication_plugins
-module(service_phpbb_auth).
-svc_title("External Zotonic Authentication service").
%% You can change this to restrict access
-svc_needauth(false).
-export([process_get/2]).
-include_lib("zotonic.hrl").
defmodule DefStructPlusPlus do
@doc """
Macro for defining structs
## Examples
defmodule Models do
import DefStructPlusPlus