Skip to content

Instantly share code, notes, and snippets.

View jonsecchis's full-sized avatar

Jon Secchis jonsecchis

View GitHub Profile
@jonsecchis
jonsecchis / how-to-add-image-to-gist.md
Created December 11, 2023 18:20 — forked from mroderick/how-to-add-image-to-gist.md
How to add an image to a gist

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone git@gist.github.com:<hash>.git     # or with ssh
@jonsecchis
jonsecchis / nginx.conf
Created June 30, 2022 18:40 — forked from jrom/nginx.conf
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
#!/usr/bin/env python3
#
# Test script to convert between xtilt/ytilt (Qt, Windows) and azimuth/altitude (iOS)
# Free to use for any purpose
import math
import secrets
# [azimuthRad, altitudeRad] => [tiltXrad, tiltYrad]
# azimuth in [0, 2*pi] range, altitude in [0, pi/2]
@jonsecchis
jonsecchis / image-arraybuffer.js
Created April 6, 2021 17:45 — forked from candycode/image-arraybuffer.js
Create a jpg image from ArrayBuffer data
// Simulate a call to Dropbox or other service that can
// return an image as an ArrayBuffer.
var xhr = new XMLHttpRequest();
// Use JSFiddle logo as a sample image to avoid complicating
// this example with cross-domain issues.
xhr.open( "GET", "http://fiddle.jshell.net/img/logo.png", true );
// Ask for the result as an ArrayBuffer.
xhr.responseType = "arraybuffer";
@jonsecchis
jonsecchis / ajax.js
Created October 23, 2020 18:07 — forked from xeoncross/ajax.js
Simple, cross-browser Javascript POST/GET xhr request object. Supports request data and proper AJAX headers.
/**
* IE 5.5+, Firefox, Opera, Chrome, Safari XHR object
*
* @param string url
* @param object callback
* @param mixed data
* @param null x
*/
function ajax(url, callback, data, x) {
try {
@jonsecchis
jonsecchis / -etc-sysctl
Created October 22, 2020 20:10 — forked from mbbx6spp/-etc-sysctl
Ephemeral port range on OS X
net.inet.ip.portrange.first=32768
net.inet.ip.portrange.hifirst=32768
net.inet.tcp.msl=1000
# for postgresql
kern.sysv.shmall=65536
kern.sysv.shmmax=16777216
# defaults
net.inet.ip.portrange.lowfirst=1023
/*!
Math.uuid.js (v1.4)
http://www.broofa.com
mailto:robert@broofa.com
Copyright (c) 2010 Robert Kieffer
Dual licensed under the MIT and GPL licenses.
*/
/*
@jonsecchis
jonsecchis / script.js
Created September 2, 2020 20:07 — forked from bramus/script.js
List of valid HTML Elements
// Run this on https://developer.mozilla.org/en/docs/Web/HTML/Element
var tags = [], nodeList = document.querySelectorAll('td a code');
for (i in nodeList) {
if ((nodeList[i].innerText) && (nodeList[i].innerText.indexOf('<') > -1)) {
var tag = nodeList[i].innerText.replace('<','"').replace('>','"');
if (tags.indexOf(tag) == -1) {
tags.push(tag);
}
}
}
@jonsecchis
jonsecchis / generate-pushid.js
Created August 22, 2020 14:24 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@jonsecchis
jonsecchis / easing.js
Created October 16, 2019 04:41 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity