Skip to content

Instantly share code, notes, and snippets.

Working from home

Otman Bouchari obouchari

Working from home
Block or report user

Report or block obouchari

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
obouchari / fp.js
Created Jan 10, 2018
FP pipe and compose util functions in ES2015
View fp.js
// Pipe
const pipe = (...fns) =>
(...input) =>
fns.reduce(function(input, fn) {
if (typeof fn !== 'function') {
throw Error(`expect a "function" instead got "${typeof fn}".`);
return fn(...[].concat(input));
}, input);
obouchari / Asset.js
Created Dec 20, 2014
Smooth Scroll Anchors
View Asset.js
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
scrollTop: target.offset().top
}, 1000);
return false;
obouchari / Asset.php
Created Dec 20, 2014
Detecte Mobile Devices
View Asset.php
function is_mobile(){
// returns true if one of the specified mobile browsers is detected
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220";
obouchari / CSS: Image replacement
Last active Dec 23, 2015
CSS: Image replacement
View CSS: Image replacement
.hide {
bottom: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
View Payments online with PHP
So you want to accept payments online with PHP?
- Well, you probably don't want to handle that process manually. Too dangerous and risky.
- So learn the Stripe API. Works great!
- But you'll still need to setup SSL. So go learn how to do that.
- Stripe provides a PHP package, so download that through Composer. If you're not familiar with Composer, you'll need to learn that too.
- If you want the most flexibility, you'll want to manually create the payment form.
- So you'll need to send an AJAX request with a special token to Stripe's API. jQuery makes this easy, so go learn jQuery.
- Once the payment completes, you'll likely want to send the buyer a "Purchased" email, so learn how to send email.
- But don't make the user wait for the email to send. That takes too long. Add that to a background job.
You can’t perform that action at this time.