Skip to content

Instantly share code, notes, and snippets.

@mloberg
mloberg / watermark.html
Created June 23, 2011 18:40
Watermark PHP
<img src="watermark.php?watermark=watermark.png&src=test.jpg" />
@miguelramos
miguelramos / PHP-ELEMENT-Search.php
Created March 6, 2012 23:31
PHP: Search element in array recursive
<?php
/**
* Function to search for key/value in recursive mode. If last arg is true
* it returns it's value or key. By default give true or false if key/value have been found.
*
* @param array $array Array to search
* @param string $search What to search
* @param string $mode Mode search for value or key
* @param boolean $return Return value or key
@nghuuphuoc
nghuuphuoc / 1) Install
Last active September 4, 2023 09:29
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
@denji
denji / nginx-tuning.md
Last active May 3, 2024 03:57
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@elena-kolevska
elena-kolevska / validators.php
Last active June 24, 2021 14:44
Custom alphabetic validator that allows spaces
<?php
/* app/validators.php */
Validator::extend('alpha_spaces', function($attribute, $value)
{
return preg_match('/^[\pL\s]+$/u', $value);
});
/*
@bocharsky-bw
bocharsky-bw / hgfs-shared-folder-permissions
Created July 5, 2014 11:00
Permissions on Shared Folders on Ubuntu
http://viraj-workstuff.blogspot.com/2013/07/vmware-fusion-permissions-on-shared.html
VMware Fusion - Permissions on Shared Folders on Ubuntu
VMware Fusion provides a nice functionality of sharing folder from host (Mac OSX) to guest (Ubuntu). But then, it seems they are more focused on windows guests, because they screwup on file permissions of shared folders.
"ls -al /mnt/hgfs" will show 501 dialout as user and group, which is sure to cause permission issues on linux guest.
Update: Found a more persistent alternative
1. sudo vim /etc/vmware-tools/services.sh
2. Search for 'vmhgfs_mnt="/mnt/hgfs"'. After this line add: 'vmuser=${VMWARE_MNT_USER:-root}'
@jacobtwlee
jacobtwlee / UploadSupportDetection.js
Last active July 16, 2019 13:59
Upload support detection
function isUploadSupported() {
if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) {
return false;
}
var elem = document.createElement('input');
elem.type = 'file';
return !elem.disabled;
};
@Kryptonit3-zz
Kryptonit3-zz / .gitignore
Last active July 13, 2018 18:15
Lightweight image cropping with jQuery
# Ignore everything in this directory
*
# Except this file
!.gitignore
@jashmenn
jashmenn / self-eq-this-vs-bind.md
Last active September 6, 2022 23:11
Javascript var self = this; vs. .bind

The Problem

In Javascript this is bound in unexpected ways. Functions, in particular, create a new 'this' and so when you want to keep a reference to an "outer" object you sometimes see the pattern:

var self = this;

as in:

var self = this;
@taotao
taotao / Debian_Mail_Server_with_Anti-Virus.md
Last active January 13, 2021 12:50
Debian Exim4 mail server with Clamav support.

Environment

  • Debian: Jessie
  • Mail Server: Exim
  • Anti-Virus: Clamav

Install packages

  1. apt-get install clamav clamav-daemon exim4-daemon-heavy

Configuration of Clamav

  1. Modify /etc/clamav/clamd.conf