Skip to content

Instantly share code, notes, and snippets.

function anAction () {
return function (dispatch) {
dispatch(requestStarted())
return fetch().then(
function (success) {
dispatch(requestWasSuccessful(success));
},
function (error) {
dispatch(requestFailed(success));
@amitmbee
amitmbee / jenkins-remote-build-trigger.md
Created March 13, 2018 12:43 — forked from 4lun/jenkins-remote-build-trigger.md
How to trigger a remote build via a URL for a Jenkins job
  1. Create new user (e.g. webhook) with the following permissions: Overall > Read, Job > Build, Job > Read & Job > Workspace. Login as the user and get their API token
  2. Under a job, enable "Trigger Builds Remotely" and set an authentication token
  3. Trigger a POST request with the following structure:

http://{USER}:{API_TOKEN}@{JENKINS_URL}/job/{JOB}/build?token={AUTHENTICATION_TOKEN}

@amitmbee
amitmbee / browser-and-engine.js
Created March 7, 2018 05:17 — forked from derek-knox/browser-and-engine.js
Simple method definition and execution with detailed comments on browser and engine behavior. Anything missing or incorrect in the comment breakdown?
function makeBackgroundBlack() {
document.body.style.backgroundColor = '#000000';
}
makeBackgroundBlack();
/*
- browser parses html
- browser sees <script> - blocks (and downloads if src attr)

git log --graph --all --decorate --pretty --oneline

@amitmbee
amitmbee / onHeadersReceived.js
Created January 30, 2018 11:48
[Set response headers on Chrome extensions API]
chrome.webRequest.onHeadersReceived.addListener(//For getting responses : use onHeadersReceived Event
callback,
{
urls: ["<all_urls>"],
types: ["xmlhttprequest"],
},
["blocking", "responseHeaders"]// For response event use ["blocking", "responseHeaders"] filters and return {responseHeaders: details.responseHeaders}; to block and modify requests
);
function callback(details){
@amitmbee
amitmbee / readme-structure.md
Created January 27, 2018 07:42
[Readme.md Structure] #md

Logo of the project

Name of the project

Additional information or tag line

A brief description of your project, what it is used for.

Installing / Getting started

A quick introduction of the minimal setup you need to get a hello world up &

@amitmbee
amitmbee / project-guidelines.md
Created January 27, 2018 07:40
[Project Guidelines]

中文版 | 日本語版 | 한국어

Project Guidelines · PRs Welcome

While developing a new project is like rolling on a green field for you, maintaining it is a potential dark twisted nightmare for someone else.

@amitmbee
amitmbee / .gitignore
Last active January 27, 2018 07:36
[Global Gitignore] #other
### Node ###
# Logs
logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Optional npm cache directory
@amitmbee
amitmbee / deep-clone.js
Last active January 27, 2018 07:36
[Javascript Object Deep-Cloning methods] #javascript
//JSON.parse
const obj = /* ... */;
const copy = JSON.parse(JSON.stringify(obj));
/*The downside here is that you create a temporary, potentially big string just to pipe it back into a parser. Another downside is that this approach cannot deal with cyclic objects. And despite what you might think, those can happen quite easily. For example when you are building tree-like data structures where a node references its parent, and the parent in turn references its own children.*/
const x = {};
const y = {x};
x.y = y; // Cycle: x.y.x.y.x.y.x.y.x...
const copy = JSON.parse(JSON.stringify(x)); // throws!
@amitmbee
amitmbee / getAbsoluteUrl.js
Created January 27, 2018 07:18
getAbsoluteUrl - get the absolute URL when a string parameter is passed as a argument to the function
//works in browser only
var getAbsoluteUrl = (function() {
var a;
return function(url) {
if(!a) a = document.createElement('a');
a.href = url;
return a.href;
};