Skip to content

Instantly share code, notes, and snippets.

View gist:65fdf0222635d768e9d7c679db135987
There is a Taoist story of an old farmer who had worked his crops for many years. One day his horse ran away. Upon hearing the news, his neighbors came to visit. "Such bad luck," they said sympathetically. "May be," the farmer replied.
The next morning the horse returned, bringing with it three other wild horses. "How wonderful," the neighbors exclaimed. "May be," replied the old man.
The following day, his son tried to ride one of the untamed horses, was thrown, and broke his leg. The neighbors again came to offer their sympathy on his misfortune. "May be," answered the farmer.
The day after, military officials came to the village to draft young men into the army. Seeing that the son's leg was broken, they passed him by. The neighbors congratulated the farmer on how well things had turned out. "May be," said the farmer.
View pin.py
import re
def does_pin_match(pin):
# FROM https://docs.python.org/3/library/re.html
# Matches the end of the string or just before the newline at the end of the
# string, and in MULTILINE mode also matches before a newline. foo matches
# both ‘foo’ and ‘foobar’, while the regular expression foo$ matches only
# ‘foo’. More interestingly, searching for foo.$ in 'foo1\nfoo2\n' matches
# ‘foo2’ normally, but ‘foo1’ in MULTILINE mode; searching for a single $ in
@carlwiedemann
carlwiedemann / netrw quick reference.md
Created Feb 18, 2019 — forked from t-mart/netrw quick reference.md
A quick reference for Vim's built-in netrw file selector.
View netrw quick reference.md
Map Action
<F1> Causes Netrw to issue help
<cr> Netrw will enter the directory or read the file
<del> Netrw will attempt to remove the file/directory
- Makes Netrw go up one directory
a Toggles between normal display, hiding (suppress display of files matching g:netrw_list_hide) showing (display only files which match g:netrw_list_hide)
c Make browsing directory the current directory
C Setting the editing window
d Make a directory
View funtimes.php
<?php
print "<pre>";
$urls = [
[
'url' => 'https://badssl.com/',
'expected_http' => 200,
'expected_curl_errno' => 0,
'expected_curl_error' => '',
View reference.js
// See https://stackoverflow.com/questions/13104494/does-javascript-pass-by-reference
(function(){
var foo = [
'hello'
];
var replace_the_argument = function (some_array) {
some_array = ['hola'];
return some_array;
View test-static-cache.php
<?php
class A {
public $bar;
public function foo() {
static $cache = [];
if (!array_key_exists($this->bar, $cache)) {
$cache[$this->bar] = mt_rand();
}
View switch-is-broken.php
<?php
/**
* # EXPECTED
* $ php -f ./switch-is-broken.php
* the word alpha
* the word beta
* the default
* the default
* the number one
View probo-step.yaml
- name: Add php7
plugin: Script
script: |
echo 'exit 0' > /usr/sbin/policy-rc.d
apt-get update
apt-get install -y software-properties-common language-pack-en-base
LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y php7.0 libapache2-mod-php7.0 php7.0-gd php7.0-curl php7.0-json php7.0-mbstring php7.0-mysql php7.0-mcrypt php7.0-imagick php7.0-dev php7.0-gmp php7.0-xml php7.0-bcmath php7.0-redis php7.0-uploadprogress php7.0-soap php7.0-pgsql
cp /etc/php5/mods-available/general_settings.ini /etc/php/7.0/apache2/conf.d/20-general_settings.ini
View hello-banana.html
<html>
<head><title>hello banana</title></head>
<style media="screen">
div {
margin-bottom: 2px;
}
.outer-container {
position: relative;
View gist:df99050ecb67caab7b7c
Libraries We Use
The following sets forth attribution notices for third party software that may be contained in portions of the Instagram product. We thank the open source community for all of their contributions.
AFNetworking
The following software may be included in this product: AFNetworking. This software contains the following license and notice below:
Copyright (c) 2011 Gowalla (http://gowalla.com/)