Skip to content

Instantly share code, notes, and snippets.

View kimegede's full-sized avatar

Kim Egede Jakobsen kimegede

View GitHub Profile
@ankr
ankr / scrcap.md
Last active March 25, 2020 10:06
Simple script for taking a drag-n-drop screenshot on OSX and upload it to your private server.

scrcap

Simple script to taking drag-n-drop screenshots on OSX and upload them to your own server.

  1. First create a new bash script with the following content:
#!/bin/bash

# Use timestamp to generate "unique" filename
filename=$(date +%s).png
@roylee0704
roylee0704 / dockergrep.sh
Created December 9, 2016 08:24
how to grep docker log
docker logs nginx 2>&1 | grep "127."
# ref: http://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container
@ankr
ankr / danish_apis.md
Last active January 29, 2024 13:22
List of various Danish API services.
@DenisIzmaylov
DenisIzmaylov / INSTALLATION.md
Last active April 27, 2023 15:44
OS X 10.11 El Capitan: fresh install with Node.js (io.js) Developer Environment

OS X 10.11 (El Capitan) / Node.js and io.js Developer Environment

Custom recipe to get OS X 10.11 El Capitan running from scratch with useful applications and Node.js Developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after fresh install.

Content

@ankr
ankr / slugify.php
Last active August 29, 2015 14:18
PHP function to turn a string into a slug. Will transliterate characters and replace whitespace with `-`.
<?php
// @see http://stackoverflow.com/a/13331948/1640765
function slugify($str) {
$str = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $str);
$str = preg_replace('/\s+/', '-', $str);
return trim($str, '-');
}
@hummus
hummus / gist:8592113
Last active April 26, 2024 19:45
aws cli + jq example
wget http://stedolan.github.io/jq/download/linux64/jq
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \
"Name=instance-state-name,Values=running" \
| jq -r \
".Reservations[] | .Instances[] | .InstanceId" \
aws ec2 describe-volumes --filters \
"Name=status,Values=available" \
| jq -r ".Volumes[] | .VolumeId" \
@ankr
ankr / Convert_SVN_to_GIT.md
Last active December 25, 2015 16:29
Convert SVN repo to GIT repo

1. Create local SVN checkout

mkdir svn-repo
svn checkout svn://example.org svn-repo/

2. Create an authors list

Will create a list of all the contributers of the SVN repo.

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