Skip to content

Instantly share code, notes, and snippets.

@NapoleonWils0n
NapoleonWils0n / curl_time_to_first_byte.sh
Created November 3, 2012 22:33
bash: curl time to first byte
curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" http://inserturl.here
@ozh
ozh / github_oauth_token.md
Last active June 23, 2022 15:42
Get a Github OAuth token from the CLI with curl

At the command line:

curl -u ':USERNAME' -d '{"scopes":["public_repo"],"note":"Google Issues to GH"}' https://api.github.com/authorizations
curl -H "Authorization: bearer :TOKEN" https://api.github.com/users/:USERNAME -I

Replace :USERNAME with your Github username and :TOKEN with the oauth token you get from first curl

After that, the token will be listed in your Applications and you can revoke it from there

@nikic
nikic / objects_arrays.md
Last active May 16, 2025 22:07
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:

@webmasterkai
webmasterkai / img.l
Last active November 3, 2018 08:49 — forked from phpdude/nginx.conf
Mirror remote image files, supports dynamic resizing of images. nginx image_filter remote fetching with a local mirror of original and resized image. Using try_files instead of if statements and proxy_pass with proxy_store for permanent local storage. No cache expiration, that will need to be handled outside of this.
server {
server_name img.l;
root /var/www/cache/store/ns365;
index index.html;
# This requests the original file from itself and then resizes the image.
location ~ /resize/(\d+)x(\d+)/(.*) {
proxy_pass http://img.l/$3;
image_filter resize $1 $2;
image_filter_jpeg_quality 90;
@jamesarosen
jamesarosen / if_less_development.md
Last active July 19, 2020 19:53
On Procedural Polymorphism: I like the idea of replacing ifs with Polymorphism, but I'm not quite comfortable with it yet.

Background

Cory Foy recently wrote an article entitled, Procedural Polymorphism: Is your code really telling you to use an if statement?. Corey Haines has been talking about this same topic for a while. Sandi Metz covers the topic in Practical Object-Oriented Design in Ruby. Ben Rady and Rod Coffin discussed using the Null-Object pattern instead of an if statement in Continuous Testing with Ruby, Rails, and JavaScript.

Printing in Conway's Game of Life

That is, very smart people whom I admire agree that, in general,

class DeadCell
@JalfResi
JalfResi / revprox.go
Last active May 7, 2025 07:35
Simple reverse proxy in Go
package main
import(
"log"
"net/url"
"net/http"
"net/http/httputil"
)
func main() {
@gregrickaby
gregrickaby / _mixins.scss
Created September 12, 2013 22:14
The ultimate SASS - PX to REM mixin
// Create REM values with PX fall back
//
// Generate a REM with PX fallback from
// $baseFontSize. Enter the desired size based
// on pixels in numerical form. Supports shorthand.
//
// Forked from: http://codepen.io/thejameskyle/pen/JmBjc
//
// @author Greg Rickaby
// @since 1.0
@plentz
plentz / nginx.conf
Last active June 25, 2025 06:48
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@oddlyzen
oddlyzen / devops_shell_commands.md
Last active March 25, 2019 08:17
A list of extremely useful DevOps commands for *nix environments (Use caution on OS X, of course...)

Process Basics

All processes, with params + hierarchy

ps auxww -H

Show all ruby-related PIDs and processes

pgrep -fl ruby

@andresviikmaa
andresviikmaa / brute_force.txt
Created December 12, 2013 06:57
TSP brute force and nearest neighbour in PHP
[2013-12-12 08:51:40] start BruteForceTSP
best so far: 4918.6049886512, atempt: 1
Path: (443, 511)->(471, 124)->(10, 774)->(88, 600)->(518, 322)->(292, 171)->(995, 423)->(14, 374)->(697, 153)->(422, 301)
....
best so far: 2384.6557454024, atempt: 341178
Path: (443, 511)->(422, 301)->(518, 322)->(995, 423)->(697, 153)->(471, 124)->(292, 171)->(14, 374)->(88, 600)->(10, 774)
[2013-12-12 08:52:17] end BruteForceTSP
--------