Skip to content

Instantly share code, notes, and snippets.

View jb41's full-sized avatar

Michal Oblak jb41

View GitHub Profile
-- show slow queries eating whole CPU
SELECT substring(query, 1, 50) AS short_query, round(total_time::numeric, 2) AS total_time, calls, rows, round(total_time::numeric / calls, 2) AS avg_time, round((100 * total_time / sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu FROM pg_stat_statements ORDER BY total_time DESC LIMIT 20;
-- same as above but whole query
SELECT query AS short_query, round(total_time::numeric, 2) AS total_time, calls, rows, round(total_time::numeric / calls, 2) AS avg_time, round((100 * total_time / sum(total_time::numeric) OVER ())::numeric, 2) AS percentage_cpu FROM pg_stat_statements ORDER BY total_time DESC LIMIT 20;
<body>
<h1 class="title" sheetsu-key="Header">
DrivePages by Sheetsu - simplest solution to host websites
</h1>
<h2 class="subtitle">
<a href="https://sheetsu.com/pages" sheetsu-key="Main link">
Visit pages.sheetsu.com
</a>
</h2>
<a href="#" onclick='Intercom("showNewMessage", "Hello there! 👋 I want to add domain to my Sheetsu Page")'>Add Domain</a>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="//script.sheetsu.com/"></script>
</head>
<body>
<script>
function getParamsFromUrl(url) {
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<form id="form">
<input type="text" name="name">
<input type="text" name="score">
<button type="submit">submit</button>
angular.module('app').service('Subjucator', [
'$http', function($http) {
return {
get: function(url) {
return $http.get(url);
},
post: function(url, data) {
return $http.post(url, data);
}
};
@jb41
jb41 / error.rb
Created July 30, 2016 16:49
Dynamically create Error classes
module SheetCRUD
module Error
ERRORS = [
unauthorized: { message: 'Unauthorized.', status: 401 },
limit_exceed: { message: 'Rate limit exceed.', status: 429 },
not_found: { message: 'Not found.', status: 404 }
]
class StandardAPIError < StandardError
import requests
url = 'https://sheetsu.com/apis/YOUR_API_ID'
data = {"timestamp": "1458819671995", "idea": "wooho"}
r = requests.post(url, json=data)
print r.status_code
print r.json()
<html>
<head>
<script src="https://code.jquery.com/jquery-3.0.0-alpha1.js"></script>
</head>
<body>
<ul id="characters-list"></ul>
<script>
var sheetsuUrl = "https://sheetsu.com/apis/v1.0/020b2c0f";
require 'pry'
require 'json'
require 'httparty'
require 'stripe'
class ChargeApp < Sinatra::Base
AMOUNT = 300
Stripe.api_key = "SECRET_STRIPE_KEY"