Skip to content

Instantly share code, notes, and snippets.

View ychaouche's full-sized avatar

Yassine Chaouche ychaouche

View GitHub Profile
@ychaouche
ychaouche / gist:3888918
Created October 14, 2012 15:29
lazy version of the ADN parser
def is_valid_sequence(sequence):
for character in sequence:
if character not in "ACTG":
return False
return True
@ychaouche
ychaouche / gist:3888973
Created October 14, 2012 15:47
better version of the lazy ADN parse
is_valid_sequence = lambda x:all(character in "ACTG" for character in x)
>>> is_valid_sequence("ACTG")
True
>>> is_valid_sequence("ACTGAAA")
True
>>> is_valid_sequence("ACTGa")
False
>>>
@ychaouche
ychaouche / gist:3937786
Created October 23, 2012 09:11
regular expressions in javascript example
var myString = "0h 1m 40s",
matches = myString.match(/(\d+)h (\d+)m (\d+)s/),
hours = matches[1],
mins = matches[2],
secs = matches[3];
console.debug(hours, mins, secs);
console.debug(matches);
@ychaouche
ychaouche / sugarcrm_restapi_test.php
Created October 25, 2012 13:50
The test file for SugarCRM Rest API.
<?php
/*********************************************************************************
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
@ychaouche
ychaouche / gist:4054292
Created November 11, 2012 09:31
vhost sugarcrm.conf
<VirtualHost *:80>
ServerName sugarcrm.localhost
DocumentRoot "/srv/www/htdocs/sugarcrm/"
ErrorLog /var/log/apache2/errors/sugarcrm.log
CustomLog /var/log/apache2/access/sugarcrm.log combined
<Directory "/srv/www/htdocs/sugarcrm/">
# Options Indexes +FollowSymLinks -SymLinksIfOwnerMatch
Options All
AllowOverride None
Order allow,deny
@ychaouche
ychaouche / gist:4054293
Created November 11, 2012 09:32
ls /serv/www/htdocs/
fictive chaouche # ls /srv/www/htdocs/
total 20K
drwxr-xr-x 2 wwwrun www 4.0K Jan 15 2012 gif
-rw-r--r-- 1 wwwrun www 6 Feb 9 2012 index.html
-rw-r--r-- 1 wwwrun www 2.4K Oct 22 2011 info2html.css
drwxr-xr-x 6 root root 4.0K Nov 6 10:16 phpMyAdmin
lrwxrwxrwx 1 wwwrun www 52 Nov 8 14:12 sugarcrm -> /home/chaouche/DOWNLOADS/WEBAPPS/SugarCE-Full-6.5.7/
drwxr-xr-x 7 wwwrun www 4.0K Feb 9 2012 wiki
fictive chaouche #
@ychaouche
ychaouche / gist:4054296
Created November 11, 2012 09:33
ls /srv/www/htdocs/sugarcrm/
fictive chaouche # ls /srv/www/htdocs/sugarcrm/
total 984K
-rw-r--r-- 1 wwwrun www 2.5K Oct 25 19:22 acceptDecline.php
drwxr-xr-x 10 wwwrun www 4.0K Oct 25 19:22 cache
-rw-r--r-- 1 wwwrun www 3.4K Oct 25 19:22 campaign_tracker.php
-rw-r--r-- 1 wwwrun www 2.5K Oct 25 19:22 campaign_trackerv2.php
-rw-r--r-- 1 wwwrun www 0 Oct 25 19:22 config_override.php
-rw-r--r-- 1 wwwrun www 0 Oct 25 19:22 config.php
[...]
@ychaouche
ychaouche / gist:4054300
Created November 11, 2012 09:34
namei -m /srv/www/htdocs/sugarcrm/
fictive chaouche # namei -m /srv/www/htdocs/sugarcrm/
f: /srv/www/htdocs/sugarcrm/
drwxr-xr-x /
drwxr-xr-x srv
drwxr-xr-x www
drwxr-xr-x htdocs
lrwxrwxrwx sugarcrm -> /home/chaouche/DOWNLOADS/WEBAPPS/SugarCE-Full-6.5.7/
drwxr-xr-x /
drwxr-xr-x home
drwxr-xr-x chaouche
@ychaouche
ychaouche / gist:4054311
Created November 11, 2012 09:41
symbolic link not allowed or link target not accessible.
[error] [client 127.0.0.1] Symbolic link not allowed or link target not accessible: /srv/www/htdocs/sugarcrm
@ychaouche
ychaouche / gist:4117861
Created November 20, 2012 13:09
transform a where to a join
SELECT contacts.first_name, contacts.last_name, email_addresses.email_address
FROM
contacts
INNER JOIN email_addr_bean_rel
ON contacts.id = email_addr_bean_rel.bean_id
INNER JOIN email_addresses
ON email_addresses.id = email_addr_bean_rel.email_address_id
WHERE email_addresses.email_address = '[email protected]'