Skip to content

Instantly share code, notes, and snippets.

View ammarfaizi2's full-sized avatar
🐀
Baby Opossum Posse

Ammar Faizi ammarfaizi2

🐀
Baby Opossum Posse
View GitHub Profile
@abeluck
abeluck / gpg-offline-master.md
Last active October 22, 2023 02:59 — forked from KenMacD/cmd.md
GPG Offline Master Key w/ smartcard
@nikic
nikic / objects_arrays.md
Last active September 24, 2024 14:51
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:

// Put this in a separate .h file (called "getopt.h").
// The prototype for the header file is:
/*
#ifndef GETOPT_H
#define GETOPT_H
int getopt(int nargc, char * const nargv[], const char *ostr) ;
#endif
*/
@roderik
roderik / postgresql.conf
Last active February 20, 2019 08:55
Default 9.3 postgres config
# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
# name = value
#
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
# "#" anywhere on a line. The complete list of parameter names and allowed
@nikAizuddin
nikAizuddin / NASMx86: Allocate heap memory
Created October 12, 2014 22:58
Example using brk() system call for dynamic memory allocations
; 1 2 3 4 5 6 7
;01234567890123456789012345678901234567890123456789012345678901234567890
;=======================================================================
;+---------------------------------------------------------------------+
;| |
;| Example using brk() system call for dynamic memory allocations. |
;| |
;| DON'T CONFUSE that brk() used in C Function is different with brk() |
;| systemcall (systemcall 45 for x86 ASM). |
;| |
@CMCDragonkai
CMCDragonkai / memory_layout.md
Last active November 11, 2024 13:39
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@application2000
application2000 / how-to-install-latest-gcc-on-ubuntu-lts.txt
Last active November 2, 2024 12:39
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
@rvido
rvido / setup-xrdp-ubuntu.sh
Last active February 25, 2023 14:34
A shell script to setup Remote Desktop Ubuntu 16.04
#!/bin/bash
#------------------------------------------------
# Setup Ubuntu 16.04 with xRDP via MATE-Desktop
#------------------------------------------------
#
sudo apt update
sudo apt install xrdp
sudo apt install mate-core mate-desktop-environment mate-notification-daemon
sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n mate-session \n' /etc/xrdp/startwm.sh
@ianmustafa
ianmustafa / 0-prepare-your-linux-server.md
Last active June 1, 2021 02:17
Prepare your Linux Server

Prepare Your Linux Server

What Does This Really Do?

Basically we set up the timezone and locale, and only allow for SSH root login without password, by using SSH authentication key. We also add a basic Vim conviguration inside .vimrc by adding line numbers by default.

Then we update the repository and the system, and also add basic tools like nano, curl, tmux, even vim itself doesn't included by the system. zsh and git is prequisites for oh-my-zsh,

@pentagonal
pentagonal / Collection.php
Created June 5, 2017 20:47
Just Simple Shell Arg Parser
<?php
namespace Pentagonal\RujakLegi;
/**
* Class Collection
* @package Pentagonal\RujakLegi
*/
class Collection implements \ArrayAccess, \IteratorAggregate, \Countable
{
/**