Skip to content

Instantly share code, notes, and snippets.

View alexcroox's full-sized avatar
🙈
code is my own and does not reflect the quality my employer expects

Alex alexcroox

🙈
code is my own and does not reflect the quality my employer expects
View GitHub Profile
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages
@remy
remy / now-realias.js
Last active September 6, 2016 11:38
Quick `now` re-alias script, if run inside the current project dir
#!/usr/bin/env node
const Now = require('now-client');
const now = Now(); // this looks like it detect the token from ~/.now.json or the env automatically
const pkg = require(process.cwd() + '/package.json');
now.getDeployments().then(res => {
const [latest, prev, ...rest] = res.filter(_ => _.name === pkg.name).sort((a, b) => b.created - a.created);
console.log(`getting alias for ${prev.uid} (${prev.url})`);
return now.getAliases(prev.uid).then(res => {
@danharper
danharper / CatchAllOptionsRequestsProvider.php
Last active April 20, 2024 01:53
Lumen with CORS and OPTIONS requests
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
/**
* If the incoming request is an OPTIONS request
* we will register a handler for the requested route
*/
class CatchAllOptionsRequestsProvider extends ServiceProvider {
@Fusselwurm
Fusselwurm / marker.sqf
Last active December 17, 2015 00:09
In ArmA, set a fuzzy marker on a player's position
private ["_markerPos", "_inner_marker", "_helper_marker"];
trackingPrecision = 50; //marker precision (radius)
gpsSleepTimeMin = 120;
gpsSleepTimeMax = 300;
_markerPos = (getPos _this);
_inner_marker = createMarker ["agentmarker", _markerPos];
@lanqy
lanqy / bytesToSize.js
Created March 19, 2013 03:05
JavaScript To Convert Bytes To MB, KB, Etc
// from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/
function bytesToSize(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return 'n/a';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
if (i == 0) return bytes + ' ' + sizes[i];
return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
};
@tmcw
tmcw / xyz_vs_tms.md
Last active April 3, 2024 06:18
The difference between XYZ and TMS tiles and how to convert between them

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

@powdahound
powdahound / hipchat_bot.js
Created April 25, 2011 18:35
Basic XMPP bot example for HipChat using node.js
// Basic XMPP bot example for HipChat using node.js
// To use:
// 1. Set config variables
// 2. Run `node hipchat_bot.js`
// 3. Send a message like "!weather 94085" in the room with the bot
var request = require('request'); // github.com/mikeal/request
var sys = require('sys');
var util = require('util');