Skip to content

Instantly share code, notes, and snippets.

@hissy
hissy / hard_coded.php
Last active March 5, 2018 15:52
[concrete5] Render the hard coded select attribute options list
<?php
$navigation = Loader::helper('navigation');
$c = Page::getCurrentPage();
// get the attribute key by handle
$ak = CollectionAttributeKey::getByHandle('your_attribute_handle');
// get the attribute type controller
$atc = $ak->getController();
// check if the attibure type is select
if ($atc instanceOf SelectAttributeTypeController) {
function isPointInPoly(poly, pt) {
for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)
((poly[i][1] <= pt.y && pt.y < poly[j][1]) || (poly[j][1] <= pt.y && pt.y < poly[i][1])) && (pt.x < (poly[j][0] - poly[i][0]) * (pt.y - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0]) && (c = !c);
return c;
}
isPointInPoly([[1, 1], [5, 1], [5, 5], [1, 5]], {x: 2, y: 2}); //true
isPointInPoly([[1, 1], [5, 1], [5, 5], [1, 5]], {x: 100, y: 100}); //false
@socketz
socketz / 0_nginx_example_config.md
Last active August 8, 2018 02:57
Prestashop 1.6.x + Nginx 1.13.x + PHP-FPM 7.0 + SSL Let's Encrypt Configuration Example

Prestashop 1.6.x + Nginx 1.13.x + PHP-FPM 7.0 + SSL Let's Encrypt

Place the files on next paths or other and replace in the files below:

  • /data/nginx/config/global/acme-challenge.conf
  • /data/nginx/config/global/restrictions.conf
  • /data/nginx/config/global/expires.conf
  • /data/nginx/config/snippets/ssl-params.conf
  • /data/nginx/config/conf.d/example.com.conf
<?php
/**
* Todo: Send a random user agent string and sleep a random amount between requests.
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Extract and sanatize input:
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_URL);
$terms = filter_input(INPUT_POST, 'terms', FILTER_SANITIZE_STRING);
// Setup Goutte (which also includes Guzzle):
@frozeman
frozeman / gist:b3f016de58b04c99cfc3
Created November 11, 2014 20:27
Steps in phantomjs
var page = new WebPage(), testindex = 0, loadInProgress = false;
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.onLoadStarted = function() {
loadInProgress = true;
console.log("load started");
};
@oliyh
oliyh / image-url-to-data-uri.js
Created November 7, 2015 22:17
Convert an image url to a data URI without canvas
// hard won knowledge from http://stackoverflow.com/questions/20035615/using-raw-image-data-from-ajax-request-for-data-uri
var xmlHTTP = xhr.XMLHttpRequest();
xmlHTTP.open('GET', url, true);
xmlHTTP.responseType = 'arraybuffer';
xmlHTTP.onload = function(e) {
var arr = new Uint8Array(this.response);
var raw = String.fromCharCode.apply(null,arr);
var b64 = base64.encode(raw);
var dataURL="data:image/png;base64," + b64;
};
@ecin
ecin / phantomjs_facebook.js
Created April 23, 2012 21:06
Log into Facebook with phantomJS
console.log("got here");
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open("http://facebook.com", function(status) {
if ( status === "success" ) {
@davidtsadler
davidtsadler / add_item.php
Last active June 14, 2022 00:13
Example showing how to list an item to the eBay Sandbox using the eBay Accelerator Toolkit New Schema (EbatNS) for PHP.
<?php
/*
* Author: David T. Sadler (http://davidtsadler.com)
* Date: 2013-03-29
* License: I release this example into the public domain. Use at your own risk.
*
* Example showing how to list an item to the eBay Sandbox using the eBay Accelerator Toolkit New Schema (EbatNS) for PHP.
*
* This example uses version 815 released on the 2013-03-22.
* http://www.intradesys.de/en/system/files/its_downloads/EbatNs_1_0_815_P5_0.zip
@eresonance
eresonance / pull_from_thinkware.sh
Created July 14, 2019 17:52
Script to pull videos from a thinkware wifi camera via ftp
#!/bin/sh
set -e
#set -x
usage () {
cat <<EOF
Usage: $0 [-v|--verbose] [-h|--help] [-f|--from "dirs on camera"] [-t|--to "backup location"] camera_ip
EOF
}
@erikreagan
erikreagan / mac-apps.md
Created August 4, 2012 19:18
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik