This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| For instance, if you want to use a string as part of a URL but | |
| need to make it safe for that kind of use. | |
| */ | |
| function replace_accents($str) { | |
| $str = htmlentities($str, ENT_COMPAT, "UTF-8"); | |
| $str = preg_replace('/&([a-zA-Z])(uml|acute|grave|circ|tilde);/','$1',$str); | |
| return html_entity_decode($str); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function check_alive($url, $timeout = 10, $successOn = array(200, 301)) { | |
| $ch = curl_init($url); | |
| // Set request options | |
| curl_setopt_array($ch, array( | |
| CURLOPT_FOLLOWLOCATION => false, | |
| CURLOPT_NOBODY => true, | |
| CURLOPT_TIMEOUT => $timeout, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% if app.session.flashbag.peekAll|length > 0 %} | |
| {% for type, messages in app.session.flashbag.all %} | |
| {% for message in messages %} | |
| <div class="{{ type ? type : '' }}"> | |
| {{ message|trans({}, domain|default('messages')) }} | |
| </div> | |
| {% endfor %} | |
| {% endfor %} | |
| {% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Get all users | |
| var url = "http://localhost:8080/api/v1/users"; | |
| var xhr = new XMLHttpRequest() | |
| xhr.open('GET', url, true) | |
| xhr.onload = function () { | |
| var users = JSON.parse(xhr.responseText); | |
| if (xhr.readyState == 4 && xhr.status == "200") { | |
| console.table(users); | |
| } else { | |
| console.error(users); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # This is a simple port-forward / proxy, written using only the default python | |
| # library. If you want to make a suggestion or fix something you can contact-me | |
| # at voorloop_at_gmail.com | |
| # Distributed over IDC(I Don't Care) license | |
| # http://voorloopnul.com/blog/a-python-proxy-in-less-than-100-lines-of-code/ | |
| import socket | |
| import select | |
| import time | |
| import sys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| ''' | |
| Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library. | |
| Features: | |
| * Map URI patterns using regular expressions | |
| * Map any/all the HTTP VERBS (GET, PUT, DELETE, POST) | |
| * All responses and payloads are converted to/from JSON for you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| systemctl stop postgresql && pacman -Syu --noconfirm && su - postgres -c 'mv /var/lib/postgres/data /var/lib/postgres/olddata' && su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'" && systemctl start postgresql.service && systemctl stop postgresql.service && pacman -S postgresql-old-upgrade --noconfirm && su - postgres -c 'pg_upgrade -d /var/lib/postgres/olddata/ -D /var/lib/postgres/data/ -b /opt/pgsql-9.4/bin/ -B /usr/bin/' && /var/lib/postgres/delete_old_cluster.sh && rm /var/lib/postgres/delete_old_cluster.sh && /var/lib/postgres/analyze_new_cluster.sh && systemctl start postgresql.service && pacman -Rs postgresql-old-upgrade --noconfirm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Demo of streaming requests with Tornado. | |
| This script features a client using AsyncHTTPClient's body_producer | |
| feature to slowly produce a large request body, and two server | |
| handlers to receive this body (one is a proxy that forwards to the | |
| other, also using body_producer). | |
| It also demonstrates flow control: if --client_delay is smaller than | |
| --server_delay, the client will eventually be suspended to allow the | |
| server to catch up. You can see this in the logs, as the "client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| log_format long '$remote_addr - $remote_user [$time_local] ' | |
| '"$request" $status $body_bytes_sent ' | |
| '"$http_referer" "$http_user_agent" $request_time'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket, traceback | |
| HOST = '' | |
| PORT = 51235 | |
| CLRF = '\r\n' | |
| class InvalidRequest(Exception): | |
| pass | |
| class Request(object): |
NewerOlder