Skip to content

Instantly share code, notes, and snippets.

@cmpscabral
cmpscabral / backup.sh
Created August 18, 2014 11:38
backup script example
#!/bin/sh
renice 19 -p $$
ionice -c 3 -p $$
# change to script folder
cd ${0%/*}
TODAY=`date --rfc-3339=ns`
@cmpscabral
cmpscabral / gist:111b1d2a44ae9a9c030c
Last active August 29, 2015 14:04
create samba shares
(install samba)
> apt-get install samba-common-bin samba
(create group sambashare)
> groupadd sambashare
(add current user to group sambashare)
> adduser `whoami` sambashare
(create share)
> openssl pkcs12 -in <cert.pfx> -out <cert.pem> -nodes
The command converts the data in the <cert.pfx> file to PEM format in the <cert.pem> file. The PEM file contains all of the certificates that were in the PFX file:
- Private key
- Identity certificate
- Root certificate
- Intermediate certificate
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1, target-densityDpi=device-dpi">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="assets/libs/jquery.mobile-1.3.1/jquery.mobile-1.3.1.min.css" />
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
function hostReachable() {
// Handle IE and more capable browsers
var xhr = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" );
var status;
var server = window.location.hostname;
if (window.location.port != '') {
server += ':'+window.location.port;
}

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@cmpscabral
cmpscabral / gist:9879190
Created March 30, 2014 20:23
joomla component/module/plugin parameters
Plugin parameters from inside a plugin
$param = $this->params->get('paramName', 'defaultValue');
Plugin parameters from outside a plugin
$plugin = &JPluginHelper::getPlugin('exampleType', 'example');
$pluginParams = new JParameter($plugin->params);
$param = $pluginParams->get('paramName', 'defaultValue');
Module parameters from inside a module
checkProvadoresEscolhidos : function() {
// se ainda não temos provadores escolhidos, posso alterar à vontade
if (sessoes_edit.dtgHorariosProvadoresEscolhidos == 0) {
return true;
}
// se não, tenho que confirmar se vou fazer asneiras
var txtDataInicio = $('#dtgHorariostxtDataInicio');
var txtDataFim = $('#dtgHorariostxtDataFim');
var txtHoraInicio = $('#dtgHorariostxtHoraInicio');
@cmpscabral
cmpscabral / redirect
Created January 22, 2014 15:18 — forked from codepo8/redirect
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
# allowed domains, add as needed
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?christianheilmann.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wait-till-i.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mozilla.org [NC]
# search engines and social sites and stuff