Skip to content

Instantly share code, notes, and snippets.

@jarodium
jarodium / downloader.js
Created July 3, 2020 12:19 — forked from jhidalgo3/downloader.js
Use NodeJS to download files
var path = require('path');
var url = require('url');
var http = require('http');
var fs = require('fs');
var write_file;
//what global variable do we have?
var complete = false;
var content_length = 0;
var downloaded_bytes = 0;
@jarodium
jarodium / test1.php
Last active November 5, 2019 20:05
Predominant color with VIPS
<?php
require '../vendor/autoload.php';
use Jcupitt\Vips;
Vips\Config::concurrencySet(2);
Vips\Config::CacheSetMax(0);
//header("Content-type: text/plain");
//var_dump($_REQUEST);
$mime = "jpeg";
@jarodium
jarodium / sw.js
Created December 25, 2018 15:12
Service Worker
'use strict';
var cacheVersion = 1;
var currentCache = {
offline: 'offline-cache' + cacheVersion
};
const offlineUrl = 'offline.html';
this.addEventListener('install', event => {
event.waitUntil(
@jarodium
jarodium / mail.php
Last active November 11, 2018 14:45
Open Simplex implementation in php
<?php
use ajf\TypedArrays\Uint8Array;
use ajf\TypedArrays\Float32Array;
class openSimplexNoise {
/*
* Class Open Simplex
* Direct PHP implementation based on Jonas Wagner ( https://github.com/jwagner/simplex-noise.js/blob/master/simplex-noise.js )
* implementation for javascript which is based on example code by Stefan Gustavson ([email protected]).
* eith Optimisations by Peter Eastman ([email protected]).
@jarodium
jarodium / traveling-salesman.php
Created November 1, 2018 10:00 — forked from tlhunter/traveling-salesman.php
PHP Traveling Salesman Genetic Algorithm
<?php
ini_set("error_reporting", E_ALL & ~E_NOTICE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Genetic Algorithm : TSP : PHP Implementation by Thomas Hunter</title>
<style>
body {
@jarodium
jarodium / swipe.js
Created October 23, 2017 13:10
Updated version of swipe.js from Blake Simpson's Blog. This version supports miltitouch
$.fn.swipe = function( callback ) {
var touchDown = false,
originalPosition = null,
$el = $( this );
function swipeInfo( event ) {
if ('undefined' !== typeof event.originalEvent.pageX) {
var x = event.originalEvent.pageX,
y = event.originalEvent.pageY,
dx, dy;
@jarodium
jarodium / gist:1fe78f25a1fd6cbb83b57aaa264a65b5
Created April 20, 2017 22:23 — forked from sandrinodimattia/gist:3162314
Dynamics CRM 2011 eID Javascript
<html>
<head>
<title>eID: Read</title>
<script type="text/javascript" src="https://localhost:100/be_belgium_eid.js"></script>
<script language="javascript" type="text/javascript">
// Initialize the reader.
var cardReader = new be.belgium.eid.CardReader();
// Bind error events.
function noCardPresentHandler() { window.alert("No card present!"); }
@jarodium
jarodium / one.js
Created September 15, 2016 08:19
Clear all Cookies with JS
document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
@jarodium
jarodium / index.js
Created November 25, 2015 11:21
Jquery inputs numéricos
$("#txtboxToFilter").keydown(function (e) {
// Allow: backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Allow: Ctrl+A, Command+A
(e.keyCode == 65 && ( e.ctrlKey === true || e.metaKey === true ) ) ||
// Allow: home, end, left, right, down, up
(e.keyCode >= 35 && e.keyCode <= 40)) {
// let it happen, don't do anything
return;
}
@jarodium
jarodium / zoho.php
Last active December 13, 2016 23:43
Zoho CRM API Class
<?
class ZOHO {
private $U = "";
private $P = "";
protected $BURL = 'https://crm.zoho.com/crm/private/xml/';
protected $token = "";
protected $pdata = array();
public function __construct() {
$this->pdata = array("authtoken" => $this->token,"scope" => "crmapi");