Skip to content

Instantly share code, notes, and snippets.

@dirkvranckaert
dirkvranckaert / AndroidManifest.xml
Last active September 19, 2021 00:26
Taking a picture using a FileProvider
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
...
<provider
@CarlosEduardo
CarlosEduardo / Doctrine-Multi-Tenancy.md
Last active June 19, 2024 14:36
Multi-Tenancy (tenant) Strategy for Doctrine ORM
@joshdover
joshdover / README.md
Last active September 28, 2023 21:38
Idiomatic React Testing Patterns

Idiomatic React Testing Patterns

Testing React components seems simple at first. Then you need to test something that isn't a pure interaction and things seem to break down. These 4 patterns should help you write readable, flexible tests for the type of component you are testing.

Setup

I recommend doing all setup in the most functional way possible. If you can avoid it, don't set variables in a beforeEach. This will help ensure tests are isolated and make things a bit easier to reason about. I use a pattern that gives great defaults for each test example but allows every example to override props when needed:

@shankao
shankao / levenshtein.php
Created February 1, 2016 13:04
Levenshtein distance in PHP with multibyte support
<?php
// Levenshtein distance with multibyte support
// Improved from https://gist.github.com/santhoshtr/1710925
function mb_levenshtein($str1, $str2, $encoding = 'UTF-8', $return_lengths = false){
$length1 = mb_strlen($str1, $encoding);
$length2 = mb_strlen($str2, $encoding);
if( $str1 === $str2) {
if ($return_lengths) {
return array(0, $length1, $length2);
} else {
@mcaskill
mcaskill / Function.Array-Group-By.php
Last active January 3, 2024 10:15
PHP : Groups an array by a given key
<?php
if (!function_exists('array_group_by')) {
/**
* Groups an array by a given key.
*
* Groups an array into arrays by a given key, or set of keys, shared between all array members.
*
* Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
* This variant allows $key to be closures.
@danharper
danharper / gulpfile.js
Last active April 11, 2024 08:31
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
@mPastuszko
mPastuszko / samsung-remote.xml
Last active September 15, 2021 20:32
Samsung remote key mapping for Kodi
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file contains the mapping of keys (gamepad, remote, and keyboard) to actions within XBMC -->
<!-- The <global> section is a fall through - they will only be used if the button is not -->
<!-- used in the current window's section. Note that there is only handling -->
<!-- for a single action per button at this stage. -->
<!-- For joystick/gamepad configuration under linux/win32, see below as it differs from xbox -->
<!-- gamepads. -->
<!-- The format is: -->
<!-- <device> -->
@markwingerd
markwingerd / GStreamer Tutorial 1
Last active April 6, 2019 23:20
GStreamer Tutorial 1: Whole Project - Plays an mp3 file
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
GStreamer Tutorial 1: Simple Project
In this tutorial we will receive an mp3 file from our harddrive, manipulate
with an equalizer element, and output that to our speakers.
------------------------pipeline-------------------------
| | | | |
@magnetikonline
magnetikonline / dumprequest.php
Last active April 30, 2024 08:01
PHP script to dump full HTTP request to file (method, HTTP headers and body).
<?php
// https://gist.github.com/magnetikonline/650e30e485c0f91f2f40
class DumpHTTPRequestToFile {
public function execute($targetFile) {
$data = sprintf(
"%s %s %s\n\nHTTP headers:\n",
$_SERVER['REQUEST_METHOD'],
$_SERVER['REQUEST_URI'],
$_SERVER['SERVER_PROTOCOL']
@gkralik
gkralik / DummyTranslator.php
Created February 25, 2014 11:32
ZF2 without ext/intl prior to 2.3.0
<?php
/* module/Application/src/Application/I18n/DummyTranslator.php */
namespace Application\I18n;
use Zend\I18n\Exception;
use Zend\I18n\Translator\Translator;
class DummyTranslator extends Translator