Skip to content

Instantly share code, notes, and snippets.

Status

This extension was developed as part of the jsonapi module for Drupal.

Introduction

The JSON API specification is agnostic about how a server implements filtering strategies. In fact, the spec says:

Note: JSON API is agnostic about the strategies supported by a server. The filter query parameter can be used as the basis for any number of filtering strategies.

<?php
function get_tls_version($sslversion = null)
{
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "https://www.howsmyssl.com/a/check");
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
if ($sslversion !== null) {
curl_setopt($c, CURLOPT_SSLVERSION, $sslversion);
}
pool: number indicating size of connection pool (default 5)
checkout_timeout: number of seconds to block and wait for a connection before giving up and raising a timeout error (default 5 seconds).
reaping_frequency: frequency in seconds to periodically run the Reaper, which attempts to find and close dead connections, which can occur if a programmer forgets to close a connection at the end of a thread or a thread dies unexpectedly. (Default nil, which means don't run the Reaper).
dead_connection_timeout: number of seconds from last checkout after which the Reaper will consider a connection reapable. (default 5 seconds).
encoding: (Optional) Sets the client encoding by executing "SET NAMES <encoding>" after connection.
reconnect: Defaults to false (See MySQL documentation: dev.mysql.com/doc/refman/5.0/en/auto-reconnect.html).
strict: Defaults to true. Enable STRICT_ALL_TABLES. (See MySQL documentation: dev.mysql.com/doc/refman/5.0/en
@Fivell
Fivell / chat.rb
Created December 13, 2019 10:41 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do
@Fivell
Fivell / results
Created July 2, 2019 18:29
heapy read dump.txt all
Analyzing Heap (Generation: all)
-------------------------------
allocated by memory (20764682) (in bytes)
==============================
10015347 /usr/lib/ruby/2.5.0/json/common.rb:156
6298848 /usr/lib/ruby/2.5.0/webrick/server.rb:286
1050325 eval:1
1049592 /usr/lib/ruby/2.5.0/webrick/utils.rb:202
1049480 /usr/lib/ruby/2.5.0/webrick/utils.rb:187
metrics
# HELP ruby_collector_working Is the master process collector able to collect metrics
# TYPE ruby_collector_working gauge
ruby_collector_working 1
# HELP ruby_collector_rss total memory used by collector process
# TYPE ruby_collector_rss gauge
ruby_collector_rss 0
@Fivell
Fivell / pg_application_name_patch.rb
Created December 12, 2018 15:57 — forked from vagmi/pg_application_name_patch.rb
Set the application name for a postgres connection in Rails 3
module ActiveRecord
module ApplicationName
def self.included(base)
unless base.respond_to? :establish_connection_with_application_name
base.extend ClassMethods
base.class_eval do
class << self
alias_method_chain :establish_connection, :application_name
end
end
@Fivell
Fivell / order.js
Created June 13, 2018 11:54 — forked from af23me/order.js
$.ajax({
type: 'POST',
url: "https://sandbox-api.didww.com/v3/orders",
data: JSON.stringify({
data: {
type: "orders",
attributes: {
allow_back_ordering: false,
items: [{
type: "did_order_items",
@Fivell
Fivell / mock_tcp_socket.rb
Created September 7, 2017 16:22 — forked from earlonrails/mock_tcp_socket.rb
Mock tcp socket for spec tests with ruby!!!
require 'socket'
require 'mocks'
TCP_NEW = TCPSocket.method(:new) unless defined? TCP_NEW
#
# Example:
# mock_tcp_next_request("<xml>junk</xml>")
#
class FakeTCPSocket
@Fivell
Fivell / curl.md
Created July 26, 2017 18:48 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.