- Create or find a gist that you own.
- Clone your gist (replace
<hash>with your gist's hash):# with ssh git clone [email protected]:<hash>.git mygist # with https
git clone https://gist.github.com/.git mygist
| #!/bin/bash | |
| # | |
| # Bash must have been compiled with this ability: --enable-net-redirections | |
| # The device files below do not actually exist. | |
| # Use /dev/udp for UDP sockets | |
| exec 3<>/dev/tcp/host/port | |
| # Write to the socket as with any file descriptor | |
| echo "Write this to the socket" >&3 |
| >>> from jinja2 import Template | |
| >>> tmpl = """{% if name != "Jeff" %}Nothing to see here move along{% else %} | |
| ... hello {{name}}, how are you?{% endif %}""" | |
| >>> template = Template(tmpl) | |
| >>> print template.render({"name": "Jeff"}) | |
| hello Jeff, how are you? | |
| >>> print template.render({"name": "John"}) | |
| Nothing to see here move along | |
| >>> |
| /* | |
| * circular-reference-detect.js | |
| * author: Hiroshi Kori | |
| * | |
| * Detect circular reference of linked list | |
| * | |
| * 1) Overview | |
| * - Reverse linked-list until finding a node whose next pointer is null. | |
| * - Chekck the head node if its next pointer is null | |
| * 1) null: the node is not traversed twice. (no circular reference) |
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| Vagrant.configure("2") do |config| | |
| # All Vagrant configuration is done here. The most common configuration | |
| # options are documented and commented below. For a complete reference, | |
| # please see the online documentation at vagrantup.com. | |
| # Every Vagrant virtual environment requires a box to build off of. | |
| config.vm.box = "ubuntu1204_64" |
| # Join multiple lines without new line | |
| value: > | |
| part 1 | |
| part 2 | |
| # Join with newline | |
| value2: | | |
| line 1 | |
| line 2 |
| from flask import Flask, request | |
| import requests | |
| import json | |
| app = Flask(__name__) | |
| def msg_process(msg, tstamp): | |
| js = json.loads(msg) | |
| msg = 'Region: {0} / Alarm: {1}'.format( | |
| js['Region'], js['AlarmName'] |
| #!/bin/bash | |
| if [ -z "$1" ]; then | |
| echo "Usage: git pr [clean] [<remote>] <id-or-url>" | |
| echo "" | |
| echo "Examples:" | |
| echo "git pr 42 --> git fetch origin pull/42/head:pr/origin/42" | |
| echo "git pr upstream 42 --> git fetch upstream pull/42/head:pr/upstream/42" | |
| echo "git pr https://github.com/peerigon/phridge/pull/1 --> git fetch https://github.com/peerigon/phridge.git pull/1/head:pr/peerigon/phridge/1" | |
| echo "git pr clean --> Deletes all branches that match pr/*/* and pr/*/*/*" |
| function hoverable (WrappedComponent, propName = 'hover') { | |
| return class HoverableComponent extends Component { | |
| constructor (props) { | |
| super(props) | |
| this.state = { hovered: false } | |
| } | |
| turnHoverOn () { | |
| this.setState({ hovered: true }) |
<hash> with your gist's hash):
# with ssh
git clone [email protected]:<hash>.git mygist
# with httpsgit clone https://gist.github.com/.git mygist
| var convertToString = function(array) { | |
| return array.map((item, index) => '"' + index + ' ' + item.replace(/"/g, '') + '"').join(''); | |
| } | |
| var find = function(needle, sourceAsString, source) { | |
| var rx = new RegExp('"(\\d+) ([^"]*' + needle + '[^"]*)"','gi'); | |
| var i = 0, results = []; | |
| while (result = rx.exec(sourceAsString)) { | |
| results.push(result[1]); | |
| if (results.length >= 100) { |