Skip to content

Instantly share code, notes, and snippets.

View stratboy's full-sized avatar

Luca Reghellin stratboy

View GitHub Profile
@joashp
joashp / openssl_encrypt_decrypt.php
Created September 4, 2015 15:59
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@jfairbank
jfairbank / poll-promise.js
Created June 3, 2015 16:23
poll promise
function poll(fn, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
return new Promise(function(resolve, reject) {
(function p() {
// If the condition is met, we're done!
if (fn()) {
resolve();
}
/**
* Problem: an Hammer.JS instance listens to the horizontal swipe gestures
* targeted at a top-level html element (e.g.: body) in order to show/hide
* an off-canvas menu; it should be possible to browse a touch-enabled carousel
* placed in the same page (e.g.: RoyalSlider, Owl Carousel or similar) without
* interfering with the above listener.
*
* Solution: enable Hammer.JS custom DOM events and prevent any "swipe" gesture
* from bubbling up to the body element by stopping event propagation via listeners
* attached to each nested touch-enabled element (e.g.: the carousel)
@ocean90
ocean90 / box-shadow.html
Last active April 11, 2024 13:54
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@draeton
draeton / checkImage.example.js
Last active January 1, 2023 03:30
Check the existence of an image file at `url` by creating a temporary Image element.
// Example Use
(function () {
function success() {
console.log("success: ", this.src);
}
function failure() {
console.log("failure: ", this.src);
}