Skip to content

Instantly share code, notes, and snippets.

View ziaenezhad's full-sized avatar
🧑‍💻
Is typing ...

Sajjad Ziaenezhad Shirazi ziaenezhad

🧑‍💻
Is typing ...
View GitHub Profile
@zgordon
zgordon / enqueue-block-css.php
Last active October 11, 2023 13:50
This example shows how to use enqueue_block_assets to enqueue custom block CSS on the frontend of a theme and in the Gutenberg editor.
<?php
/**
* Enqueue block styles on frontend and in editor
*
*/
function mytheme_block_styles() {
wp_enqueue_style( 'mytheme-blocks', get_stylesheet_directory_uri() . '/css/blocks.css' );
@benmccallum
benmccallum / _Instructions.md
Last active July 25, 2021 03:35
nuxtjs, bootstrap-vue with custom bootstrap build

Important! This guide is out of date (circa 2017) and should no longer be used. For the latest advice, please refer to the BootstrapVue docs and their Nuxt.js module. https://bootstrap-vue.org/docs#nuxt-js

General setup:

  1. Install bootstrap as a dev dependency, and its dependencies (node-sass and sass-loader) npm install --save-dev bootstrap@4.0.0-beta.2 node-sass sass-loader
@AloofBuddha
AloofBuddha / sequelize-cheat-sheet.md
Created September 26, 2016 14:28
Sequelize cheat sheet

Note: $> means command line input

Dependencies

Dependencies to use Sequelize $> npm install --save sequelize pg pg-hstore

Setup

Must create the DB first $> createdb my-music

@ozexpert
ozexpert / ionic2.image-cache.directive.ts
Last active February 21, 2024 11:13
AngularJS2 / Ionic2 : ImageCache Directive to use with imgcache.js
import { Directive, ElementRef, Input } from '@angular/core';
declare var ImgCache: any;
@Directive({
selector: '[image-cache]'
})
export class ImageCacheDirective {
constructor (
private el: ElementRef
@Restuta
Restuta / framework-sizes.md
Last active March 7, 2024 00:01
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@petenelson
petenelson / multiformat-wp-api-response.php
Last active February 26, 2021 21:49
WordPress: Example of returning non-JSON results from the WP-API
<?php
// reference https://github.com/WP-API/WP-API/blob/develop/lib/infrastructure/class-wp-rest-server.php
// serve_request() function
add_filter( 'rest_pre_serve_request', 'multiformat_rest_pre_serve_request', 10, 4 );
function multiformat_rest_pre_serve_request( $served, $result, $request, $server ) {
// assumes 'format' was passed into the intial API route
// example: https://baconipsum.com/wp-json/baconipsum/test-response?format=text
@rmehner
rmehner / delete-databases.js
Last active May 13, 2024 13:40
Delete all indexedDB databases
// Credit to @steobrien from https://gist.github.com/rmehner/b9a41d9f659c9b1c3340#gistcomment-2940034
// for modern browsers, this works:
const dbs = await window.indexedDB.databases()
dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) })
// for older browsers, have a look at previous revisions of this gist.
@itzg
itzg / 0_AddingPersistentVirtualDiskToBoot2Docker.md
Last active February 22, 2021 01:21
Manually adding persistent storage to a VirtualBox VM of boot2docker

These instructions build on those provided here and here.

Before doing the following, create a new virtual disk and attach it to your VM. The size of the virtual disk just depends on what you intend to use/run and how many containers you intend to run. The default, 8 GB, is probably more than enough and is reasonable to use if in doubt since the default mode dynamically allocates the drive as needed.

Boot the VM and run just

fdisk -l

To see the disk device name(s) and their size. In this case it's the /dev/sda shown here that has 8 GB capacity: