Skip to content

Instantly share code, notes, and snippets.

View sadeghbarati's full-sized avatar
🤨

Sadegh Barati sadeghbarati

🤨
  • Iran, Mashhad
  • 01:29 (UTC +03:30)
View GitHub Profile
@g00glen00b
g00glen00b / netlify-build-hook.php
Created January 21, 2020 13:13
WordPress Netlify build hook plugin
<?php
/**
* Plugin Name: Netlify build hook
* Plugin URI: https://dimitr.im
* Description: Call webhook when WordPress post is published
* Version: 1.0
* Author: g00glen00b
* Author URI: https://dimitr.im
*/
add_action('publish_future_post', 'nb_webhook_future_post', 10);
html {
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}
@getify
getify / naf.js
Created June 27, 2012 14:19
requestNextAnimationFrame() and cancelNextAnimationFrame()
// requires raf.js (polyfil)
(function(){
var ids = {};
function requestId(){
var id;
do {
id = Math.floor(Math.random() * 1E9);
} while (id in ids);
@seblambla
seblambla / getTotalLength.js
Created November 16, 2015 10:33
getTotalLength() equivalent for circle, rect, polygon and line shapes.
/*
Author: ZetCoby
http://stackoverflow.com/a/30376660/3708754
*/
var tools = {
/**
*
* Used to get the length of a rect
*
@mul14
mul14 / readme.md
Last active October 13, 2020 06:37
JavaScript Upload FormData
<form id="form">
  <input type="name" name="full_name" />
  <input type="file" name="image" />
  <button type="submit">Submit</button>    
</form>
// Fetch
@Abban
Abban / handleUpload.php
Last active October 13, 2020 06:39
jQuery AJAX file uploads. Code for the following blog post: http://abandon.ie/notebook/simple-file-uploads-using-jquery-ajax
<?php // You need to add server side validation and better error handling here
$data = array();
if(isset($_GET['files']))
{
$error = false;
$files = array();
$uploaddir = './uploads/';
@pierrehenri220
pierrehenri220 / barba-settings.js
Created December 6, 2016 01:25
Update html head tags with Barba.js
Barba.Dispatcher.on('newPageReady', function(currentStatus, oldStatus, container, newPageRawHTML) {
// html head parser borrowed from jquery pjax
var $newPageHead = $( '<head />' ).html(
$.parseHTML(
newPageRawHTML.match(/<head[^>]*>([\s\S.]*)<\/head>/i)[0]
, document
, true
)
);
var headTags = [
@B-iggy
B-iggy / inline-svg-function.scss
Last active December 13, 2020 11:53
Inline SVG function [SASS]
// set svg d path used as fallback (star)
$svg-d-path: 'm25,1l6,17l18,0l-14,11l5,17l-15,-10l-15,10l5,-17l-14,-11l18,0l6,-17z' !default;
// functions to urlencode the svg string
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
@5t3ph
5t3ph / 11ty-imgBase.md
Created January 24, 2021 03:27
Set a variable for a directory base path for images in Markdown for 11ty

{% set imgBase %}/img/post-directory/{% endset %}

![Alt text]({{ imgBase }}img-name.png)