Skip to content

Instantly share code, notes, and snippets.

View AstDerek's full-sized avatar

Ast Derek AstDerek

View GitHub Profile
@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 / 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 / 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 / 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 / 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>
#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 / 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";