Skip to content

Instantly share code, notes, and snippets.

View mstaack's full-sized avatar
🎯
Focusing

Max mstaack

🎯
Focusing
View GitHub Profile
@jboner
jboner / latency.txt
Last active June 12, 2024 14:31
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@schmunk42
schmunk42 / gist:4349624
Created December 20, 2012 23:44
Updated Yii Metadata component from http://www.yiiframework.com/extension/metadata/
<?
/**
* Metadata Helps to get metadata about models,controllers and actions in application*
*
* For using you need:
* 1. Place this file to directory with components of your application (your_app_dir/protected/components)
* 2. Add it to 'components' in your application config (your_app_dir/protected/config/main.php)
* 'components'=>array(
* 'metadata'=>array('class'=>'Metadata'),
* ...
@xeoncross
xeoncross / ParensParser.php
Created February 4, 2013 22:28
PHP: Nested Parenthesis Parser
<?php
// @rodneyrehm
// http://stackoverflow.com/a/7917979/99923
class ParensParser
{
// something to keep track of parens nesting
protected $stack = null;
// current level
protected $current = null;
@karanth
karanth / parse-imap.md
Last active August 7, 2022 06:27
Notes on parsing IMAP responses

The IMAP protocol workflow consists of the following steps,

  • A network connection established between the client and the server.
  • A greeting message sent by the server indicating that the client has successfully connected.
  • A series of interactions between the client and server.

The interactions consists of strings of lines, i.e. string terminated by a carriage return and a line feed (CRLF or \r\n). Interactions can be both commands (sent by clients) and data (sent by clients and servers). Both the client and the server strictly interact using lines or known length octet streams (8-bit characters) followed by a line.

####Client

An IMAP client issues commands to the server in a CRLF terminated string. The syntax of a command includes a tag, followed by the command and parameters. A tag is an alphanumeric identifier and each client command has a different tag for that session. A tag could be something like but not limited to A1, A2 etc.

@itamarhaber
itamarhaber / scan_del.sh
Created April 20, 2014 22:27
A bash script that deletes Redis keys by pattern using SCAN
#!/bin/bash
if [ $# -ne 3 ]
then
echo "Delete keys from Redis matching a pattern using SCAN & DEL"
echo "Usage: $0 <host> <port> <pattern>"
exit 1
fi
cursor=-1
@dasevilla
dasevilla / github-issue-to-phab-task.py
Created May 6, 2014 23:01
Copy GitHub issues to Phabricator
import json
import os
import requests
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN')
if GITHUB_TOKEN is None:
raise Exception('Missing GITHUB_TOKEN from os.environ')
@MikeNGarrett
MikeNGarrett / siege
Last active April 3, 2024 03:49
Siege with JSON POST data
# Changed to use content-type flag instead of header: -H 'Content-Type: application/json'
siege -c50 -t60S --content-type "application/json" 'http://domain.com/path/to/json.php POST {"ids": ["1","2","3"]}'
@deividaspetraitis
deividaspetraitis / Application.php
Created October 5, 2017 06:03
Custom Request object is overridden by default Illuminate\Http\Request
<?php namespace App;
class Application extends \Laravel\Lumen\Application
{
use Concerns\RoutesRequests; // override with our new trait
}
@Radostin
Radostin / twitter.html
Created November 6, 2017 20:25
Twitter Mockup with TailwindCSS
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Twitter</title>
<link rel="stylesheet" type="text/css" href="./css/tailwind.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
@kimhogeling
kimhogeling / js_optional_chaining_operator.markdown
Last active February 26, 2018 22:31
Why the optional chaining operator might be pretty damn useful for readable code

Coming soon to JavaScript: Optional Chaining Operator

This example is inspired by mpjme's Fun Fun Function Video Watch that! It's short fun and explained really well!

This gist, is for me and my colleagues as a reference.

Given: Optional properties in an object

const hero1 = { name: 'Superman', address: { city: 'Metropolis', zip: 12345 } }