This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RegexRouter | |
{ | |
private $routes = array(); | |
public function addRoute($route, callable $service) | |
{ | |
$route = '#^'.$route.'$#'; | |
$this->routes[$route] = $service; | |
return $this; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sorts by weight | |
$data = array( | |
array( | |
'language' => 'PHP', | |
'weight' => 50, | |
), | |
array( | |
'language' => 'Java', | |
'weight' => 20, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type ( | |
ListKey string | |
ListVal interface{} | |
) | |
type ArrayList struct { | |
list map[ListKey]ListVal | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://play.golang.org/p/zu7mtEWy7e | |
package main | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"math/rand" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Number float64 | |
func (n *Number) Increase() { | |
*n++ | |
} | |
func (n *Number) Decrease() { | |
*n-- | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Sleep Service | |
Requires=docker.service | |
# Dependency ordering | |
After=docker.service | |
[Service] | |
Restart=always | |
ExecStartPre=-/usr/bin/docker rm %p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2015 The Nanoninja Authors. All rights reserved. | |
package container | |
// ServiceFunc registers the service function. | |
type ServiceFunc func(c *container) interface{} | |
type container struct { | |
name string | |
services map[string]interface{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2015 The Nanoninja Authors. All rights reserved. | |
package box | |
import "time" | |
// ServiceFunc registers the service function. | |
type ServiceFunc func(b *Box) interface{} | |
type Box struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get random data | |
function getRandScore($nb = 10) { | |
$data = array(); | |
for ($i = 0; $i < $nb; $i++) { | |
$data[] = rand(5, 299); | |
} | |
return $data; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
) | |
func myHandler(w http.ResponseWriter, r *http.Request) { | |
w.Write([]byte("myHandler\n")) |
OlderNewer