Skip to content

Instantly share code, notes, and snippets.

View schleumer's full-sized avatar
🔝
Writing bad code.

Wesley Schleumer de Góes schleumer

🔝
Writing bad code.
View GitHub Profile
<?php
class Octopus {
public $results = array();
public $urls = array();
public $chs = array();
public $mh = null;
public function __construct() {
#Add these commands to the file
echo "\n"
echo "********************"
echo "Post receive hook: Updating website"
echo "********************"
echo "\n"
#Change to working git repository to pull changes from bare repository
cd /home/topfriends/www || exit
unset GIT_DIR
<?php
class Users implements JsonSerializable{
private $_data = array();
public function addUser(User $user){
$this->_data[] = $user;
}
public function jsonSerialize(){
return $this->_data;
}
@schleumer
schleumer / designer.html
Last active August 29, 2015 14:08
designer
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-progress/paper-progress.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
try {
if (empty($_POST["name"])) {
throw new UserRegistrationException("Your name cannot be empty.");
}
if (filter_var($_POST["email"])) {
throw new UserRegistrationException("Invalid email");
}
} catch (UserRegistrationException $e) {
}
@schleumer
schleumer / designer.html
Last active August 29, 2015 14:16
designer
<link rel="import" href="../ace-element/ace-element.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@schleumer
schleumer / gist:7162107ad76c5a28f33c
Last active August 29, 2015 14:22
Why use Promise's constructor instead of Promise.resolve/Promise.reject

Let's declare a function that explicitly throws an error

hehe = ->
  throw new Error "OMFG"

Let's simulate some behavior within Promise's constructor

highlight = require 'highlight.js'
cheerio = require 'cheerio'
color-it = (code, lang) ->
html = (highlight.highlight lang, code).value
$ = cheerio.load("<div id=\"the-wrapper\">#{html}</div>")
elements = []
($ '#the-wrapper *').each ->
var validator = require('validator')
, R = require("ramda")
, Promise = require("bluebird");
var skip = R.defaultTo(null);
var pairObjectify = R.pipe(
R.splitEvery(2),
R.map(x => ({key: R.head(x), value: R.last(x)}))
);
@schleumer
schleumer / generateNumbers
Created March 12, 2013 00:51
Generate an array with $quantity random numbers from the given range (from $x to $y)
<?php
/**
* Generate an array with $quantity random numbers from the given range (from $x to $y)
* @param int $min
* @param int $max
* @param int $quantity
* @return array
*/
function generateNumbers($min, $max, $quantity) {