Skip to content

Instantly share code, notes, and snippets.

@pvalencia
pvalencia / gist:166334
Created August 12, 2009 05:04
como hacer trim de una url en cakephp con tr.im
<?php
/**
* Hacer tr.im de una URL en cakephp
*/
function trim($url) {
// Quizás esto debiese ir en un archivo de configuración
$username = 'TR.IM_USERNAME';
$password = 'TR.IM_PASSWORD';
App::import('Core', array('Xml', 'HttpSocket')); //Esto va acá?
@pvalencia
pvalencia / gist:166613
Created August 12, 2009 17:06
saving users with ACL in cakephp
<?php
/**
* Cambia el parent_id del aro asociado al correspondiente al nuevo grupo
*/
function afterSave($created) {
if(!$created && $this->id && isset($this->data['Usuario']['grupo_id'])) {
$aro = $this->Aro->find('first',
array(
'conditions' => array(
'model' => 'Usuario',
@pvalencia
pvalencia / gist:166672
Created August 12, 2009 19:03
twiteando con cakephp
<?php
function tweet($status) {
$username = 'TWITTER_USERNAME';
$password = 'TWITTER_PASSWORD';
App::import('Core', array('Xml', 'HttpSocket'));
$sckt = new HttpSocket();
$res = $sckt->request(
array(
'method' => 'POST',
@pvalencia
pvalencia / gist:167635
Created August 14, 2009 03:52
async but not ajax cross-site
<html>
<head></head>
<body>
<ul id="tweets">
</ul>
<a href="#">reload tweets</a>
<script src="jquery-1.3.2.min.js"></script>
<script>
function updateTwitter(tweets) {
var uls = '';
/* Based on gist: 26061 by bastos. */
CmdUtils.CreateCommand({
names: ["code"],
icon: "http://www.github.com/favicon.ico",
author: {name: "Pedro Valencia", email: "pvalencia+github@gmail.com"},
license: "GPL",
homepage: "http://gist.github.com/gists/168442",
description: "Search on Github Code Search",
help: "Search on Github Code Search",
arguments: [{role: 'object', nountype: noun_arb_text, label: 'function'}],
@pvalencia
pvalencia / gist:169204
Created August 17, 2009 15:55
example for twitter-cakephp-component
<?php
class FooController extends AppController {
var $components = array('Twitter');
function bar() {
/* authentication */
$this->Twitter->username = 'foo';
$this->Twitter->password = 'bar';
$this->set('statuses',
// ==UserScript==
// @name Esconder nuevos en instituciones
// @namespace u-cursos
// @include https://www.u-cursos.cl/*
// ==/UserScript==
nuevos = document.getElementById('instituciones').getElementsByClassName('nuevo');
for(el in nuevos) {
el = nuevos[el];
el.style.display = 'none';
}
// ==UserScript==
// @name U-Cursos Slider Menu
// @namespace u-cursos
// @include https://www.u-cursos.cl/*
// ==/UserScript==
(function(){
GM_xmlhttpRequest({
method: "GET",
url: "http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js",
\documentclass[letterpaper,12pt]{article}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
%%%%%%%%%%%%%%%%%%%%%%%%%%% PORTADA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1pt\hfill \kern \z@}
\renewcommand{\maketitle}{\begin{titlepage}%
\let\footnotesize\small
<?php
class DATABASE_CONFIG {
var $development = array(
'driver' => 'sqlite',
'persistent' => false,
'host' => '',
'login' => '',
'password' => '',
'database' => 'development.sqlite',