Skip to content

Instantly share code, notes, and snippets.

View cordoval's full-sized avatar

Luis Cordova cordoval

View GitHub Profile
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active March 1, 2024 14:39
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
kubectl create -f test.yaml
#secret "postgres-files-secret" created
#statefulset "postgres-statefulset" created
kubectl exec -it postgres-statefulset-0 /bin/sh
ls -lah /var/lib/postgresql/
# total 12
# drwxr-xr-x 3 root root 4.0K May 19 16:02 .
# drwxr-xr-x 3 root root 4.0K May 19 16:02 ..
@sstok
sstok / ShortArraySyntaxFixer.php
Last active August 29, 2015 14:03
ShortArraySyntaxFixer for PHP-CS-Fixer
use Symfony\CS\FixerInterface;
use Symfony\CS\Tokens;
class ShortArraySyntaxFixer implements FixerInterface
{
public function fix(\SplFileInfo $file, $content)
{
$tokens = Tokens::fromCode($content);
for ($index = 0, $c = $tokens->count(); $index < $c; $index++) {
@graffic
graffic / gist:6c15f8c2b4f0f208939e
Created May 11, 2014 19:49
Uncle bob "Framework Whipped" original post

Framework Whipped

Uncle Bob 11 May 2014 Craftsmanship Frameworks are powerful tools. We'd be lost without them. But there's a cost to using them.

The relationship between a programmer and a framework is similar to the relationship between an executive and an administrative assistant. The framework takes care of all the necessary details, so that the executive can focus on high level decisions.

Think of Rails, or Spring, or JSF, or Hibernate. Think about what writing a web system would be like without these frameworks to help you. The idea is disheartening. There'd be so many little piddling details to deal with. It'd be like endeavoring to construct a mnemonic memory circuit using stone knives and bearskins[1].

And so we gleefully use those glittering frameworks. We joyously intermingle our code with the frameworks' in anticipation of all the benefits they promise. We make the mistake that so many executives have made before us. We marry our secretary.

Configure

xdebug.ini

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
@fabpot
fabpot / pr-labels.js
Created December 10, 2013 08:50
Displays pull requests labels on Github. Change 'YOU_API_TOKEN' to a Github token or remove the query parameter altogether (but you will run out of calls very fast).
// ==UserScript==
// @name Adds Labels on Github Pull Request
// @namespace http://fabien.potencier.org
// @include https://github.com/*/*/pulls*
// @version 2
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// ==/UserScript==
$(function() {
$(".pulls-list .list-group-item h4").each(function() {
var pull_request = this;
@grantslatton
grantslatton / fizzbuzz.c
Last active August 19, 2022 11:20
FizzBuzz solved using only bit twiddling. It essentially uses two deterministic finite automata for divisibility testing.
#include <stdio.h>
int f0(unsigned int x) { return x? (x&(1<<31)? f1(x<<1) : f0(x<<1)) : 1; }
int f1(unsigned int x) { return x? (x&(1<<31)? f3(x<<1) : f2(x<<1)) : 0; }
int f2(unsigned int x) { return x? (x&(1<<31)? f0(x<<1) : f4(x<<1)) : 0; }
int f3(unsigned int x) { return x? (x&(1<<31)? f2(x<<1) : f1(x<<1)) : 0; }
int f4(unsigned int x) { return x? (x&(1<<31)? f4(x<<1) : f3(x<<1)) : 0; }
int t0(unsigned int x) { return x? (x&(1<<31)? t1(x<<1) : t0(x<<1)) : 1; }
int t1(unsigned int x) { return x? (x&(1<<31)? t0(x<<1) : t2(x<<1)) : 0; }
int t2(unsigned int x) { return x? (x&(1<<31)? t2(x<<1) : t1(x<<1)) : 0; }
@jakzal
jakzal / behat-runner.sh
Last active June 7, 2016 01:24
Running behat scenarios parallelized (by sprint)
#!/usr/bin/env bash
# finds all sprint tags (like @sprint:42) and runs them in a reversed order (won't run not tagged scenarios)
PARALLEL_COMMAND='parallel --gnu'
#PARALLEL_COMMAND='xargs -I{}'
BEHAT_COMMAND='./bin/behat --ansi --tags={}'
grep '@sprint:' features/*.feature | sed -e 's/.*\(@sprint:[0-9]*\).*/\1/' | sort -ur | $PARALLEL_COMMAND $BEHAT_COMMAND
@tPl0ch
tPl0ch / CommandContext.php
Last active August 18, 2023 11:18
A CommandContext for Behat tests of Symfony Console Commands
<?php
namespace MFB\Behat\Subcontext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\MinkExtension\Context\RawMinkContext;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\EventDispatcher\EventDispatcher;
/**
@krakjoe
krakjoe / pthreads.md
Last active August 30, 2023 18:30
pthreads.md

Multi-Threading in PHP with pthreads

A Brief Introduction to Multi-Threading in PHP

  • Foreword
  • Execution
  • Sharing
  • Synchronization
  • Pitfalls