Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris O'Donnell codfish

View GitHub Profile
@DavidWells
DavidWells / javascript-proxy-as-rest-client.js
Last active May 9, 2023 15:18
Using a javascript proxy as low code REST client
View javascript-proxy-as-rest-client.js
/* Using a JavaScript proxy for a super low code REST client */
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3
// also see https://github.com/fastify/manifetch
// also see https://github.com/flash-oss/allserver
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const createApi = (url) => {
return new Proxy({}, {
get(target, key) {
@javdl
javdl / #linting.md
Last active June 28, 2022 14:31 — forked from codfish/#linting.md
Prettier + ESLint + airbnb config + Husky + lint-staged + commitlint + markdownlint
View #linting.md

Joost:

  • added steps to fix markdown via cli (extra script)

  • autofix in vs code on save, add this setting:

    "editor.codeActionsOnSave": { "source.fixAll.markdownlint": true }

original:

@monkeymonk
monkeymonk / jquery.scrollToTop.js
Created April 8, 2016 08:26
ES6 jQuery plugin definition
View jquery.scrollToTop.js
import $ from 'jquery';
import plugin from './plugin';
class ScrollToTop {
constructor(element, options) {
const $element = $(element);
$(window).scroll(function () {
if ($(this).scrollTop() > options.offset) {
$element.fadeIn();
@Yimiprod
Yimiprod / difference.js
Last active May 31, 2023 15:30
Deep diff between two object, using lodash
View difference.js
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {
@rpavlovic
rpavlovic / wp_average_comments.sql
Created January 29, 2015 14:43
Wordpress SQL: average comments per day over time
View wp_average_comments.sql
SELECT
'2010-11-24' AS date_begin,
'2015-01-26' AS date_end,
day_of_week,
AVG(comment_count) AS average_comments
FROM (
SELECT
comment_date,
DAYNAME(comment_date) day_of_week,
DAYOFWEEK(comment_date) day_num,
@ozh
ozh / gist:0cd11817a4767d87bb72
Created January 19, 2015 11:42
Manual CRON in WP
View gist:0cd11817a4767d87bb72

wp-config.php:

define( 'DISABLE_WP_CRON', true );

Cronjob: one of:

*/15 * * * * wget -q -O - http://www.website.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
*/15 * * * * curl http://www.website.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1
*/15 * * * * cd /home/user/public_html; php wp-cron.php > /dev/null 2>&1
View Capfile
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Custom tasks
require 'capistrano/composer'
require 'capistrano/npm'
@CMCDragonkai
CMCDragonkai / UrlFriendly.Filter.js
Created August 21, 2013 06:36
JS: Angular Url Friendly Filter. Can be used to create url friendly permalinks from blog titles. Port of url_title in Codeigniter.
View UrlFriendly.Filter.js
define(['angular'], function(angular){
'use strict';
angular.module('Filters')
.filter('UrlFriendly', [
function(){
return function(text, separator, lowercase){
var output,
@ianmariano
ianmariano / git-fork-sync
Last active April 21, 2020 12:03
Syncs your repo fork with the upstream master and then pushes the synced master to origin. Presumes you have an 'upstream' remote which is from whence your fork was created. Put on your path and chmod a+x it then do: git fork-sync. Use -h for usage help.
View git-fork-sync
#!/usr/bin/env bash
set -Eeuo pipefail
VERSION="20200421.1"
_usage() {
cat << __EOF
$0 usage:
@ijones922
ijones922 / gist:5952576
Created July 8, 2013 21:17
Javascript: equal column heights
View gist:5952576
function matching_heights() {
var highestCol = Math.max($('').height(),$('').height());
$('').height(highestCol);
}