Skip to content

Instantly share code, notes, and snippets.

View devnix's full-sized avatar
🐢

Pablo Largo Mohedano devnix

🐢
View GitHub Profile
@Ocramius
Ocramius / handling-optional-input-fields-with-type-safe-abstractions.md
Last active March 17, 2023 12:06
Handling optional input parameters in PHP with `vimeo/psalm` and `azjezz/psl`

Handling optional input parameters in PHP with vimeo/psalm and azjezz/psl

I had an interesting use-case with a customer for which I provide consulting services: they needed multiple fields to be marked as "optional".

Example: updating a user

We will take a CRUD-ish example, for the sake of simplicity.

For example, in the following scenario, does a null $description mean "remove the description",

@Quackster
Quackster / habbo_encoding.py
Created December 17, 2017 21:07
Habbo VL64 and B64 encoding
def decode_b64(value):
result = 0
for i in range(0, len(value)):
result += ((ord(value[i]) - 0x40) << 6 * (len(value) - 1 - i));
return result
def encode_b64(value, length=2):
result = ""
@maxpou
maxpou / _pagination.html.twig
Last active February 26, 2023 20:28
Example of pagination with Twig
{#
Parameters:
* nbPages (int): number of pages
* currentPage (int): current pages
* url (string): route name & query (string): route parameter
ex: list/page-5?q=myFilter (5 = page and query = myFilter)
#}
{% spaceless %}
{% if nbPages > 1 %}
Byobu is a suite of enhancements to tmux, as a command line
tool providing live system status, dynamic window management,
and some convenient keybindings:
F1 * Used by X11 *
Shift-F1 Display this help
F2 Create a new window
Shift-F2 Create a horizontal split
Ctrl-F2 Create a vertical split
Ctrl-Shift-F2 Create a new session
@jmlweb
jmlweb / validnif.js
Created November 22, 2014 12:08
Directiva Angular para validación de NIF/NIE españoles | Angular directive for spanish NIF/NIE validation
'use strict';
/**
* @ngdoc directive
* @name directive:validnif
* @description
* # validnif
*/
angular.module()
.directive('validnif', function () {
$context = Timber::get_context();
$context['slides'] = Timber::get_posts('post_type=slides');
$context['pages'] = Timber::get_posts('post_type=page&posts_per_page=2');
$context['portfolio'] = Timber::get_posts('post_type=portfolio');
$context['posts'] = Timber::get_posts(); //leave blank for default page query
Timber::render('front-page.twig', $context);
@Gergling
Gergling / PackageLoader.js
Created May 23, 2013 15:57
This is a requirejs-based preloader progress bar using jquery. Download the files into a directory and run index.html in a browser to see the effects.
var PackageLoader = function() {
this.cb = Math.random(0, 100000000000);
this.current = 0;
this.batches = [];
// Load kicks off the entire loading process.
this.load = function(config, loadMap, onload) {
var scope = this;
for(label in loadMap) {
scope.batches.push(new PackageBatch(label, loadMap[label]));