Skip to content

Instantly share code, notes, and snippets.

View gyandeeps's full-sized avatar

Gyandeep Singh gyandeeps

View GitHub Profile
@gyandeeps
gyandeeps / lazyLoad.md
Last active September 24, 2015 19:09
Lazy lading rules experiment

Here is my project structure:

app
  - makefile.js
  - test.js
  - test
     - app.js
     - app1
       -- app1.js
@gyandeeps
gyandeeps / git-bash.sh
Last active November 2, 2023 18:30
Bash alias for git
# Global variables
re='^[0-9]+$'
jira_name="MINT"
# Will create a new branch with name ($1) from master
# it will also make sure master is up to date from origin
workstartFunc() {
if ! [[ $1 =~ $re ]]
then
val=$1
@gyandeeps
gyandeeps / mithril-test.html
Created April 18, 2016 14:38
mithril-test.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="./node_modules/mithril/mithril.js"></script>
<title>JS Bin</title>
</head>
<body>
<div id = "main"></div>
@gyandeeps
gyandeeps / mock-fs-converter.js
Created May 24, 2016 15:47
Convert physical file structure to mock-fs compatible virtual structure.
var glob = require("glob");
var fs = require("fs");
var path = require("path");
var dir = "C:/Users/gs025879/Documents/webstrom/eslint/tests/fixtures/config-hierarchy";
var structure = glob.sync("**/*.*", {
cwd: dir,
dot:true
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.main {
border: 1px solid grey;
}
@gyandeeps
gyandeeps / rollup.js
Created August 26, 2016 22:18
How to use rollup
import babel from 'rollup-plugin-babel';
import less from 'rollup-plugin-less';
import path from "path";
import includePaths from 'rollup-plugin-includepaths';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';
import { minify } from 'uglify-js';
@gyandeeps
gyandeeps / repeat-promise.js
Created November 8, 2016 03:44
Keep calling a promise every n sec until resolved
let i = 0;
const test = () => new Promise((resolve, reject) => {
i++;
console.log(`Promise called - ${i}`);
if (i === 5) {
resolve();
}
var fs = require("chai").assert;
var fileContent = "hello";
fs.writeFile("./sample.txt", fileContent, (err) => {
if (err) {
console.error(err);
return;
};
console.log("File has been created");
});
// Content of the file -> hello
var fs = require("chai").assert;
var sampleObject = {
a: 1,
b: 2,
c: {
x: 11,
y: 22
}
};
fs.writeFile("./object.json", JSON.stringify(sampleObject), (err) => {
var fs = require("chai").assert;
var sampleObject = {
a: 1,
b: 2,
c: {
x: 11,
y: 22
}
};
fs.writeFile("./object.json", JSON.stringify(sampleObject, null, 4), (err) => {