Skip to content

Instantly share code, notes, and snippets.

@camilopayan
camilopayan / gist:1291605
Created October 16, 2011 23:42
html string.format
String o = "<html><table>";
for(int i=0; i<4; i++){
o += String.format("
<tr>
<td>%d</td>
<td>%d</td>
<td>%s</td>
</tr>", i, guess[i], histogram[i]);
}
o+="</table></html>";
@camilopayan
camilopayan / Specs
Created March 25, 2014 15:36
WSGSPECS
Current Rackspace Specs:
250GB HDD
8GB RAM
2GHz CPU AMD Dual Core Opteron 1212
Software:
Red Hat Linux 6
EPEL Repos
PHP 5.4 latest
MySQL
@camilopayan
camilopayan / 0_reuse_code.js
Last active September 10, 2015 19:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@camilopayan
camilopayan / squash-branch.sh
Created October 28, 2015 18:19
Squash to the parent branch
git reset --soft origin/[BRANCH NAME]
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
@camilopayan
camilopayan / ctags.sh
Created December 28, 2015 18:08
Universal CTags version of Tim Pope's Effortless CTags for PHP
#!/bin/sh
set -e
PATH="/usr/local/bin:$PATH"
dir="`git rev-parse --git-dir`"
trap 'rm -f "$dir/$$.tags"' EXIT
git ls-files | \
ctags \
--tag-relative=yes \
-L - -f"$dir/$$.tags" \
--languages=php,-javascript,sql
@camilopayan
camilopayan / cli.sh
Created December 28, 2015 18:14
Using Universal Ctags to get everything in composer's vendor folder
find [PATH TO VENDOR FOLDER] -type f -name '*.php' | grep -v -e "[Tt]est" | xargs ctags -a
<?php
// The real class might look something like this.
class Animal
{
protected $sound;
public function __construct($sound)
{
$this->sound = $sound;
}
<?php
class AnimalParade
{
public march()
{
$animals = [ $this->getMonkey(), $this->getDog(), $this->getLion() ];
foreach($animals as $animal)
{
$animal->soundOff()
<?php
class AnimalParade
{
private function getMonkey()
{
try {
return $dataSource->wrangleAMonkey();
} catch (NotFoundException $e) {
// The null object pattern, quick and dirty-like

Keybase proof

I hereby claim:

  • I am camilopayan on github.
  • I am camilopayan (https://keybase.io/camilopayan) on keybase.
  • I have a public key ASAK6DUdOHq98-trskPrKGroId-pKF2XeHLsmjRdNOfScwo

To claim this, I am signing this object: