Skip to content

Instantly share code, notes, and snippets.

<?php
// See https://github.com/web-token/jwt-framework/tree/v1.3.9 for about JWT
function createAppleIDSecret()
{
$privateKey = file_get_contents('/path/to/your/key');
$keyId = 'key_id';
$teamId = 'team_id';
$clientId = 'client_id';
@ntamvl
ntamvl / os-x-terminal-color-prompt.md
Last active February 16, 2025 17:55
OS X Terminal color prompt

OS X Terminal color prompt

Update .bash_profile with content:

export CLICOLOR=1
export PS1="\[\e[36m\]\w\[\e[0m\]$ "
alias ll='ls -GFhl' dir='ls -GFhl'
alias start=open
printf "\033]0;`date "+%a %d %b %Y %I:%M %p"`\007"
@ravishakya
ravishakya / multidimentionalArrayMap.php
Last active January 30, 2021 14:48
array_map for multidimensional array
function multidimentional_array_map( $function, $arr ){
$result = array();
foreach ($arr as $key => $val){
$result[$key] = (is_array($val) ? multidimentional_array_map($function, $val) : $function($val));
}
return $result;
}
@Lazhari
Lazhari / README.md
Created February 25, 2017 22:01
Split a large CSV file and add headers to each file

Split a large CSV file and add headers to each file

Step One: Split file

$ split -l 5000 users.csv ./split-files 

5000 is the number of lines you want for each file.)

@shingorow
shingorow / up-to-php7-in-cloud9.sh
Last active November 20, 2018 10:46
On Cloud9, upgrade PHP 5 to 7.
# Install phpbrew
sudo apt-get update
sudo apt-get install libmcrypt-dev
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod +x phpbrew
sudo mv phpbrew /usr/local/bin/
phpbrew init
[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc
@oanhnn
oanhnn / using-multiple-github-accounts-with-ssh-keys.md
Last active April 27, 2025 19:52
Using multiple github accounts with ssh keys

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@henriquemenezes
henriquemenezes / curl-upload-file.sh
Last active September 12, 2023 20:19
Using CURL to Upload Files
# curl - Raw upload
curl -X PUT -T image.png https://example.com/upload
# curl - Content-Type: multipart/form-data
curl -F name=logo -F [email protected] https://example.org/upload
# curl - POST presigned URL (S3)
@jeremeamia
jeremeamia / aws-csv-streamwrapper.php
Created June 6, 2014 18:23
Shows how to read a CSV stored in S3 using the AWS SDK for PHP's S3 Stream Wrapper.
<?php
require __DIR__ . '/vendor/autoload.php';
$s3 = Aws\S3\S3Client::factory($config);
$s3->registerStreamWrapper();
$url = 's3://{$bucket}/{$key}';
// Read CSV with fopen
@amirkdv
amirkdv / php_mdb.rst
Last active August 25, 2023 13:14
How to handle MS Access MDB files in Linux with PHP5 PDO and ODBC

To be able to use PHP5 PDO with MS Access mdb files the following is required (the same applies for the PHP4 style of using odbc_X except for the obviously PDO specific requirements):

PHP ODBC module

In Linux this is achieved by intalling the php5-odbc package:

@yorkxin
yorkxin / rfc6750.md
Created September 17, 2013 07:54
RFC 6750 in Markdown - Edited from http://tools.ietf.org/rfc/rfc6750.txt
Internet Engineering Task Force (IETF)                          M. Jones
Request for Comments: 6750                                     Microsoft
Category: Standards Track                                       D. Hardt
ISSN: 2070-1721                                              Independent
                                                            October 2012

The OAuth 2.0 Authorization Framework: Bearer Token Usage

Abstract