Skip to content

Instantly share code, notes, and snippets.

/*
The MIT License (MIT)
Copyright (c) 2014 Ismael Celis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@codypo
codypo / monitex
Created April 6, 2011 14:21
Monit example for restarting a service on excessive memory consumption
# Relevant example from our monitrc file.
check process couchdb with pidfile /usr/local/var/run/couchdb/couchdb.pid
start program = "/etc/init.d/couchdb start"
stop program = "/etc/init.d/couchdb stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 70% MB for 5 cycles then restart
@franck
franck / monitrc
Created December 1, 2011 11:11
monit config file (nginx, mysql, redis, tomcat)
###############################################################################
## Monit control file
###############################################################################
##
## Comments begin with a '#' and extend through the end of the line. Keywords
## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.
##
## Below you will find examples of some frequently used statements. For
## information about the control file, a complete list of statements and
## options please have a look in the monit manual.
@madoke
madoke / XSSRequestWrapper.java
Created April 9, 2012 22:23 — forked from ulinkwo/XSSRequestWrapper.java
Stronger Anti Cross-Site Scripting (XSS) Filter for Java Web Apps
package pt.impresa.iweb.filters.request;
import java.io.IOException;
import java.text.Normalizer;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
@gathercontent
gathercontent / AutoVersion.php
Created June 19, 2012 12:56
AutoVersion.php for GatherContent.com
<?
class AutoVersion {
public function fly($folder, $files_array = array(), $content_type = 'text/css', $compress = true) {
$code = '';
$path = $_SERVER['DOCUMENT_ROOT'] . $folder;
$last_modified = $this->last_modified($folder, $files_array);
$max_age = 60 * 60 * 24 * 365; // refresh if older than a year
@mps
mps / deploying.md
Created June 21, 2012 14:54
Free WordPress Hosting on Heroku

Deploy to Heroku

$ git push heroku production:master
> -----> Heroku receiving push
> -----> PHP app detected
> -----> Bundling Apache v2.2.19
> -----> Bundling PHP v5.3.6
> -----> Discovering process types

> Procfile declares types -> (none)

@chrisjlee
chrisjlee / rhel-recommended-partition-sizes.txt
Last active March 4, 2023 01:18
ubuntu recommended partition sizes
@Darep
Darep / .htaccess
Last active April 23, 2024 07:16
PHP CSS&JS auto-versioning function.
# CSS/JS auto-versioning
RewriteEngine On
RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]
@robatron
robatron / javascript-log-wrapping.md
Last active February 6, 2024 06:49
Wrapping `console.log` (et al.) in your own function to modify logging behavior.

JavaScript Log Wrapping

Wrapping console.log (et al.) in your own function to modify logging behavior.

Why?

You may want a simple way to:

@chrislkeller
chrislkeller / import_json_appsscript.js
Last active July 16, 2024 13:26
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();