Skip to content

Instantly share code, notes, and snippets.

View merolhack's full-sized avatar

Lenin Jose Meza Zarco merolhack

View GitHub Profile
@emersonmoretto
emersonmoretto / benchmark.sh
Created August 9, 2011 21:06
Apache bench + Gnuplot Script
#!/bin/bash
echo -e "\nbenchmark.sh -n<number of requests> -c<number of concurrency> <URL1> <URL2> ..."
echo -e "\nEx: benchmark.sh -n100 -c10 http://www.google.com/ http://www.bing.com/ \n"
## Gnuplot settings
echo "set terminal png
set output 'benchmark_${1}_${2}.png'
set title 'Benchmark: ${1} ${2}'
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@fernandoaleman
fernandoaleman / Linux Static IP
Created March 23, 2012 16:20
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@bcoughlan
bcoughlan / validation.js
Created May 9, 2012 21:51
jQuery validation - IP address
//Validation
jQuery.validator.addMethod('validIP', function(value) {
var split = value.split('.');
if (split.length != 4)
return false;
for (var i=0; i<split.length; i++) {
var s = split[i];
if (s.length==0 || isNaN(s) || s<0 || s>255)
return false;
@bickart
bickart / repair.php
Created April 26, 2013 15:29
How to perform a SugarCRM Quick Repair and Rebuild from the line
#!/usr/bin/php
<?php
/*
* Copyright 2013
* Jeff Bickart
* @bickart
* jeff @ neposystems.com
*/
@PizzaBrandon
PizzaBrandon / jquery.waituntilexists.js
Last active August 24, 2023 14:23 — forked from buu700/jquery.waituntilexists.js
Updated waitUntilExists plugin
;(function ($, window) {
var intervals = {};
var removeListener = function(selector) {
if (intervals[selector]) {
window.clearInterval(intervals[selector]);
intervals[selector] = null;
}
@johnkary
johnkary / freetds.conf
Created September 20, 2013 21:01
Configure FreeTDS to connect from Linux to MSSQL and allow specifying a custom character set. The file location varies based on distribution, but two I've found: Ubuntu /etc/freetds/freetds.conf and Red Hat Enterprise Linux (RHEL) /etc/freetds.conf
[global]
# TDS protocol version
tds version = 7.0
client charset = UTF-8
@rnkoaa
rnkoaa / app.js
Created January 9, 2014 13:14
A simple angularjs with angular-ui modal form which includes validation on the client side. Thanks http://scotch.io/tutorials/javascript/angularjs-form-validation
var app = angular.module("modalFormApp", ['ui.bootstrap']);
app.controller("modalAccountFormController", ['$scope', '$modal', '$log',
function ($scope, $modal, $log) {
$scope.showForm = function () {
$scope.message = "Show Form Button Clicked";
console.log($scope.message);
var modalInstance = $modal.open({
@amusarra
amusarra / sugarcrm-dev-7-1.conf
Created March 9, 2014 21:33
SugarCRM 7.1 NGINX Config File
server {
listen 8090;
server_name sugarcrmdev-71.dontesta.local;
#charset koi8-r;
access_log /var/log/nginx/sugarcrmdev-71.dontesta.local.access.log main;
error_log /var/log/nginx/sugarcrmdev-71.dontesta.local.error.log;
root /home/sugarcrm/application;
index index.php index.html;
@betobaz
betobaz / custom_modules_Activities_ActivitiesLogicHookCustom.php
Created November 5, 2014 02:20
SugarCRM Notifications like facebook
<?php
class ActivitiesLogicHookCustom{
public function notifyActivity($bean, $event, $arguments){
if($bean->module_name == 'Activities'){
global $current_user;
$data = json_decode($bean->data);
$message = preg_replace('/(\@)\[\w+\:[a-f0-9-]{36}\:([\w ]+)\]/u', '$1$2', $data->value);
foreach($data->tags as $tag){
if($tag->module == 'Users'){
$notification = BeanFactory::newBean('Notifications');