Skip to content

Instantly share code, notes, and snippets.

View messaoudi-mounir's full-sized avatar

Messaoudi Mounir messaoudi-mounir

View GitHub Profile
@messaoudi-mounir
messaoudi-mounir / Context.Service.ts
Created July 8, 2021 14:33 — forked from dmorosinotto/Context.Service.ts
Angular Context.Service used to share data (aka state) across components - It's a "dynamic reactive DI" - sample usage: https://stackblitz.com/edit/angular-context-service
import { Injectable, OnDestroy, Optional, SkipSelf } from "@angular/core";
import { Observable, Observer, BehaviorSubject, Subject } from "rxjs";
import { takeUntil, filter } from "rxjs/operators";
import { InjectionToken } from "@angular/core";
@Injectable()
export class ContextService implements OnDestroy {
constructor(@Optional() @SkipSelf() private _parent?: ContextService) {}
private _destroy$ = new Subject<void>();
# Clone the .vmdk image to a .vdi.
vboxmanage clonehd "virtualdisk.vmdk" "new-virtualdisk.vdi" --format vdi
# Resize the new .vdi image (30720 == 30 GB).
vboxmanage modifyhd "new-virtualdisk.vdi" --resize 30720
# Optional; switch back to a .vmdk.
VBoxManage clonehd "new-virtualdisk.vdi" "resized-virtualdisk.vmdk" --format vmdk
@messaoudi-mounir
messaoudi-mounir / test
Created November 15, 2015 19:10
test1
http://besmenaas-s.akamaihd.net/live/233720_233721/besmena03s.isml/Manifest?primaryToken=1447620051_9eb02fd5dbf0d0dfdd0d8c8c24550a62
@messaoudi-mounir
messaoudi-mounir / CalendarDateRangeValidator
Created April 26, 2015 14:09
Jsf - default global validator for all or specific componant (Primefaces example)
package commons.web.jsf.validator;
import java.util.Date;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
@messaoudi-mounir
messaoudi-mounir / Calendar.java
Created April 26, 2015 14:04
Override Primefaces componant validator (Calendar mindate/maxdate)
package commons.web.primefaces.component.calendar;
import commons.web.jsf.validator.CalendarDateRangeValidator;
public class Calendar extends org.primefaces.component.calendar.Calendar {
public Calendar() {
super();
this.addValidator(new CalendarDateRangeValidator());
}
@messaoudi-mounir
messaoudi-mounir / budddypress-facebook-activity-time-style
Created January 30, 2014 12:47
Buddypress - Change activity since time like Facebook time style
//---------------------------------------------------//
// Change activity since time like Facebook time style
//---------------------------------------------------//
add_filter('bp_activity_time_since', 'bp_activity_time_since_newformat', 10, 2);
function bp_activity_time_since_newformat( $time_since, &$actvitiy ) {
$timestamp_now = time();
$timestamp_activity_date_recorded = strtotime( $actvitiy->date_recorded );
@messaoudi-mounir
messaoudi-mounir / Buddypress_change_data_format
Last active August 6, 2017 02:35
Buddypress - Change activity & comments date format
//---------------------------------------------------//
// Change activity since time to exact data+time
//---------------------------------------------------//
add_filter('bp_activity_time_since', 'bp_activity_time_since_newformat', 10, 2);
function bp_activity_time_since_newformat( $time_since, &$actvitiy ) {
// you can change the date format to "Y-m-d H:i:s"
$time_since = '<span class="time-since">' . date_i18n("F j, Y", strtotime( $actvitiy->date_recorded ) ) . '</span>';
return $time_since;
@messaoudi-mounir
messaoudi-mounir / bp_remove_favorites_functionality.php
Created January 21, 2014 16:09
Buddyperss - How to remove "Favorite" function from Buddypress
add_filter( 'bp_activity_can_favorite', '__return_false' );
add_filter( 'bp_get_total_favorite_count_for_user', '__return_false' );
function bp_admin_bar_render_remove_favorites() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('my-account-activity-favorites');
}
add_action( 'wp_before_admin_bar_render', 'bp_admin_bar_render_remove_favorites' );
@messaoudi-mounir
messaoudi-mounir / change_buddypress_groups_slug.php
Created January 21, 2014 00:08
Buddypress - Change Groups slug
// add this code to functions.php
// then edit groups page from wpadmin pages ( change permalink slug to "your_new_slug_for_groups" ) and save!
add_filter('bp_get_groups_root_slug', 'bp_change_groups_root_slug');
function bp_change_groups_root_slug( $group ){
return "your_new_slug_for_groups"; //For example "gatherings"
}
@messaoudi-mounir
messaoudi-mounir / remove_all_members_tab.php
Last active January 3, 2016 21:49
Buddypress - Remove "All members" on Members directory ( javascript trick )
//add this code to functions.php
function bp_remove_allmembers_tab_js_script(){ ?>
<script type="text/javascript">
var jq = jQuery;
jQuery(document).ready(function (jQuery) {
jq('#members-all').removeClass('selected').hide();
jq('#members-personal').find('a').trigger('click');
});