Skip to content

Instantly share code, notes, and snippets.

Sofian Benaissa sfyn

Block or report user

Report or block sfyn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sfyn
sfyn / showCkutStream.js
Created May 12, 2011
Javascript function to show an element only during a specific time, depends on jQuery
View showCkutStream.js
// Initialize some variables - we will use GMT times
var checkDate = new Date();
var offTheHourStarts = 21;
var offTheHourEnds = 22;
// Adjust for Daylight savings
if ((checkDate.getMonth() < 2 && checkDate.getMonth() > 10) || (checkDate.getMonth() == 2 && checkDate.getDate()-checkDate.getDay() > 7 ) || (checkDate.getMonth() == 10 && checkDate.getDate()-checkDate.getDay() > 1)) {
offTheHourStarts--;
offTheHourEnds--;
}
@sfyn
sfyn / template.php
Created May 12, 2011
Drupal 6 theme functions to insert a jcarousel that uses lightbox into any node with the appropriate image field, for use in a template.php file
View template.php
<?php
/**
* Node preprocess function
*/
function mytheme_preprocess_node(&$vars, $hook) {
if ($vars['node']->field_image && !empty($vars['node']->field_image)) {
$vars['image_carousel'] = _mytheme_generate_carousel($vars['node']->field_image);
}
}
@sfyn
sfyn / gist:1025146
Created Jun 14, 2011
redmine stealth button blinker
View gist:1025146
/**
* Paste this code into your greasemonkey or browser console to enable
* deep defense against redmine's stealth mode
*/
stealthButton = document.getElementById('stealth_toggle');
blonk = 0
if (stealthButton.innerHTML == 'Disable stealth mode')
{
setInterval ('blink(stealthButton)', 500);
@sfyn
sfyn / file.inc_ereg_to_preg.patch
Created Oct 26, 2011
ereg to preg patch for Drupal 6.22 includes/files.inc
View file.inc_ereg_to_preg.patch
From 45eaed831098fe253b0089517b3bdc8ac51f8d66 Mon Sep 17 00:00:00 2001
From: Sofian Benaissa <sofian@koumbit.org>
Date: Wed, 26 Oct 2011 13:48:54 -0400
Subject: [PATCH] ereg to preg in file.inc
---
includes/file.inc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/includes/file.inc b/includes/file.inc
@sfyn
sfyn / .bashrc
Created Oct 28, 2011
dev environment aegir user .bashrc
View .bashrc
# WARNING: This should be used in private, dev environments ONLY
# Not for production environments
#
# This files adjusts the aegir users bash environment to make certain
# common development tasks a little easier
# Make sure aegir files are group=-writable
umask 0002
# Aliases to make development a little easier
@sfyn
sfyn / koumbit-ledger-smb.user.js
Created Nov 4, 2011
Billing workflow for LedgerSMB
View koumbit-ledger-smb.user.js
// ==UserScript==
// @name Koumbit LedgerSMB billing workflow
// @match https://ledger.koumbit.net/*
// ==/UserScript==
/**
* @file
* Email templates and interface tweaks for ledger SMB emails
*
* Licensed under GPLv2.
@sfyn
sfyn / pad.js
Created Mar 28, 2012
custom pad.js file for etherpad-lite allows setting author names as line numbers
View pad.js
/**
* @file
* This file is an example of ways to modify etherpad-lite behaviour from the
* static/custom/pad.js file generated by etherpad-lite on first run.
*/
var edBod = [];
var lastLine = 0;
/**
@sfyn
sfyn / gist:7622365
Created Nov 24, 2013
Ongoing work on a java imp of a B+tree
View gist:7622365
import java.util.*;
/**
* B+ Tree generic type
*
* @author Sofian Benaissa
*/
public class BplusTree<K extends Comparable<K>,V>
{
@sfyn
sfyn / Formula.java
Created Jan 23, 2014
Demonstrate a way to parse a mathematical
View Formula.java
import java.util.LinkedList;
/**
* This class allows the calculation of a mathematical formula
*/
public class Formula {
private String formula;
private double result;
/**
You can’t perform that action at this time.