Skip to content

Instantly share code, notes, and snippets.

View easingthemes's full-sized avatar
🕳️
 

Dragan Filipović easingthemes

🕳️
 
View GitHub Profile
@ghinda
ghinda / object-to-form-data.js
Last active March 30, 2024 18:51
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
@matthewsuan
matthewsuan / axios.js
Last active March 28, 2024 12:36
Axios request queue-like that limits number of requests at any given time
import axios from 'axios'
const MAX_REQUESTS_COUNT = 5
const INTERVAL_MS = 10
let PENDING_REQUESTS = 0
// create new axios instance
const api = axios.create({})
/**
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
<alignment jcr:primaryType="nt:unstructured"
name="./alignChildren"
fieldLabel="Alignment of components"
required="{Boolean}true"
selectionMode="single"
sling:resourceType="granite/ui/components/coral/foundation/form/buttongroup">
<items jcr:primaryType="nt:unstructured">
<default jcr:primaryType="nt:unstructured"
name="./default"
@nateyolles
nateyolles / curlPackageFilterRules.sh
Last active November 2, 2023 16:30
AEM/CQ cURL: Adding include/exclude rules to package filters
# Adding include/exclude rules to CQ/AEM package filters through cURL.
# Through a simple search, you will find numerous lists of CQ/AEM cURL commands.
# However, I haven't seen an example of adding rules to package filters. The
# JSON "rules" key takes an array value. You can leave the array empty if you
# don't need to include any rules. The array is of JSON objects with a
# "modifier" key and value of "include" or "exclude", and a "pattern" key with
# your path or regular expression as the value.
# create package
@nyurik
nyurik / to-logical.py
Last active January 16, 2023 08:29
Script to convert SCSS files from physical to logical values for RTL and vertical languages
#
# This script converts margins, padding, and borders to logical values,
# allowing RTL and vertical languages to show correctly.
# Supports both *.css and *.scss files.
#
# Some renames are not yet implemented widely, and may require CSS plugin
# https://github.com/csstools/postcss-logical
# They have been commented out for now, but feel free to try them out.
#
# Full spec: https://drafts.csswg.org/css-logical/
@CITguy
CITguy / custom-task.js
Last active January 13, 2023 19:23
Basic pattern for creating a custom Transform stream for use with gulp tasks.
var gulp = require('gulp');
var myTransform = require('./myTransform');
gulp.task('foobar', function (){
return gulp.src("foobar.js")
.pipe(myTransform())
.pipe(gulp.dest('.'));
});
@yesvods
yesvods / gist:51af798dd1e7058625f4
Created August 15, 2015 11:13
Merge Arrays in one with ES6 Array spread
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]
@torgeir
torgeir / audio-source-microphone.js
Created September 19, 2013 17:55
Microphone input as audio source js
window.AudioContext = window.AudioContext || window.webkitAudioContext;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia;
window.addEventListener('load', init, false);
function init () {
try {
record(new AudioContext());
}
catch (e) {
@jeremyben
jeremyben / jest-coverage-badges.ts
Last active January 26, 2022 05:38
Get shields.io badges for jest coverage.
// Make sure you have json-summary as a coverage reporter in your jest config.
// coverageReporters: ['json-summary', 'text', 'lcov']
import { readFileSync, mkdirSync, writeFileSync } from 'fs'
import { join } from 'path'
import { get } from 'https'
import { ok } from 'assert'
Promise.resolve().then(async () => {
const outputDir = join(process.cwd(), 'badges')