Skip to content

Instantly share code, notes, and snippets.

View alonronin's full-sized avatar
:octocat:
Me. Write. Code.

Alon Valadji alonronin

:octocat:
Me. Write. Code.
View GitHub Profile
import { RequestInit } from 'next/dist/server/web/spec-extension/request';
type DefaultOptions = {
baseUrl: string;
headers: Headers;
};
const defaultOptions: DefaultOptions = {
baseUrl: '',
headers: new Headers({
@alonronin
alonronin / save-heroku-config-vars-to-env.sh
Created July 27, 2023 11:56 — forked from llighterr/save-heroku-config-vars-to-env.sh
Command line to save Heroku config vars into .env file
heroku config | sed 's/: */=/g; /^=/d' >> .env
@alonronin
alonronin / chasis.js
Last active February 24, 2020 17:45
JS-IL 02/2020
const express = require('express');
const { json, urlencoded } = require('body-parser');
const helmet = require('helmet');
const cors = require('cors');
const morgan = require('morgan');
const debug = require('debug');
const compression = require('compression');
const http = require('http');
const camelCase = require('lodash.camelcase');
@alonronin
alonronin / index.html
Created January 21, 2020 02:37
JS Bin friendly iframe // source https://jsbin.com/setudej/2
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="friendly iframe">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
html {
height: 100vh;
@alonronin
alonronin / README.md
Last active June 20, 2019 11:04
Cross Domain LocalStorage

Cross Orrigin LocalStorage

Get access to LocalStorage on Cross-Origin Domains.

Usage

Put the iframe.html in your remote domain.

@alonronin
alonronin / async.test.js
Created September 28, 2017 21:01
Jest async await test
const myPromise = () => Promise.resolve('ok');
describe('Async - Await Test', () => {
test('Async', async () => {
expect(await myPromise()).toBe('ok');
})
});
@alonronin
alonronin / api.js
Created June 14, 2017 11:37
An api implementation using Proxy
const target = {};
const handler = {
get(target, property, receiver) {
return fetch(`https://jsonplaceholder.typicode.com/${property}`)
.then(r => r.json())
}
};
const api = new Proxy(target, handler);
@alonronin
alonronin / cms.js
Last active December 12, 2015 22:14
Ronin CMS
'use strict';
var app = require('./app');
var models = require('./models');
var async = require('async');
var _ = require('lodash');
/*
middle-wares
*/
var config = models.config.middleware();
@alonronin
alonronin / recurssive.tree.js
Last active August 26, 2023 09:23
Create recursive tree from json using lodash transform without recursion. Can have unlimited nesting.
var _ = require('lodash');
var arr = [
{"name":"my2child1","title":"My 2 Child 1","parent":"my2"},
{"name":"my2child2","title":"My 2 Child 2","parent":"my2"},
{"name":"parent","title":"A single parent"},
{"name":"child-parent","title":"A child parent","parent":"child1"},
{"name":"my","title":"My"},
{"name":"my2","title":"My2"},
{"name":"child1","title":"Child 1","parent":"my"},
@alonronin
alonronin / service.js
Created June 23, 2015 10:40
mocking promises $q.all using $scope.$apply()
+function(angular){
'use strict';
angular.module('app.services')
.service('MyService', function($q){
var self = this;
var a = function(){ return $q.when({}) };
var b = function(){ return $q.when({}) };