Skip to content

Instantly share code, notes, and snippets.

View henrikbjorn's full-sized avatar

Henrik Hauge Bjørnskov henrikbjorn

View GitHub Profile
var MAX_AGENTS_TO_TEST = 200;
function determineAgents(callDuration, calls, periodLength, answerTarget, serviceLevelTarget) {
if(calls === 0) return(0);
for (var agents = 1; agents <= MAX_AGENTS_TO_TEST; agents++) {
if(serviceLevel(callDuration, calls, periodLength, agents, answerTarget) >= serviceLevelTarget) break;
}
return(agents);
}
@henrikbjorn
henrikbjorn / install.sh
Last active August 29, 2015 13:58 — forked from anonymous/install.sh
#!/bin/sh
#
# homebrew-cask
# Install homebrew-cask
brew tap phinze/cask
brew install brew-cask
# Install some quicklook-plugins
brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json quicklook-csv
@henrikbjorn
henrikbjorn / RelDate.php
Created December 5, 2011 08:01 — forked from arnaud-lb/RelDate.php
4 lines relative date formatter with DateInterval and Symfony2 Translator
<?php
use Symfony\Component\Translation\TranslatorInterface;
function format(\DateTime $date, TranslatorInterface $translator)
{
$diff = date_create()->diff($date);
$seconds = $diff->days * 86400 + $diff->h * 3600 + $diff->i * 60 + $diff->s;
$format = $translator->transChoice('reldate', $seconds);
@henrikbjorn
henrikbjorn / BukkitVote oversættelse
Created October 11, 2011 08:03 — forked from tcarlsen/BukkitVote oversættelse
Vi skal lige have oversat BukkitVote til dansk :)
error.accept.already={{RED}}This vote has not been initialized or you already accepted it
error.accept.unknown={{RED}}There is no such vote command
error.permissions={{RED}}You do not have permissions to use this command
error.force.permissions={{RED}}You do not have the permissions to use this command. Generally it is an admin command
error.notonserver={{RED}}{{PLAYER}} is not on this server
force.success={{GREEN}} Forcing event
muted=You are muted!
mute.broadcast={{PLAYER}} has been muted
mute.notmuted={{PLAYER}} is not muted
unmute.broadcast={{PLAYER}} has been unmuted
@henrikbjorn
henrikbjorn / ActiveEntity.php
Created August 16, 2011 08:46 — forked from beberlei/ActiveEntity.php
Doctrine 2.2 Traits Preview
<?php
use Doctrine\ORM\EntityManager,
Doctrine\ORM\Configuration,
Doctrine\ORM\Mapping\ClassMetadata;
/**
* Active Entity trait
*
* Limitations: a class can only ever be assocaited with ONE active entity manager. Multiple entity managers
security:
acl: ~
access_control:
- { path: /admin/.*, roles: [ROLE_ADMIN] }
- { path: /.*, roles: [IS_AUTHENTICATED_ANONYMOUSLY, ROLE_USER] }
encoders:
admin: { algorithm: sha1, class: Sas\CoreBundle\Entity\Account }
providers:
fos_user:
id: fos_user.user_manager
@henrikbjorn
henrikbjorn / php.rb
Created January 12, 2011 21:45 — forked from cranberyxl/php.rb
require 'formula'
def mysql_installed?
`which mysql_config`.length > 0
end
class Php <Formula
url 'http://www.php.net/get/php-5.3.5.tar.gz/from/this/mirror'
homepage 'http://php.net/'
md5 'fb727a3ac72bf0ce37e1a20468a7bb81'
<?php
namespace Symfony\Bundle\FrameworkBundle\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;
use Symfony\Bundle\FrameworkBundle\Util\Filesystem;
<?php
function checkEmail($email) {
// checks proper syntax
if(preg_match("/^([a-z])([a-z0-9._])+([a-z0-9])\@([a-z0-9])*([a-z])+(-[a-z])*([a-z0-9])*(\.([a-z0-9])*([a-z])+(-[a-z])*([a-z0-9])*)+$/i" , $email)) {
// gets domain name
list($username, $domain) = split('@', $email);
// checks for if MX records in the DNS
if(checkdnsrr($domain, 'MX')) {
<?php
class DownloaderComponent extends Object
{
public function sendFileHeaders($path)
{
$handle = finfo_open(FILEINFO_MIME_TYPE);
$contentType = finfo_file($handle, $path);
$extension = path_info($path, PATHINFO_EXTENSION); //Better way to get the extension
header("Pragma: public");