Skip to content

Instantly share code, notes, and snippets.

View aknosis's full-sized avatar
🏔️
Working Remotely

Paul Giberson aknosis

🏔️
Working Remotely
View GitHub Profile
@coderabbi
coderabbi / post-merge
Created December 18, 2017 11:27
'composer install' git post-merge hook
# .git/hooks/post-merge
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
composer_install_on_changed_lockfile() {
echo "$changed_files" | grep --quiet "composer.lock" &&
echo "Changes to 'composer.lock' detected; running 'composer install'." &&
composer install
}
@ravibhure
ravibhure / git_rebase.md
Last active April 3, 2024 08:38
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

anonymous
anonymous / mfp.sh
Created February 22, 2016 03:23
curl \
-O http://datashat.net/music_for_programming_0-manifesto.mp3 \
-O http://datashat.net/music_for_programming_1-datassette.mp3 \
-O http://datashat.net/music_for_programming_2-sunjammer.mp3 \
-O http://datashat.net/music_for_programming_3-datassette.mp3 \
-O http://datashat.net/music_for_programming_4-com_truise.mp3 \
-O http://datashat.net/music_for_programming_5-abe_mangger.mp3 \
-O http://datashat.net/music_for_programming_6-gods_of_the_new_age.mp3 \
-O http://datashat.net/music_for_programming_7-tahlhoff_garten_and_untitled.mp3 \
-O http://datashat.net/music_for_programming_8-connectedness_locus.mp3 \
@brandonsavage
brandonsavage / gist:801f921012d553b1a95d
Created January 7, 2015 15:03
My favorite function in PHP...
public function configure(array $values = array())
{
foreach ($values as $key => $value) {
if (property_exists($this, $key)) {
$this->$key = $value;
}
}
return $this;
}
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active April 20, 2024 16:52
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@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:

@clauddiu
clauddiu / eloquent.php
Created December 7, 2012 15:50
Using Eloquent outside of Laravel 4 this extends gist https://gist.github.com/4107178
<?php
require 'vendor/autoload.php';
$resolver = new Illuminate\Database\ConnectionResolver;
$resolver->setDefaultConnection('default');
$factory = new Illuminate\Database\Connectors\ConnectionFactory;
$connection = $factory->make(array(
'host' => 'localhost',
'database' => 'database',
@nikic
nikic / password_hashing_api.md
Created September 12, 2012 15:04
The new Secure Password Hashing API in PHP 5.5

The new Secure Password Hashing API in PHP 5.5

The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:

Why do we need a new API?

Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.

@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',