Skip to content

Instantly share code, notes, and snippets.

View AstDerek's full-sized avatar

Ast Derek AstDerek

View GitHub Profile
@AstDerek
AstDerek / event.rb
Created January 8, 2013 03:58
Simple Rails app compatible with DHTMLX Scheduler http://www.dhtmlx.com/docs/products/dhtmlxScheduler/index.shtml
class Event < ActiveRecord::Base
attr_accessible :_timed, :details, :end_date, :start_date, :text
# From http://www.dhtmlx.com/docs/products/dhtmlxScheduler/xml/events.xml
def to_xml (options = {})
options[:indent] ||= 2
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
xml.instruct! unless options[:skip_instruct]
xml.event(:id => id, :timed => _timed) do
xml.text text
@AstDerek
AstDerek / agregar_nueva_linea.c
Created November 8, 2012 08:10
Agregar nueva línea
void agregar_nueva_linea () {
segmento *ultimo_segmento;
char linea[ANCHO_LINEA];
int continuar = 1;
while (continuar) {
fgets(linea,ANCHO_LINEA,stdin)
/* Si hay una nueva línea, es que acabamos de procesar el texto */
if (linea[strlen(linea) - 1] == '\n') {
@AstDerek
AstDerek / final.c
Created November 4, 2012 19:17
Editor de texto simple
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*#define TECLA_ARRIBA 72*/
/*#define TECLA_ABAJO 80*/
/* El programa fue probado a través de SSH, no funcionan las flechas */
#define TECLA_ARRIBA 'r'
#define TECLA_ABAJO 'b'
@AstDerek
AstDerek / combinaciones.cpp
Created October 3, 2012 14:22
Combinaciones finales
#include <iostream>
#include <stdlib.h>
using namespace std;
// copiar un array en otro
// si *copia es NULL, se aloja memoria para guardarlo
double *copiar (double *array, double *copia, unsigned long longitud) {
if (!copia) {
copia = (double *)calloc(longitud,sizeof(double));
@AstDerek
AstDerek / combinaciones-debug.cpp
Created October 3, 2012 14:17
Combinaciones mostradas paso a paso
#include <iostream>
#include <stdlib.h>
using namespace std;
// copiar un array en otro
// si *copia es NULL, se aloja memoria para guardarlo
double *copiar (double *array, double *copia, unsigned long longitud) {
if (!copia) {
copia = (double *)calloc(longitud,sizeof(double));
@AstDerek
AstDerek / order-methods.php
Created October 2, 2012 19:24
Métodos de ordenación
<?php
set_time_limit(0);
ini_set('memory_limit','128M');
function burbuja ($v,&$metodo) {
$tmp = $v[0];
$N = count($v);
$metodo['burbuja']['tiempo'] = microtime(true);
@AstDerek
AstDerek / quicksort.cpp
Created October 2, 2012 19:23
Implementación simple de Quick Sort
#include <iostream>
using namespace std;
void intercambiar_int (int *a, int *b) {
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
@AstDerek
AstDerek / fca_en_linea.js
Created September 20, 2012 21:52
Remodelación de Moodle/FCA en Línea
// ==UserScript==
// @name FCA en linea
// @namespace fca_en_linea
// @include http://fcaenlinea1.unam.mx/informatica/escritorio/
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @version 1
// @grant none
// ==/UserScript==
/**
@AstDerek
AstDerek / oauth.php
Created May 11, 2012 02:26
Some Oauth
<?php
class Google_OAuth {
var $client_id;
var $client_secret;
var $redirect_uri;
var $scopes = array(
'userinfo' => array(
@AstDerek
AstDerek / simple-oauth.php
Created May 11, 2012 02:15
Simple OAuth workflow
<?php
$client_id = GOOGLE_CLIENT_ID;
$client_secret = GOOGLE_CLIENT_SECRET;
$redirect_uri = GOOGLE_CALLBACK;
$google_oauth = new Google_OAuth($client_id,$client_secret,$redirect_uri,'userinfo');
$status = '';
$credentials = FALSE;
$errors = array();