Skip to content

Instantly share code, notes, and snippets.

class Circle
{
public $radius;
public function __construct($radius): void
{
$this->radius = $radius;
}
}
@jdeveloper
jdeveloper / selenium.sh
Created June 1, 2016 10:32
bash script to start selenium
#!/bin/bash
case "${1:-''}" in
'start')
if test -f /tmp/selenium.pid
then
echo "Selenium is already running."
else
export DISPLAY=localhost:99.0
java -jar /usr/lib/selenium/selenium-server-standalone.jar -port 4444 -trustAllSSLCertificates > /var/log/selenium/output.log 2> /var/log/selenium/error.log & echo $! > /tmp/selenium.pid
@jdeveloper
jdeveloper / databases.yml
Created April 14, 2011 08:08
Configur sql logging in symfony with doctrine
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: 'mysql:host=HOST;dbname=DBNAME'
username: USERNAME
password: PASSWORD
profiler: true
logging: true
<?php
/**
* For now only works with Text filters and only for sfFormFilterDoctrine
* The problem of not escaping quotes was found with mysql
* Since the task doctrine:build-filters generates all formfilters extended from BaseFormFilterDoctrine we rewtirte there the addTextQuery method
*/
abstract class BaseFormFilterDoctrine extends sfFormFilterDoctrine
{
public function setup()
{
#function that takes an array and a block and aplies the block to each element in a thread returning the results in a array
#it is in fact a parallel map
def parmap(arr,&block)
threads = arr.map do |element|
Thread.new do
block.call(element)
end
end
threads.each { |th| th.join }
threads.map { |th| th.value}
//function to define a class
// actual version is a rewrite by anieto2k: http://www.anieto2k.com
//params:
// @current : Object with the methods and attributes of the class
// @previous : Class from witch we wante to extend (optional)
JotaClass = function(current,previous){
previous = typeof previous == 'undefined' ? {} : previous.prototype;
for(p in previous){
if(typeof current[p] == 'undefined') current[p] = previous[p];
else if(typeof previous[p] == 'function'){