Skip to content

Instantly share code, notes, and snippets.

View jboulhous's full-sized avatar

Jamal Boulhous jboulhous

  • Morocco, Africa
View GitHub Profile
@ahmadawais
ahmadawais / upload-a-file.MD
Created June 18, 2017 11:07 — forked from websupporter/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

@kirilloid
kirilloid / type.js
Last active July 29, 2022 19:42
getType
function getType (value) {
let type = typeof value;
if (type === 'object') {
return value ? Object.prototype.toString.call(value).slice(8, -1) : 'null';
}
return type;
}
[NaN, 0, 1, Infinity, // numbers
null, undefined, false, 'str', // other primitives
@dmvaldman
dmvaldman / promisesEM.md
Last active June 1, 2024 00:20
Promises as EventEmitters

Promises as EventEmitters

I was trying to understand JavaScript Promises by using various libraries (bluebird, when, Q) and other async approaches.

I read the spec, some blog posts, and looked through some code. I learned how to

@ilfroloff
ilfroloff / ClassA.js
Last active March 4, 2024 09:01
JavaScript Singleton using class
'use strict';
import Singleton from 'Singleton';
class ClassA extends Singleton {
constructor() {
super();
}
singletonMethod1() {
// ...
@ewnd9
ewnd9 / npm-wrapper.sh
Last active January 18, 2016 11:02
Prevent executing "npm install <deps>" without `-S`, `-D`, `--save`, `--save-dev`, `-g` flags
#!/bin/bash
set -e
if ([ "$1" == "install" ] || [ "$1" == "i" ]) && [ "$#" -ne 1 ]; then
for var in "$@"
do
if [ "$var" == "--save" ] || [ "$var" == "--save-dev" ] || [ "$var" == "-S" ] || [ "$var" == "-D" ] || [ "$var" == "-g" ]; then
has_modifier=true
fi
@Skatox
Skatox / wc-api-custom.php
Created November 16, 2015 21:19
Woocommerce API REST custom path
<?php
/**
* Custom API REST path class
*
* @package MyPlugin
* @author Skatox
*/
class WC_API_Custom extends WC_API_Resource
{
@paulirish
paulirish / bling.js
Last active November 4, 2024 17:48
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
};
NodeList.prototype.__proto__ = Array.prototype;