Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View rotexdegba's full-sized avatar

Rotimi Ade rotexdegba

View GitHub Profile
@jasonsnider
jasonsnider / cmpsr.sh
Created August 19, 2021 13:46
Upgrade Composer from 1.x to 2.x on Ubuntu 20.04
#!/bin/bash
sudo apt remove composer
sudo apt update
sudo apt install curl
sudo curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/bin/composer
@rotexdegba
rotexdegba / linux-rails-and-redmin-in-ubuntu-1604-mint18.txt
Last active December 3, 2023 15:49
Installing Rails and Redmine in Ubuntu 16.04 LTS / Linux Mint 18
# Make sure you have already installed apache and mysql;
# install rails
# https://help.ubuntu.com/lts/serverguide/ruby-on-rails.html
sudo apt install rails
# install comman dependencies
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev make libmysqlclient-dev imagemagick \
libmagickcore-dev libmagickwand-dev
@brianlmoon
brianlmoon / socket_connect_timeout.php
Last active February 26, 2021 06:13
Using socket_connect with a reliable timeout in PHP
<?php
/**
* I was having trouble with socket connections timing out reliably. Sometimes,
* my timeout would be reached. Other times, the connect would fail after three
* to six seconds. I finally figured out it had to do with trying to connect to
* a routable, non-localhost address. It seems the socket_connect call would
* not fail immediately for those connections. This function is what I finally
* ended up with that reliably connects to a working server, fails quickly for
* a server that has an address/port that is not reachable and will reach the
@eddmann
eddmann / SecureSessionHandler.php
Created April 9, 2014 12:18
Secure session handler implementation.
<?php
class SecureSessionHandler extends SessionHandler {
protected $key, $name, $cookie;
public function __construct($key, $name = 'MY_SESSION', $cookie = [])
{
$this->key = $key;
$this->name = $name;
@ralphje
ralphje / gist:5106949
Created March 7, 2013 10:07
Migrating issues from Redmine to GitHub
import csv
import datetime
import feedparser # pip install feedparser
import html2text # pip install html2text
from pygithub3 import Github # pip install pygithub3
# USAGE: Create a csv with all columns from Redmine and fetch
# your API key from Redmine. Then use the code below to match
# properties of the csv with properties of your GitHub issues.
# Note: remove the first line of the exported CSV.
@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:

<!-- This is a Node+WebSocket powered demo to sync videos
across different browsers. This file is the client,
the other one is the Node server. Powered by Node and
http://github.com/miksago/node-websocket-server -->
<style>
.inactive { display: none; }
.active { display: block; }
</style>
<script>