Skip to content

Instantly share code, notes, and snippets.

View arzola's full-sized avatar
:octocat:
Coding

Oscar Arzola arzola

:octocat:
Coding
View GitHub Profile
@nikic
nikic / objects_arrays.md
Last active April 12, 2024 17:05
Post explaining why objects often use less memory than arrays (in PHP)

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:

@chrisle
chrisle / gist:2252209
Created March 30, 2012 15:15
CURL as GoogleBot 2.1
curl --user-agent "Googlebot/2.1 (+http://www.google.com/bot.html)" -v $@
@dearaujoj
dearaujoj / remove_git_tag
Created October 22, 2013 10:02
git remove tag locally and remote
git tag -d TagName && git push origin :refs/tags/TagName
@krisanalfa
krisanalfa / macosx-install-php-oracle-oci8-pdo_oci.md
Last active January 11, 2024 22:00 — forked from gido/macosx-install-php-oracle-oci8.md
Install OCI8 and / or PDO_OCI on OSX via Brew

Installation

This procedure is tested on Mac OS X 10.10.5 with Developpers tools installed (xCode).

PHP 5.6 installed with Homebrew.

Preparation

Download the following files from Oracle website (yes, you need to create an account and accept terms):

@jessedearing
jessedearing / gist:2351836
Created April 10, 2012 14:44 — forked from twoism-dev/gist:1183437
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active November 12, 2023 23:00
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin <branch-name>
@hikari-no-yume
hikari-no-yume / example.php
Created March 20, 2017 20:02
function chaining for PHP 7
<?php declare(strict_types=1);
require_once "✨.🐘";
✨($_)->strlen("foo")->var_dump($_);
@watanabeyu
watanabeyu / MainTabNavigator.js
Created February 9, 2018 06:20
react-navigationのtabNavigatorの背景色を変更する
const tabNavigator = TabNavigator(
{
Home: { screen: HomeScreen },
Search: { screen: HomeScreen }
},
{
tabBarOptions: {
showLabel: false,
activeTintColor: '#333',
inactiveTintColor: '#bbb',
@akshaynagpal
akshaynagpal / LinkedList.java
Last active November 5, 2022 09:16
Linked List From Scratch in Java
package src.LinkedList;
public class LinkedList {
public Node head;
public int listCount;
public LinkedList(){
head = new Node(0);
listCount = 0;
}
@bayareawebpro
bayareawebpro / laravel-bitbucket-pipelines.yml
Last active January 4, 2022 05:07
Bitbucket Pipelines for Laravel
# This is a sample build configuration for PHP.
# Check our guides at https://confluence.atlassian.com/x/e8YWN for more examples.
# Only use spaces to indent your .yml configuration.
# You can specify a custom docker image from Docker Hub as your build environment.
# run composer check-platform-reqs for a list of required extensions.
image: php:7.2-fpm
pipelines:
default:
# Not needed unless you're doing feature tests.
# - step: