Skip to content

Instantly share code, notes, and snippets.

View AstDerek's full-sized avatar

Ast Derek AstDerek

View GitHub Profile
@AstDerek
AstDerek / average.cpp
Created February 29, 2012 17:35
Imperative, functional, OOP
#define IMPERATIVE
#ifdef IMPERATIVE
#include <iostream>
using namespace std;
int main (int narg, char *varg[]) {
if (narg != 4) {
cout << "Usage:\n program_name [number] [number] [number]\n";
#include <time.h>
#include <iostream>
#include <iomanip>
using namespace std;
/**
* Calcula un año biciesto:
*
* Si es múltiplo de cuatro y NO es múltiplo de 100,
@AstDerek
AstDerek / pairs.php
Created March 9, 2012 02:46
Basic div pair highlighter
<?php
$contents = htmlspecialchars(@$_POST['contents']);
if (!$contents) { ?>
<form method="post">
<textarea name="contents"></textarea>
<br>
<input type="submit">
</form>
@AstDerek
AstDerek / xor_obfuscator.php
Created March 12, 2012 07:25
Simple XOR obfuscator
<?php
function xor_obfuscator ($string) {
if (!strlen($string)) {
return $string;
}
$key = ord($string{0});
$new = pack("C",
($key & 0xf0)
@AstDerek
AstDerek / git-diff-with-colors.html
Created March 23, 2012 23:08
git diff --with-colors to HTML
<?php
/**
* git diff --with-colors A B > colors.diff
*/
function escape_meta ($string) {
$string = htmlspecialchars($string);
$string = str_replace(
@AstDerek
AstDerek / file.php
Created April 12, 2012 23:57
some gist
<style type="text/css">
#app-container
{width:100%!important;
position:absolute!important;
left:0!important;
background:#fff;}
#app-container h2
{text-align:center;
line-height:28px;}
@AstDerek
AstDerek / seg-fault.cpp
Created May 8, 2012 21:15
String inside dynamically allocated struct
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
typedef struct _node {
string name;
} node;
@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();
@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 / 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==
/**