Skip to content

Instantly share code, notes, and snippets.

View johnkingzy's full-sized avatar
🎯
Focusing

Kingsley Solomon johnkingzy

🎯
Focusing
View GitHub Profile
@johnkingzy
johnkingzy / getdates.js
Last active February 19, 2018 22:31 — forked from miguelmota/getDates.js
Get dates in between two dates with JavaScript.
// Returns an array of dates between the two dates
var getDates = function(startDate, endDate) {
var dates = [],
currentDate = startDate,
addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
};
while (currentDate <= endDate) {
@johnkingzy
johnkingzy / index.html
Created February 19, 2018 22:29
Index.html from the /dist folder
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Client</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
@johnkingzy
johnkingzy / gulpfile.js
Created February 19, 2018 22:33
Intial Gulp file
var gulp = require("gulp");
var rename = require("gulp-rename");
var clean = require("gulp-clean");
var fs = require("fs");
var cheerio = require("cheerio");
var ts = require("typescript");
gulp.task("dist", function() {
// task operations - begin
@johnkingzy
johnkingzy / gulpfile.js
Created February 19, 2018 22:36
Gulp file that copies all /dist content and cleans the laravel public folder
// tasks operations - begin
var files = [
"./../server/public/*",
"!./../server/public/.htaccess",
"!./../server/public/index.php",
"!./../server/public/storage",
"!./../server/public/favicon.ico"
];
// remove old dist folder content from the laravel public folder
gulp.src(files, { read: false }).pipe(clean({ force: true }));
@johnkingzy
johnkingzy / gulpfile.js
Created February 19, 2018 23:04
Get the css and script tags that needs to be injected into the laravel view
var $ = cheerio.load(fs.readFileSync("./dist/index.html", "utf8"));
//get script tags that need to be injected into the laravel view
var scripts = $("script").map(function(i, el) {
return $("<div>").append($(el)).html();
}).toArray();
//get css tags that need to be injected into main laravel view
var styles = $("link").filter(function(i, el) {
return $(el).attr("href").indexOf("bundle.css") > -1;
<html>
<head>
<title>Client</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="icon" type="image/x-icon" href="favicon.ico">
{{--angular styles begin--}}
{{--angular styles end--}}
//js scripts replace regex
var jsSearch = /{{ — angular scripts begin — }}[\s\S]*{{ — angular scripts end — }}/;
var jsReplaceStr =
“{{ — angular scripts begin — }}” +
“\n\t\t” +
scripts.join(“\n\t\t”) +
“\n\t\t{{ — angular scripts end — }}”;
//css styles replace regex
@johnkingzy
johnkingzy / gulpfile.js
Created February 19, 2018 23:23
Final output for Gulp file
var gulp = require("gulp");
var rename = require("gulp-rename");
var clean = require("gulp-clean");
var fs = require("fs");
var cheerio = require("cheerio");
var ts = require("typescript");
gulp.task("dist", function() {
var files = [
"./../server/public/*",
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
@johnkingzy
johnkingzy / git_empty_branch
Created February 20, 2018 03:43 — forked from j8/git_empty_branch
Create new branch with empty folder structure
You can create a new empty branch like this:
$ git checkout --orphan NEWBRANCH
--orphan creates a new branch, but it starts without any commit. After running the above command you are on a new branch "NEWBRANCH", and the first commit you create from this state will start a new history without any ancestry.
The --orphan command keeps the index and the working tree files intact in order to make it convenient for creating a new history whose trees resemble the ones from the original branch.
Since you want to create a new empty branch that has nothing to do with the original branch, you can delete all files in the new working directory: