Skip to content

Instantly share code, notes, and snippets.

@IsmailShurrab
IsmailShurrab / run-a-local-server-inside-dir.md
Created December 2, 2022 16:48 — forked from thagxt/run-a-local-server-inside-dir.md
Run a local web server inside any folder on Mac, Window, Linux, PHP, Node.js

Node.js

# Install http-server module globally 
npm install http-server -g

# Navigate to any directory you want the server to run in
cd /path/to/dir/with/files

# Launch HTTP server
# git
alias g="git"
alias gs="git status"
alias ga="git add ."
alias gc="git commit -m"
alias gn="git init && git add . && git commit -m \"init\""
# laravel
alias pa="php artisan"
alias l="php artisan serve"
"",
"Asia/Pacific Region",
"Europe",
"Andorra",
"United Arab Emirates",
"Afghanistan",
"Antigua and Barbuda",
"Anguilla",
"Albania",
"Armenia",
// Delete Attachments from Post ID 25
$attachments = get_posts(
array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_status' => 'any',
'post_parent' => 25,
)
);
foreach ( $attachments as $attachment ) {
@IsmailShurrab
IsmailShurrab / gist:037eacc23d97605aaf7059115767d3c7
Created October 13, 2019 14:09 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@IsmailShurrab
IsmailShurrab / wp-db.tutorial.php
Created October 12, 2019 14:48 — forked from benbalter/wp-db.tutorial.php
WordPress DB Tutorial
<?php
//absolute path to wp-load.php, or relative to this script
//e.g., ../wp-core/wp-load.php
include( 'trunk/wp-load.php' );
//grab the WPDB database object, using WP's database
//more info: http://codex.wordpress.org/Class_Reference/wpdb
global $wpdb;
@IsmailShurrab
IsmailShurrab / behov.sql
Created October 12, 2019 14:47 — forked from per42/behov.sql
SQL Behovsguiden
-- Create tables --
DROP TABLE IF EXISTS wp_posts;
CREATE TABLE wp_posts (
ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
post_type VARCHAR(255) NOT NULL DEFAULT 'hso_product',
post_status VARCHAR(255) NOT NULL DEFAULT 'publish',
menu_order INT NOT NULL DEFAULT 0
);
@IsmailShurrab
IsmailShurrab / iframechange.js
Created October 12, 2019 11:40 — forked from hdodov/iframechange.js
HTML iframe URL change listener for tracking when a new iframe page starts to load
function iframeURLChange(iframe, callback) {
var lastDispatched = null;
var dispatchChange = function () {
var newHref = iframe.contentWindow.location.href;
if (newHref !== lastDispatched) {
callback(newHref);
lastDispatched = newHref;
}
$string = "The text you want to filter goes here. http://google.com, https://www.youtube.com/watch?v=K_m7NEDMrV0,https://instagram.com/hellow/";
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $string, $match);
echo "<pre>";
print_r($match[0]);
echo "</pre>";
Create a posts array in your data:
...
data() {
return {
posts: []
}
},
....
Then create a method that fetches the records and assigns the result to the posts array: