Skip to content

Instantly share code, notes, and snippets.

Avatar
😀

Grégoire Pineau lyrixx

😀
View GitHub Profile
@ziadoz
ziadoz / awesome-php.md
Last active Sep 30, 2022
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
View awesome-php.md
@qhwa
qhwa / go_port_forwarding.go
Last active Sep 13, 2022
network port forwarding in go lang
View go_port_forwarding.go
package main
import (
"fmt"
"io"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":8080")
@naholyr
naholyr / _service.md
Created Dec 13, 2012
Sample /etc/init.d script
View _service.md

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@hSATAC
hSATAC / gist:5343225
Created Apr 9, 2013
Http Redirect in Golang
View gist:5343225
package main
import (
"log"
"net/http"
)
func redirect(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "http://www.google.com", 301)
@lyrixx
lyrixx / HardCoreDebugLogger.php
Last active Aug 25, 2022
Hardcore Debug Logger
View HardCoreDebugLogger.php
<?php
const STREAM_OPEN_FOR_INCLUDE = 128;
final class HardCoreDebugLogger
{
public static function register(string $output = 'php://stdout')
{
register_tick_function(function () use ($output) {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
@lyrixx
lyrixx / segfault-finder.php
Last active Aug 25, 2022
How to find a segfault in PHP
View segfault-finder.php
<?php
register_tick_function(function() {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
$last = reset($bt);
$info = sprintf("%s +%d\n", $last['file'], $last['line']);
file_put_contents('/tmp/segfault.txt', $info, FILE_APPEND);
// or
// file_put_contents('php://output', $info, FILE_APPEND);
});
@nikic
nikic / objects_arrays.md
Last active Jun 3, 2022
Post explaining why objects often use less memory than arrays (in PHP)
View objects_arrays.md

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@mxlje
mxlje / ssl.md
Last active Jan 10, 2022
SSL Certificate Commands
View ssl.md

These commands are needed every time you want to generate a new certificate signing request to give to an authority in order for them to generate and sign a certificate for you.

https://letsencrypt.org/ solves a lot of the pain involved with SSL certs, but sometimes you still need to go the "old school" route. I constantly forget how this stuff works, so I collected the most important commands (and what they do) here for easy copy & paste.

Generate new private key

@remi
remi / .gitconfig
Created Jul 27, 2011
Alias pour utiliser git en français!
View .gitconfig
[alias]
etat = status
pousser = push
tirer = pull
commettre = commit
ranger = stash
ajouter = add
enlever = rm
cloner = clone
fusionner = merge
@lyrixx
lyrixx / run.php
Last active Oct 7, 2021
Updated your templates with the new twig include
View run.php
<?php
<<<CONFIG
packages:
- "symfony/finder: ~3.0"
- "symfony/console: ~3.0"
CONFIG;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;