Skip to content

Instantly share code, notes, and snippets.

View samacs's full-sized avatar

Saul Martínez samacs

View GitHub Profile
@samacs
samacs / helper.php
Created October 16, 2012 05:58
Simple module to get articles in Joomla >1.6
<?php
abstract class modBreakingNews
{
public function getArticles(&$params)
{
$db =& JFactory::getDbo();
$application =& JFactory::getApplication();
$applicationParams = $application->getParams();
$model = JModel::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
@samacs
samacs / IFormatter.php
Created October 22, 2012 16:23
A set of classes to demonstrate polymorphism.
<?php
/**
* Formatter interface.
*
* A contract to format.
*
* @category Formatter
* @package Formatter
* @author Saul Martinez <[email protected]>
* @copyright 2012 Shark Web Intelligence
try {
$fecha = date('Y-m-d');
$mensajeId = mysql_insert_id();
$path = realpath($_SERVER['DOCUMENT_ROOT'] . DS . '..' . DS . 'adjuntos');
$path = $path . DS . implode(DS, explode('-', $fecha)) . DS . $mensajeId;
if (!file_exists($path)) {
mkdir($path, 0777, true);
}
$file = $_FILES['archivo_adjunto'];

Having the following structure:

/app
|____/config/
     |____endpoints.json
     |____/endpoints/
          |
          |____/module1/
          |    |____contacts.json

| |____agendas.json

#
# voipmonitor.org configuration file
#
# location of this file is at ~/.voipmonitor.conf or /etc/voipmonitor.conf
# command line parameters overrides configuration directives in this file
# allowed comments are ; or #.
#
[general]
class SegmentTree
class Segment
attr_reader :range, :value
def initialize range, value
raise ArgumentError, 'Range expected, %s given' % range.class.name unless range.is_a?(Range)
@range, @value = range, value
end
module CrudManagement
extend ActiveSupport::Concern
module ClassMethods
def crudify(resource_name, model_name = nil, options = {})
model_name ||= resource_name
options[:plural_name] ||= resource_name.to_s.pluralize
options[:singular_name] ||= resource_name.to_s.singularize
options[:permitted_params] ||= []
@samacs
samacs / docker-cleanup-resources.md
Created June 21, 2017 17:01 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@samacs
samacs / Installation.md
Created June 22, 2017 13:57 — forked from albertbori/Installation.md
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->