Skip to content

Instantly share code, notes, and snippets.

@metecik
metecik / jq-cheetsheet.md
Created November 4, 2024 05:44 — forked from olih/jq-cheetsheet.md
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@metecik
metecik / mysql_ip_address_info.sql
Created February 22, 2024 05:49 — forked from chris/mysql_ip_address_info.sql
Get list of IP addresses connected to MySQL DB, with their connection counts
SELECT
tmp.ipAddress,
-- Calculate how many connections are being held by this IP address.
COUNT( * ) AS numConnections,
-- For each connection, the TIME column represent how many SECONDS it has been in
-- its current state. Running some aggregates will give us a fuzzy picture of what
-- the connections from this IP address is doing.
FLOOR( AVG( tmp.time ) ) AS timeAVG,
@metecik
metecik / compiling_standalone.md
Created February 22, 2024 05:42 — forked from guest271314/compiling_standalone.md
Compiling a standalone executable using modern JavaScript/TypeScript runtimes

Compiling a standalone executable using modern JavaScript/TypeScript runtimes

We have the same code working using node, deno, and bun.

E.g.,

bun run index.js
@metecik
metecik / cloudflareworker-verifyjwt.js
Created August 18, 2022 14:42 — forked from bcnzer/cloudflareworker-verifyjwt.js
Sample Cloudflare worker that gets the JWT, ensures it hasn't expired, decrypts it and returns a result
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
// Following code is a modified version of that found at https://blog.cloudflare.com/dronedeploy-and-cloudflare-workers/
/**
* Fetch and log a request
* @param {Request} request
*/
@metecik
metecik / haproxy.cfg
Created October 24, 2019 09:12 — forked from Philmod/haproxy.cfg
HAProxy configuration for the socket.io chat example, splitted into frontend and websocket servers.
global
log 127.0.0.1 local0
maxconn 8192
user haproxy
group haproxy
defaults
log global
mode http
option httplog
@metecik
metecik / events.js
Created November 2, 2018 08:20 — forked from tbranyen/events.js
Rethinking events using ES6 (https://tbranyen.com/events)
const bus = {};
const get = e => (bus[e] = bus[e] || new Set());
export const listeners = new Proxy(bus, { get });
export const emit = (e, ...args) => listeners[e].forEach(fn => fn(...args));
@metecik
metecik / .zshrc
Last active August 29, 2015 14:18 — forked from SlexAxton/.zshrc
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
<?php
//işin sırrı headerdaki X-Requested-With: XMLHttpRequest de :)
class bcurl {
private $curl;
private $debug = false;
private $normalizeUtf = true;
public $cookieFile = 'cookie.txt';
public $user_agent = 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0';
public $gzip = "Accept-Encoding: gzip,deflate";