Skip to content

Instantly share code, notes, and snippets.

View abusedmedia's full-sized avatar

Fabio Franchino abusedmedia

View GitHub Profile
const distance = (lat1,lon1,lat2,lon2) => {
lon1 = lon1 * Math.PI / 180
lon2 = lon2 * Math.PI / 180
lat1 = lat1 * Math.PI / 180
lat2 = lat2 * Math.PI / 180
let dlon = lon2 - lon1;
let dlat = lat2 - lat1;
let a = Math.pow(Math.sin(dlat / 2), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(dlon / 2),2)
@abusedmedia
abusedmedia / ember-sandbox-service.js
Created October 18, 2022 07:46 — forked from devotox/ember-sandbox-service.js
Create A Javascript sandbox to execute custom code without giving access to things like window and outer contextThey still have a `this` object they can use across multiple executions to persist data
import Service from '@ember/service';
const has = () => true;
const { console, WeakMap, Proxy, Symbol } = window;
const get = (target, key) => key === Symbol.unscopables ? undefined : target[key];
export default Service.extend({
@abusedmedia
abusedmedia / example.js
Created October 1, 2021 17:50 — forked from andrei-tofan/example.js
node.js writable buffer stream (pdfkit example)
/**
* Convert PDFDocument to Base64
*/
const PDFDocument = require('pdfkit');
const stream = require('./stream');
// crate document and write stream
let doc = new PDFDocument();
let writeStream = new stream.WritableBufferStream();
col.append('<div class="item" style="flex:'+flex_value_row+';background-color:'+color+';margin-bottom:'+border_bottom+'px;"></div>')
var col = $('<div class="col" style="flex:'+flex_value_col+';"></div>')
function gen(){
$('body').empty()
var number_column = parseInt(Math.random()*6) + 2
for(var i=0; i<number_column; ++i){
var number_rows = parseInt(Math.random()*50) + 5
<script async id="__bs_script__"
src="http://localhost:3000/ browser-sync/ browser-sync-client.js?v=2.18.8 ">
</script>
browser-sync start --localOnly --files './app'

Brute Force Layout

Processing source code, more info here

@abusedmedia
abusedmedia / .block
Created November 13, 2016 20:52 — forked from HarryStevens/.block
Basic Map Functions
license: gpl-3.0