Skip to content

Instantly share code, notes, and snippets.

@Jean85
Jean85 / composer-outdated.sh
Last active March 3, 2019 01:59
How to check in CI if any Composer dependency can be upgraded, using a committed file as a way to ignore upgrades blocked by external factors.
#!/usr/bin/env bash
rm outdated-status.txt
touch outdated-status.txt
for package in `composer outdated | awk '{ print $1":"$4 }'`;
do
echo "New version: $package" > outdated-status.txt
composer why-not $package > outdated-status.txt
echo "----------" > outdated-status.txt
@morozov
morozov / backport.sh
Last active December 6, 2018 09:49
A shell script for back-porting Doctrine DBAL pull requests from master to older branches
#!/usr/bin/env bash
set -eu
if [ $# -ne 2 ]; then
echo "Usage: `basename $0` <pull> <branch>";
exit 1;
fi
PULL="$1"
@dunglas
dunglas / example.php
Created April 19, 2018 06:25
A minimalist GraphQL client for PHP
<?php
$query = <<<'GRAPHQL'
query GetUser($user: String!) {
user (login: $user) {
name
email
repositoriesContributedTo {
totalCount
}
@greg0ire
greg0ire / pagination.md
Last active May 20, 2018 16:42
Pagination

Pagination

Pagination is the process of dividing a long list of results into easier to consume pages. By only loading one page at a time, memory is preserved. This applies to RDBMS result sets, collections of serialized items in an API, or listings in list views of simple CRUD applications. Although the needs are often the same, many libraries define their own objects, or even use plain arrays to represent a paginated result. As a result, projects consuming these libraries often end up defining many adapters for those many libraries.

@podhy
podhy / parallel.sh
Last active October 17, 2017 13:19
Psql parallel processing in Bash
#!/bin/bash
workers=4
STEP=$(psql -U svetluska -c "SELECT ceil(COUNT(*) / $workers) FROM svetluska.domination" -qtA svetluska)
time for ((i=0; i<$workers; i++))
do
echo "UPDATE svetluska.domination SET geometry = t.geometry_wkt FROM (SELECT id, geometry_wkt FROM svetluska.domination ORDER BY id LIMIT $STEP OFFSET $STEP*$i) t WHERE domination.id = t.id";
done | xargs -P $workers -I % psql -U svetluska -c "%" svetluska
#done | xargs -P 3 -I % echo %
@mindplay-dk
mindplay-dk / collections.md
Last active August 21, 2024 18:29
Linear collection workflow

You can have a linear workflow with the array functions.

The following is unreadable:

$output = array_reduce(
  array_map(
    function($n) { return $n ** 2; }
    array_filter($input, function($n) { return $n % 2 == 0; })
 ),
@thegauraw
thegauraw / clone_gitlab_projects.rb
Last active May 28, 2020 20:14
How to clone all the repositories or projects from gitlab?
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
# TWO WAYS TO RUN THIS SCRIPT:
# ----------------------------
# --->>> THE FIRST WAY> Run this script as executable: `./clone_gitlab_projects.rb`
# You need to make the script executable: `chmod +x gitlab_clone_all_repos.rb`
# ---- ANYTHING ABOVE THIS LINE IS ONLY REQUIRED IF YOU WANT TO RUN THE SCRIPT WITH SINGLE COMMAND `./clone_gitlab_projects.rb` ---- #
-- psql -U postgres -h localhost -f /path/to/tardis.sql
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
@boekkooi
boekkooi / CustomPropertyAccessor.php
Last active December 23, 2020 02:49
Using a custom property path for symfony forms set / get path
<?php
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\PropertyAccess\PropertyPath;
/**
* A property accessor that allows you to rewrite a property path for setters and getters.
*/
class CustomPropertyAccessor extends PropertyAccessor
{
/**
@ivanbarlog
ivanbarlog / labels.sh
Last active January 28, 2016 13:44
Adding github labels via bash script
#!/bin/bash
read -p "repository (owner/repository): " REPO
read -p "user: " USER
read -p "password: " -s PASS
# Delete default labels
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO/labels/bug"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO/labels/duplicate"
curl --user "$USER:$PASS" --include --request DELETE "https://api.github.com/repos/$REPO/labels/enhancement"