Skip to content

Instantly share code, notes, and snippets.

View ekinhbayar's full-sized avatar

Ekin ekinhbayar

View GitHub Profile
// XMLDecl from http://www.w3.org/TR/xml/#xmldoc
$regex = <<<'REGEX'
/
(?(DEFINE)
(?<S> [\x20\x9\xD\xA]+ )
(?<Eq> (?&S)? = (?&S)? )
)
^(?<XMLDecl>
<\?xml
(?<VersionInfo>
@ulgens
ulgens / brown-taggedwords.py
Last active October 16, 2016 11:34
Export Brown Corpus tagged words by categories using NLTK. Based on: https://gist.github.com/JonathanReeve/ac543e9541d1647c1c3b
from nltk.corpus import brown
for category in brown.categories():
words = brown.tagged_words(categories=category)
text = '\n '.join('%s, %s' % word for word in words)
filename = category + '.txt'
with open(filename, 'w') as outfile:
outfile.write(text)
# 1000 concurrent HTTP requests to 127.0.0.1 where default nginx is sitting
# Using golang
[ralt@zap golang]$ time ./golang
real 0m0.083s
user 0m0.165s
sys 0m0.087s
[ralt@zap golang]$ time ./golang
@DaveRandom
DaveRandom / script.js
Last active June 6, 2018 09:36
Tweet icon for Jeeves in SO chat
// ==UserScript==
// @name Tweet icon for Jeeves in SO chat
// @namespace http://room11.org/
// @version 1.0
// @description @PeeHaa sucks
// @author @DaveRandom
// @match *://chat.stackoverflow.com/rooms/*
// @grant none
// ==/UserScript==
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!doctype html>
<!-- This is just a very slightly modified tracking.js demo: https://trackingjs.com/examples/face_camera.html -->
<html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/tracking.js/1.1.3/tracking-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tracking.js/1.1.3/data/face-min.js"></script>
<style>
video, canvas {
margin-left: 100px;
@Girgias
Girgias / steps.md
Last active December 5, 2020 12:47
How to commit a Git patch to SVN for the PHP Documentation

This assumes 2 copies of the PHP documentation repo, one "official" SVN which is meant to be kept clean, and a fork of php/doc-en

After the doc PR has been reviewed/approved/decided to merge, squash it into one commit (make sure the branch is up to date with upstream).

Assumed file structure

For the purpose of this tutorial, the following file structure is assumed:

|
|-- doc-en the Git fork
| |(content of English documentation)
@imkevinxu
imkevinxu / .gitconfig
Created November 5, 2012 09:42
`git random` alias that will commit a random commit message from http://whatthecommit.com/
[alias]
random = !"git add -A; git commit -am \"$(echo $(curl -s http://whatthecommit.com/index.txt)\" (http://whatthecommit.com)\")\"; git pull --rebase; git push"
@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:

@pitch-gist
pitch-gist / gist:2999707
Created June 26, 2012 22:21
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>