Skip to content

Instantly share code, notes, and snippets.

View mikaa123's full-sized avatar

Michael Sokol mikaa123

  • Paris, France
View GitHub Profile
@mikaa123
mikaa123 / havesome
Last active August 29, 2015 13:56
Makes your browser drink
-----------------------------------------------------------------------------
"THE BEER-WARE LICENSE" (Revision 42):
<misokol123@gmail.com> wrote this file. As long as you retain this notice you
can do whatever you want with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return. -Michaël Sokol
-----------------------------------------------------------------------------
eval(atob("\
dmFyIGpxID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnc2NyaXB0Jyk7CmpxLnNyYyA9ICIvL2N \
@mikaa123
mikaa123 / gist:a9380af5cd1d56a387ce
Created June 1, 2014 18:32
Simple Api implementation
var express = require('express'),
app = express();
var bodyParser = require('body-parser');
app.use(bodyParser());
var makeResource = require('catnap').makeResource;
// This simulates our datastore.
var users = [{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.vim/plugged')
Plug 'whatyouhide/vim-gotham'
Plug 'https://github.com/kien/ctrlp.vim.git'
Plug 'tpope/vim-sensible'
Plug 'https://github.com/vim-scripts/Smart-Tabs'
Plug 'bling/vim-airline'
@mikaa123
mikaa123 / rake run_jar
Created March 23, 2011 17:14
Rake task to generate and run a jar with Rawr
desc "Generates and run the jar file"
task :run_jar do
puts `rake rawr:clean`
puts `rake rawr:jar`
puts `java -jar deployement/jar/filename.jar
end
@mikaa123
mikaa123 / gist:1382896
Created November 21, 2011 15:08
Executable Markdown file example

Lilplateform

To create lilplateform, we will be using ray library. It's a game engine DSL made for ruby. Have a look (here)[http://mon-ouie.github.com/projects/ray.html] if you don't know about it yet.

All the dependencies of the game are defined in the project's Gemfile, under the "game" group. Let's require them now.

@mikaa123
mikaa123 / my_swt_program.rb
Created June 12, 2012 18:12
SWT + JRuby Bootstrap example
require 'java'
require 'swt'
# Each Swt application need a display to interact with the operating system.
# It provides the event loop.
display = Swt::Widgets::Display.new
# Let's create a new window. It's called "Shell" in Swt vocabulary.
# Note that we pass in a display.
shell = Swt::Widgets::Shell.new(display)
@mikaa123
mikaa123 / gist:4109789
Created November 19, 2012 09:19
Samsung TV cookie module
// Use this as a black-box module to replace joshlib!utils/cookie when developing with
// Samsung TV.
//
// It returns a function to be called with the following parameters:
// name - The key to store.
// data - The value associated with this key.
//
// NOTE: In order to use, you need to expose <script src='$MANAGER_WIDGET/Common/af/2.0.0/loader.js' type='text/javascript'></script>
// in your index file.
//
@mikaa123
mikaa123 / function_strategies.js
Last active December 14, 2015 16:48
Strategies as functions
// Greeter is a class of object that can greet people.
// It can learn different ways of greeting people through
// 'Strategies.'
//
// This is the Greeter constructor.
var Greeter = function(strategy) {
this.strategy = strategy;
};
// Greeter provides a greet function that is going to
@mikaa123
mikaa123 / template_methods.js
Created March 8, 2013 17:03
Strategies and template methods
// Since the GreetingStrategy#execute method uses methods to define its algorithm,
// the Template Method pattern, we can subclass it and simply override one of those
// methods to alter the behavior without changing the algorithm.
var PoliteGreetingStrategy = function() {};
PoliteGreetingStrategy.prototype = Object.create(GreetingStrategy.prototype);
PoliteGreetingStrategy.prototype.sayHi = function() {
return "Welcome sir, ";
};
@mikaa123
mikaa123 / strategy_classes.js
Created March 8, 2013 16:53
Strategies as classes
// We can also leverage the power of Prototypes in Javascript to create
// classes that act as strategies.
//
// Here, we create an abstract class that will serve as the interface
// for all our strategies. It isn't needed, but it's good for documenting
// purposes.
var Strategy = function() {};
Strategy.prototype.execute = function() {
throw new Error('Strategy#execute needs to be overridden.')